欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
SpringFramework(9)

6、ORM

1ORM

l         ORM:對象關(guān)系映射(Object-Relational Mapping

l         內建支持:

Ø         JDO

Ø         iBATIS

Ø         Hibernate

2Hibernate配置

l         定義DataSourceHibernate SessionFactory

<bean id="dataSource" ...> ... </bean>
<bean id="sessionFactory" class="...LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>employee.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">....DB2Dialect</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>

3HibernateTemplate

l         創(chuàng )建HibernateTemplate

SessionFactory sessionFactory = (SessionFactory) ctx.getBean("sessionFactory");
HibernateTemplate hibernate = new HibernateTemplate(sessionFactory);

l         加載和更新

Employee e = (Employee) hibernate.load(Employee.class, "000330");
e.setFirstName("BOB");
hibernate.update(e);

l         使用方便的方法查詢(xún)

List employees = hibernate.find("from app.Employee");
List list = hibernate.find(
"from app.Employee e where e.lastName=?",
"LEE",
Hibernate.STRING);
List list = hibernate.find(
"from app.Employee e where e.lastName=? and e.firstName=?",
new String[] { "BOB", "LEE" },
new Type[] {Hibernate.STRING , Hibernate.STRING });

l         使用回調方法查詢(xún)

List list = (List) hibernate.execute(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException {
List result = session.find("from app.Employee");
// do some further stuff with the result list
return result;
}
});

4)異常處理

l         傳遞Hibernate異常到DataAccessException

l         采用和JDBC相同的策略

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
hibernate在spring中的使用
Spring數據庫訪(fǎng)問(wèn)之ORM(二)
spring+hibernate多數據源+動(dòng)態(tài)切換 事宜 lazyload一應俱全
HibernateCallback的用法
在myeclipse下整合spring和hibernate
在Spring+hebernate中 Cannot get a connection, pool error Timeout waiting for idle object異常的解決辦法
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久