Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Lazy Load of Hibernate doesn't work in Liferay 7.2 DXP
We are using hibernate for service interaction. (Not service builder)At one model class, we are using Lazy load as follows:
It was working fine in Liferay 6.2 but after upgrading to 7.2 DXP, It returns the following error while trying to accessing this field.
@OneToOne(orphanRemoval = true, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "SCHOOL_ENROLMENTS_ID")
private final SchoolEnrolments enrolments = new SchoolEnrolments();
It was working fine in Liferay 6.2 but after upgrading to 7.2 DXP, It returns the following error while trying to accessing this field.
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:167)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:215)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
OSGi brings a lot of classloader restrictions and requirements into play. It can be difficult exposing these kinds of things within OSGi.
In 6.2 you had a portlet war file and your hibernate was isolated within the web application. This happens to be a construct that hibernate knows how to operate within. You'll have to stick to the same kind of deployment model to get it to work under 7.x.
In 6.2 you had a portlet war file and your hibernate was isolated within the web application. This happens to be a construct that hibernate knows how to operate within. You'll have to stick to the same kind of deployment model to get it to work under 7.x.
Even in 7.2, we are deploying as a war.
Why difficulty in exposing these kinds of things within OSGi.
And can you provide some examples for implementing Hibernate Lazy load in Liferay 7.2.
Why difficulty in exposing these kinds of things within OSGi.
And can you provide some examples for implementing Hibernate Lazy load in Liferay 7.2.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™