Lazy loading in One to One Mapping in hibernate

2019-08-03 11:16发布

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条回答
走好不送
2楼-- · 2019-08-03 11:28

Lazy Loading with OneToOne behaves little differently.

This might help you out. Just follow the post.

查看更多
登录 后发表回答