Reputation: 2107
I'm new with Hibernate 4.3 and need initialize the instances of the entities. With hibernate 3 I used the Hibernate.initialize() but in the version 4.3 the don't found the command neither the import org.hibernate.Hibernate.
I used the Eclipse Kepler and Wildfly 8.0.
can tell me how to do this?
Thanks
Upvotes: 0
Views: 337
Reputation: 2528
Things to consider :
Have you include hibernate jar files (especially the required jars) in your lib
folder ?
antlr-2.7.7.jar
commons-collections-3.2.1.jar
dom4j-1.6.1.jar
javassist-3.12.1.GA.jar
hibernate-core-4.0.1.Final.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
jboss-logging-3.1.0.CR2.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
this file is from hibernate
you will download and it will have required
folder inside lib
.
If yes
:
Right click the import which contains error , and click Fix project
setup and missing jar files
will be automatically included.
Upvotes: 0
Reputation: 26077
Issue is with classpath only that you are not able to see the imports correctly, also i would recommend to use the below code snippet for intializing proxies.
Create a class HibernateUtils and call it's static method.
public class HibernateUtils {
public static <T> T initializeAndUnproxy (T entity) {
if (entity == null) {
return null;
}
if (entity instanceof HibernateProxy) {
entity = (T) ((HibernateProxy) entity).getHibernateLazyInitializer().getImplementation();
}
return entity;
}
}
Upvotes: 2