Home @ManyToOne(fetch=FetchType.LAZY, optional=false) still fetching
Reply: 0

@ManyToOne(fetch=FetchType.LAZY, optional=false) still fetching

user1339 Published in June 23, 2018, 4:34 am

I have an @Embeddable class:

public class MyTable {
    @ManyToOne(fetch=FetchType.LAZY, optional=false)
    private MyOtherEntity myOtherEntity;

@DiscriminatorColumn(name="DISC", discriminatorType=DiscriminatorType.STRING)
public abstract class MyOtherEntity {

public class MyOtherEntityA extends MyOtherEntity {

public class MyOtherEntityB extends MyOtherEntity {

As with the LAZY fetch type, I would expect MyOtherEntity to be a proxy only, not the actual class initialised. But Hibernate is still issuing a query to fetch all its columns (except those further marked as LAZY within MyOtherEntity) once the owner class of MyTable calls getMyTable().

Adding optional=false as suggested in Hibernate: one-to-one lazy loading, optional = false and Hibernate ManyToOne FetchType.LAZY is not working? did not help. And the class is not final as suggested in Hibernate ManyToOne with FetchType.LAZY not fetching lazy . Any other reason how LAZY is not working as expected?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313596 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO