I have an @Embeddable
class:
@Embeddable
@Table(name="MY_TABLE")
public class MyTable {
@ManyToOne(fetch=FetchType.LAZY, optional=false)
@JoinColumn(name="my_other_id")
private MyOtherEntity myOtherEntity;
...
}
@Entity
@Table(name="MY_OTHER_TABLE")
@DiscriminatorColumn(name="DISC", discriminatorType=DiscriminatorType.STRING)
public abstract class MyOtherEntity {
...
}
@Entity
@DiscriminatorValue("A")
public class MyOtherEntityA extends MyOtherEntity {
...
}
@Entity
@DiscriminatorValue("B")
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?
specify @Proxy(lazy=true)
@Proxy(lazy=true)
@Embeddable
@Table(name="MY_TABLE")
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.