可以在spring配置文件中配置:
- <</SPAN>property
name="hibernateProperties"> -
<</SPAN>props> -
<</SPAN>prop key="hibernate.dialect">${hibernate.dialect}</</SPAN>prop> -
<</SPAN>prop key="hibernate.show_sql">${hibernate.show_sql}</</SPAN>prop> -
<</SPAN>prop key="connection.autocommit">false</</SPAN>prop> -
org.hibernate.hql.classic.ClassicQueryTranslatorFa ctory 可以在hibernate.cfg.xml中配置:
- <</SPAN>property
name="hibernate.query.factory_class"> -
org.hibernate.hql.classic.ClassicQueryTranslatorFa ctory - </</SPAN>property>
org.hibernate.hql.classic.ClassicQueryTranslatorFa
ctory
或者在写HQL的时候不吧中文参数拼凑进去,用query的setXxx。setProperties()方法
个人觉得这个跟ORM技术的ibatis中的SQLMAP有些许相似。它是用setProperties()方法。如:String
hql = " from Customer user where 1=1 and userr.mc like :sna " ;
Customer
cus = new Customer();
cus.setMc( " 惠止南国 " );
Session
session = getHibernateTemplate().getSessionFactory().openSession();
Transaction
tx = session.beginTransaction();
List
returnList = session.createQuery(sql).setProperties(cus).list();
tx.commit();
session.close();
- <</SPAN>property