Ò»¸öʵÏÖÁ˺ÍÊý¾Ý¿â´ò½»µÀµÄÔ´Îļþ£¨×é×°sqlÓï¾ä°æ£©
package com.itcast.service.base;
import java.util.LinkedHashMap;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.itcast.util.QueryResult;
/**
* Õë¶ÔËùÓÐʵÌåbeanµÄÒ»¸ö³éÏóÀ࣬ËùÓеÄʵÌåbean°üÀ¨ProductType,ProductµÈµÈ
* @author lucky
*
*/
@Transactional
public abstract class DaoSupport implements DAO {
@PersistenceContext protected EntityManager em;
//µ÷ÓÃÏÂÃæµÄpublic <T> void delete(Class<T> entityClass,Object[] entityids·½·¨
public <T> void delete(Class<T> entityClass,Object entityid) {
delete(entityClass,new Object[]{entityid});
}
public <T> void delete(Class<T> entityClass,Object[] entityids) {
for(Object id:entityids){
em.remove(em.getReference(entityClass, id));
}
}
@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)//˵Ã÷ÔÚÖ´Ðи÷½·¨µÄʱºò²»ÐèÒª½øÐÐÊÂÎñ´¦Àí
public <T> T find(Class<T> entityClass, Object entityid) {
return em.find(entityClass, entityid);
}
/**
* ¿ÉÒÔ×Ô¶¯¹ÜÀïÖ÷¼üidµÄÉú³É£¬µ«Ç°ÌáÊÇidÊÇ×Ô¶¯Éú³ÉµÄ
* ÈôidÊÇuuidµÄ»°£¬jpa¾Í²»Ö§³Ö×Ô¶¯¹ÜÀíÖ𽥵ŦÄÜ£¬×ÓÀà¾Í±ØÐëÖØд¸Ã·½·¨£¬ÊÖ¶¯Ìí¼ÓÖ÷¼ü
*/
public void save(Object entity) {
em.persist(entity);
}
public void update(Object entity) {
em.merge(entity);
}
@SuppressWarnings("unchecked")
@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)
/**
* ²éѯµÄÖÕ¼«×îÇ¿°æ£¬¼È¿ÉÒÔ·ÖÒ³£¬ÓÖ¿ÉÒÔ°´Ðò²éѯ£¬»¹¿ÉÒÔÓвéѯÌõ¼þ£¬ÆäËûµÄ²éѯ¶¼Ê¹ÓÃÕâ¸ö²éѯ·½·¨
* orderby Óï¾ä¸ñʽ£ºorder by key1 asc
Ïà¹ØÎĵµ£º
´´½¨Ò»¸ö¼òµ¥µÄ´¥·¢Æ÷
´¥·¢Æ÷ÊÇÒ»ÖÖÌØÊâµÄ´æ´¢¹ý³Ì£¬ÀàËÆÓÚʼþº¯Êý£¬SQL Server? ÔÊÐíΪ INSERT¡¢UPDATE¡¢DELETE ´´½¨´¥·¢Æ÷£¬¼´µ±ÔÚ±íÖвåÈë¡¢¸üС¢É¾³ý¼Ç¼ʱ£¬´¥·¢Ò»¸ö»òһϵÁÐ T-SQLÓï¾ä¡£
´¥·¢Æ÷¿ÉÒÔÔÚ²éѯ·ÖÎöÆ÷Àï´´½¨£¬Ò²¿ÉÒÔÔÚ±íÃûÉϵãÓÒ¼ü->“ËùÓÐÈÎÎñ”->“¹ÜÀí´¥·¢Æ÷”À´´´½¨£¬²» ......
character-set-server = GB2312
collation-server = latin1_general_ci
MySQL×Ö·û¼¯ GBK¡¢GB2312¡¢UTF8Çø±ð ½â¾ö MYSQLÖÐÎÄÂÒÂëÎÊÌâ ÊÕ²Ø
MySQLÖÐÉæ¼°µÄ¼¸¸ö×Ö·û¼¯
character-set-server/default-character-set£º·þÎñÆ÷×Ö·û¼¯£¬Ä¬ÈÏÇé¿öÏÂËù²ÉÓõġ£
character-set-database£ºÊý¾Ý¿â×Ö·û¼¯¡£
character-set-table£ºÊ ......
1 £¬¶ÔÓÚÈÕÆÚ×Ö¶Î×Ö¶Î
access±íʾΪ£º#1981-28-12#
SQLSERVER2000±íʾΪ£º''1981-02-12''
2,SQLÓï¾äÇø±ð£¬select ,update ÔÚ¶Ôµ¥±í²Ù×÷ʱ¶¼²î²»¶à£¬
µ«¶à±í²Ù×÷ʱupdateÓï¾äµÄÇø±ðACCESSÓëSQLSERVERÖеÄUpdateÓï¾ä¶Ô±È:
SQLSERVERÖиüжà±íµÄUpdateÓï¾ä:
Update Tab1
SET a.Name = b.Name
from Tab1 a,Tab2 b
Whe ......
SQLÖ®ÐÐÁл¥±äÎÊÌâ¡£
Ñ°Ñ°ÃÙÃÙ£¬SQLÐбäÁУ¬ÁбäÐÐÎÊÌâËäÈ»½â¾ö·½°¸Öڶ࣬µ«ÎÞ²»´æÔÚ×Å´úÂ븴ÔÓ£¬ÐÔÄÜÇ·¼ÑµÈÎÊÌâ¡£½ñÓÐÐÒµÃÖª×î¼Ñ½â¾ö·½°¸£¬ºÃ¶«Î÷²»¸Ò¶ÀÏí£¬±Ê¼ÇÖ®£¬ÑÅË×¹²ÉÍ¡£
ʾÀýÊý¾Ý£º£¨¸ÃʾÀýÊý¾ÝÀ´×ÔYHHRÊý¾Ý¿â Performance_Zmonth_Value±í£©
Employee_Id& ......
ÎÊÌâ
ÈçºÎ´´½¨Ò»¸öT-SQL²âÊÔÌ×¼þÓÃÓÚ²âÊÔSQL´æ´¢¹ý³Ì¡£
Éè¼Æ
Ê×ÎÞ£¬Í¨¹ý²åÈë´óÁ¿²âÊÔƽ̨Êý¾Ý×¼±¸ºÃÒ»¸ö°üº¬´ý²â´æ´¢¹ý³ÌµÄµ×²ãÊý¾Ý¿â¡£½ÓÏÂÀ´£¬Ê¹ÓÃÒ»¸öSQLÓαê(cursor)±éÀúÕâ¸ö²âÊÔÓÃÀýÊý¾Ý±í¡£Õë¶Ôÿ¸ö²âÊÔÓÃÀý£¬µ÷Óôý²â´æ´¢¹ý³Ì²¢ÇÒÈ¡µÃËüµÄ·µ»ØÖµ£ ......