简体   繁体   中英

Lazy loading in One to One Mapping in hibernate

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?

Lazy Loading with OneToOne behaves little differently.

This might help you out. Just follow the post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM