只需在配置文件ApplicationContext.xml中加入下面代碼紅色部分。
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
destroy-method="destroy" >
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/snsoft/crm/domain/SnRukudan.hbm.xml</value>
<value>com/snsoft/crm/domain/SnKehu.hbm.xml</value
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.query.factory_class">
org.hibernate.hql.classic.ClassicQueryTranslatorFactory
</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
</bean>
上面這種方法有時也會存在很多問題,最好的方法還是利用Hiberante的參數綁定。例如:
Query query = session.createQuery("from TUser user where user.name=? and user,age>?");
query.setString(0,"Erica");
query.setInteger(1,20);
減肥瘦身品總匯
值得信賴*脈脈美妝*正品現貨謝絕講價
〓深港商盟〓名品歐衣坊(美國休閑品牌AF系列)
QQ三國游戲幣及道具專賣店
小臉紅紅的瘦身旗艦店
posted on 2009-04-18 00:29
龍華城 閱讀(1842)
評論(1) 編輯 收藏 所屬分類:
Hibernate