Lazy loading in One to One Mapping in hibernate

99封情书 提交于 2020-01-05 09:06:55

问题


I have a data model class Account.In Account class I have one one property Contact(Custom class) and this is having one to one mapping.So I am using like this in Account class:

@OneToOne(mappedBy = "account", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
public Contact getContact() {
        return contact;
    }

After doing this contact property is not lazy loading.I have tried optional=false and @LazyToOne (LazyToOneOption.NO_PROXY).But no luck. Could you please help me?


回答1:


Lazy Loading with OneToOne behaves little differently.

This might help you out. Just follow the post.



来源:https://stackoverflow.com/questions/24757555/lazy-loading-in-one-to-one-mapping-in-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!