Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将一个对象复制到另一个(它的属性)。该对象由 Hibernate 管理并具有惰性集合。PropertyUtils.copyProperties() 抛出惰性异常。
有什么办法吗?
PS:我不想取消代理我的对象,因为我不拥有它(它在另一个罐子里)
在复制之前,您可以在原始对象的每个惰性集合上调用 Hibernate.initialize()。显然,如果你的对象与 Hibernate 会话分离,它不会在事务之外工作。所以,你必须足够早地初始化你的惰性集合。