如何在运行时设置获取类型? +休眠 [英] how to set fetch type at runtime ? + Hibernate
本文介绍了如何在运行时设置获取类型? +休眠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在运行时设置fetch类型在hibernate 3.2中?
session.beginTransaction();
Customer customer = session.get(getCustomerId());
session.save(customer);
session.commit();
如果有可能在运行时更改提取类型(lazy / eager)。所以,当已经定义了一个获取模式,即在hibernate.mapping文件中的select / join时,是否有任何影响?如果问题有任何问题,抱歉。
解决方案可以使用
join fetch
来指定一个特定的集合来初始化。 例如。
from cat as cat
内部连接读取cat.mate
左边连接读取cat.kittens
查看更多 here
或者你可以使用标准API
how to set fetch type at run time in hibernate 3.2?
session.beginTransaction();
Customer customer = session.get(getCustomerId());
session.save(customer);
session.commit();
if any possibility to change fetch type("lazy/eager") at run time. so,is there any impact when already defined a fetch mode i.e.,"select/join" in hibernate.mapping file?.If any wrong with question sorry.
解决方案
You can use join fetch
to specify a specific collection to initialize.
e.g.
from Cat as cat
inner join fetch cat.mate
left join fetch cat.kittens
See more here
Or you can use the criteria API
这篇关于如何在运行时设置获取类型? +休眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文