These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: CGLIB problem
PostPosted: Tue Mar 07, 2006 3:30 am 
Newbie

Joined: Tue Mar 07, 2006 3:12 am
Posts: 3
We are using Hibernate 3.1 in our project.
Previously I was using Hibernate 2.x for this project, when Hibernate 3.x released we decide to migrate the existing codes to Hibernate 3.x compaitable ones. We have done every things to convert to hibernate 3.x and it is working now. We currently have only one problem i.e if we use lazy loading in any of our HBM file then is throwing exception like CGLIB enhancement failed: IllegalAccessException.
Can anybody help me out for this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 5:44 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
We'll need a full exception trace, and any pertinent code. The most common cause of this error is that you have a final class or method in a class that CGlib is trying to proxy. You shouldn't have final classes or members in classes mapped in hibernate.


Top
 Profile  
 
 Post subject: Re: CGLIB problem
PostPosted: Tue Mar 07, 2006 5:49 pm 
Beginner
Beginner

Joined: Wed Jun 09, 2004 2:49 pm
Posts: 25
I had a similar problem once when we use a different JVM.
Maybe your problem is different.
Anyway in my case,
It turned out it is casued by a particlur mapping. Onece I removed that mapping, everythink becomes fine.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 2:22 am 
Newbie

Joined: Tue Mar 07, 2006 3:12 am
Posts: 3
Thanx for early reply.
Here is the full exceptions:

2006-03-08 11:45:39,507 ERROR - CGLIB Enhancement failed: com.unisys.ecs.server.hibernate.Procedures
java.lang.IllegalAccessError
at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.java:45)
at net.sf.cglib.core.ClassEmitter.<init>(ClassEmitter.java:37)
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
at com.unisys.ecs.server.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:49)
at com.unisys.ecs.server.hibernate.HibernateUtility.getUserDetails(HibernateUtility.java:176)
at com.unisys.ecs.server.session.LoginEJBBean.login(LoginEJBBean.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMethod.java:32)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java:166)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1357)
at com.inprise.ejb.Dispatcher.invokeSecurityCheck(Dispatcher.java:1065)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:827)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:603)
at com.inprise.ejb.EJBHome.dispatcherInvokeBeanMethod(EJBHome.java:84)
at com.inprise.ejb.EJBHome$ComponentInterfaceMethodCache.invokeDispatcherMethod(EJBHome.java:1581)
at com.inprise.ejb.EJBHome.invokeDispatcherMethod(EJBHome.java:62)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:429)
at com.unisys.ecs.server.session.LoginEJBPOAInvokeHandler.login(LoginEJBPOAInvokeHandler.java:80)
at com.unisys.ecs.server.session.LoginEJBPOAInvokeHandler.login(LoginEJBPOAInvokeHandler.java:196)
at com.unisys.ecs.server.session.LoginEJBPOA._invoke(LoginEJBPOA.java:85)
at com.unisys.ecs.server.session.LoginEJBPOA._invoke(LoginEJBPOA.java:58)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2916)
at com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:187)
at com.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInterceptorManager.java:115)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.java:868)
at com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapter.java:68)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAdapter.java:1158)
at com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.java:111)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:95)
2006-03-08 11:45:39,522 WARN - could not create proxy factory for:com.unisys.ecs.server.hibernate.Procedures
org.hibernate.HibernateException: CGLIB Enhancement failed: com.unisys.ecs.server.hibernate.Procedures
at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:132)
at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
at com.unisys.ecs.server.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:49)
at com.unisys.ecs.server.hibernate.HibernateUtility.getUserDetails(HibernateUtility.java:176)
at com.unisys.ecs.server.session.LoginEJBBean.login(LoginEJBBean.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMethod.java:32)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java:166)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1357)
at com.inprise.ejb.Dispatcher.invokeSecurityCheck(Dispatcher.java:1065)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:827)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:603)
at com.inprise.ejb.EJBHome.dispatcherInvokeBeanMethod(EJBHome.java:84)
at com.inprise.ejb.EJBHome$ComponentInterfaceMethodCache.invokeDispatcherMethod(EJBHome.java:1581)
at com.inprise.ejb.EJBHome.invokeDispatcherMethod(EJBHome.java:62)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:429)
at com.unisys.ecs.server.session.LoginEJBPOAInvokeHandler.login(LoginEJBPOAInvokeHandler.java:80)
at com.unisys.ecs.server.session.LoginEJBPOAInvokeHandler.login(LoginEJBPOAInvokeHandler.java:196)
at com.unisys.ecs.server.session.LoginEJBPOA._invoke(LoginEJBPOA.java:85)
at com.unisys.ecs.server.session.LoginEJBPOA._invoke(LoginEJBPOA.java:58)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2916)
at com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:187)
at com.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInterceptorManager.java:115)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.java:868)
at com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapter.java:68)
at com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAdapter.java:1158)
at com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.java:111)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:95)
Caused by: java.lang.IllegalAccessError
at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.java:45)
at net.sf.cglib.core.ClassEmitter.<init>(ClassEmitter.java:37)
at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:116)
... 40 more


the hbm file is as follow

<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<!-- Created Wed Dec 28 16:50:30 GMT+05:30 2005 -->
<hibernate-mapping package="com.unisys.ecs.server.hibernate" default-lazy="false">

<class name="Procedures" table="PROCEDURES">
<id name="procedureid" column="PROCEDUREID" type="java.lang.Long">
<generator class="increment"/>
</id>

<property name="procedurecode" column="PROCEDURECODE" type="java.lang.String" not-null="true" />
<property name="procedureversion" column="PROCEDUREVERSION" type="java.lang.String" not-null="true" />
<property name="proceduretitle" column="PROCEDURETITLE" type="java.lang.String" not-null="true" />
<property name="lastupdated" column="LASTUPDATED" type="java.util.Date" not-null="true" />

<many-to-one name="emergencyCategories" column="PROCEDURECATEGORYCODE" class="EmergencyCategories" not-null="true" />

<many-to-one name="emergencyLevels" column="PROCEDURELEVELCODE" class="EmergencyLevels" not-null="true" />

<many-to-one name="processdefinitions" column="PROCEDUREWORKFLOWDEFINITIONID" class="Processdefinitions" />

<many-to-one name="statusDefinitions" column="PROCEDURESTATUS" class="StatusDefinitions" not-null="true" />

<set name="incidentsSet" inverse="true" lazy="true">
<key column="INVOKEDPROCEDUREID"/>
<one-to-many class="Incidents"/>
</set>

<set name="incidents1Set" inverse="true" lazy="true">
<key column="PROCEDURETOBEINVOKED"/>
<one-to-many class="Incidents"/>
</set>

<set name="procedureAuthoritiesSet" inverse="true" lazy="true">
<key column="PROCEDUREID"/>
<one-to-many class="ProcedureAuthorities"/>
</set>

<set name="procedureSectionsSet" inverse="true" lazy="true">
<key column="PROCEDUREID"/>
<one-to-many class="ProcedureSections"/>
</set>
</class>

</hibernate-mapping>

the abstract class is here:

/*
* WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized
* by MyEclipse Hibernate tool integration.
*
* Created Wed Dec 28 16:50:30 GMT+05:30 2005 by MyEclipse Hibernate Tool.
*/
package com.unisys.ecs.server.hibernate;

import java.io.Serializable;

/**
* A class that represents a row in the PROCEDURES table.
* You can customize the behavior of this class by editing the class, {@link Procedures()}.
* WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized
* by MyEclipse Hibernate tool integration.
*/
public abstract class AbstractProcedures
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Long procedureid;

/** The value of the emergencyCategories association. */
private EmergencyCategories emergencyCategories;

/** The value of the emergencyLevels association. */
private EmergencyLevels emergencyLevels;

/** The value of the processdefinitions association. */
private Processdefinitions processdefinitions;

/** The value of the statusDefinitions association. */
private StatusDefinitions statusDefinitions;

/** The value of the incidentsSet one-to-many association. */
private java.util.Set incidentsSet;

/** The value of the incidents1Set one-to-many association. */
private java.util.Set incidents1Set;

/** The value of the procedureAuthoritiesSet one-to-many association. */
private java.util.Set procedureAuthoritiesSet;

/** The value of the procedureSectionsSet one-to-many association. */
private java.util.Set procedureSectionsSet;

/** The value of the simple procedurecode property. */
private java.lang.String procedurecode;

/** The value of the simple procedureversion property. */
private java.lang.String procedureversion;

/** The value of the simple proceduretitle property. */
private java.lang.String proceduretitle;

/** The value of the simple lastupdated property. */
private java.util.Date lastupdated;

/**
* Simple constructor of AbstractProcedures instances.
*/
public AbstractProcedures()
{
}

/**
* Constructor of AbstractProcedures instances given a simple primary key.
* @param procedureid
*/
public AbstractProcedures(java.lang.Long procedureid)
{
this.setProcedureid(procedureid);
}

/**
* Return the simple primary key value that identifies this object.
* @return java.lang.Long
*/
public java.lang.Long getProcedureid()
{
return procedureid;
}

/**
* Set the simple primary key value that identifies this object.
* @param procedureid
*/
public void setProcedureid(java.lang.Long procedureid)
{
this.hashValue = 0;
this.procedureid = procedureid;
}

/**
* Return the value of the PROCEDURECODE column.
* @return java.lang.String
*/
public java.lang.String getProcedurecode()
{
return this.procedurecode;
}

/**
* Set the value of the PROCEDURECODE column.
* @param procedurecode
*/
public void setProcedurecode(java.lang.String procedurecode)
{
this.procedurecode = procedurecode;
}

/**
* Return the value of the PROCEDUREVERSION column.
* @return java.lang.String
*/
public java.lang.String getProcedureversion()
{
return this.procedureversion;
}

/**
* Set the value of the PROCEDUREVERSION column.
* @param procedureversion
*/
public void setProcedureversion(java.lang.String procedureversion)
{
this.procedureversion = procedureversion;
}

/**
* Return the value of the PROCEDURETITLE column.
* @return java.lang.String
*/
public java.lang.String getProceduretitle()
{
return this.proceduretitle;
}

/**
* Set the value of the PROCEDURETITLE column.
* @param proceduretitle
*/
public void setProceduretitle(java.lang.String proceduretitle)
{
this.proceduretitle = proceduretitle;
}

/**
* Return the value of the PROCEDURECATEGORYCODE column.
* @return EmergencyCategories
*/
public EmergencyCategories getEmergencyCategories()
{
return this.emergencyCategories;
}

/**
* Set the value of the PROCEDURECATEGORYCODE column.
* @param emergencyCategories
*/
public void setEmergencyCategories(EmergencyCategories emergencyCategories)
{
this.emergencyCategories = emergencyCategories;
}

/**
* Return the value of the PROCEDURELEVELCODE column.
* @return EmergencyLevels
*/
public EmergencyLevels getEmergencyLevels()
{
return this.emergencyLevels;
}

/**
* Set the value of the PROCEDURELEVELCODE column.
* @param emergencyLevels
*/
public void setEmergencyLevels(EmergencyLevels emergencyLevels)
{
this.emergencyLevels = emergencyLevels;
}

/**
* Return the value of the PROCEDURESTATUS column.
* @return StatusDefinitions
*/
public StatusDefinitions getStatusDefinitions()
{
return this.statusDefinitions;
}

/**
* Set the value of the PROCEDURESTATUS column.
* @param statusDefinitions
*/
public void setStatusDefinitions(StatusDefinitions statusDefinitions)
{
this.statusDefinitions = statusDefinitions;
}

/**
* Return the value of the PROCEDUREWORKFLOWDEFINITIONID column.
* @return Processdefinitions
*/
public Processdefinitions getProcessdefinitions()
{
return this.processdefinitions;
}

/**
* Set the value of the PROCEDUREWORKFLOWDEFINITIONID column.
* @param processdefinitions
*/
public void setProcessdefinitions(Processdefinitions processdefinitions)
{
this.processdefinitions = processdefinitions;
}

/**
* Return the value of the LASTUPDATED column.
* @return java.lang.String
*/
public java.util.Date getLastupdated()
{
return this.lastupdated;
}

/**
* Set the value of the LASTUPDATED column.
* @param lastupdated
*/
public void setLastupdated(java.util.Date lastupdated)
{
this.lastupdated = lastupdated;
}

/**
* Return the value of the INVOKEDPROCEDUREID collection.
* @return Incidents
*/
public java.util.Set getIncidentsSet()
{
return this.incidentsSet;
}

/**
* Set the value of the INVOKEDPROCEDUREID collection.
* @param incidentsSet
*/
public void setIncidentsSet(java.util.Set incidentsSet)
{
this.incidentsSet = incidentsSet;
}

/**
* Return the value of the PROCEDURETOBEINVOKED collection.
* @return Incidents
*/
public java.util.Set getIncidents1Set()
{
return this.incidents1Set;
}

/**
* Set the value of the PROCEDURETOBEINVOKED collection.
* @param incidents1Set
*/
public void setIncidents1Set(java.util.Set incidents1Set)
{
this.incidents1Set = incidents1Set;
}

/**
* Return the value of the PROCEDUREID collection.
* @return ProcedureAuthorities
*/
public java.util.Set getProcedureAuthoritiesSet()
{
return this.procedureAuthoritiesSet;
}

/**
* Set the value of the PROCEDUREID collection.
* @param procedureAuthoritiesSet
*/
public void setProcedureAuthoritiesSet(java.util.Set procedureAuthoritiesSet)
{
this.procedureAuthoritiesSet = procedureAuthoritiesSet;
}

/**
* Return the value of the PROCEDUREID collection.
* @return ProcedureSections
*/
public java.util.Set getProcedureSectionsSet()
{
return this.procedureSectionsSet;
}

/**
* Set the value of the PROCEDUREID collection.
* @param procedureSectionsSet
*/
public void setProcedureSectionsSet(java.util.Set procedureSectionsSet)
{
this.procedureSectionsSet = procedureSectionsSet;
}

/**
* Implementation of the equals comparison on the basis of equality of the primary key values.
* @param rhs
* @return boolean
*/
public boolean equals(Object rhs)
{
if (rhs == null)
return false;
if (! (rhs instanceof Procedures))
return false;
Procedures that = (Procedures) rhs;
if (this.getProcedureid() == null || that.getProcedureid() == null)
return false;
return (this.getProcedureid().equals(that.getProcedureid()));
}

/**
* Implementation of the hashCode method conforming to the Bloch pattern with
* the exception of array properties (these are very unlikely primary key types).
* @return int
*/
public int hashCode()
{
if (this.hashValue == 0)
{
int result = 17;
int procedureidValue = this.getProcedureid() == null ? 0 : this.getProcedureid().hashCode();
result = result * 37 + procedureidValue;
this.hashValue = result;
}
return this.hashValue;
}
}



the procedure class is here:

/*
* Created Wed Dec 28 16:49:57 GMT+05:30 2005 by MyEclipse Hibernate Tool.
*/
package com.unisys.ecs.server.hibernate;

import java.io.Serializable;

/**
* A class that represents a row in the 'PROCEDURES' table.
* This class may be customized as it is never re-generated
* after being created.
*/
public class Procedures
extends AbstractProcedures
implements Serializable
{
/**
* Simple constructor of Procedures instances.
*/
public Procedures()
{
super();
}

public Procedures(Long procId)
{
super(procId);
}

/* Add customized code below */

}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 3:57 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
There is "wrong" asm.jar in classpath. Upgrade all libraries after migration.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 5:21 am 
Newbie

Joined: Tue Mar 07, 2006 3:12 am
Posts: 3
Thanx it works....
I would like to know in which real scenario we should use lazy loading and where not.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 6:34 am 
Newbie

Joined: Mon Mar 06, 2006 5:20 am
Posts: 7
san.pinku wrote:
I would like to know in which real scenario we should use lazy loading and where not.

Let's say you print a list of furnishers and that you have a huge amount of contacts for each of this furnishers, but that in the current page, you do not want to print them. If you do not use lazy when getting the list of furnishers, hibernate will load all the furnishers and contacts even if you do not need the latter.

Now, the question could be: "then why do not always use lazy loading", and the simple answer is : cause if you need them all, you will do a lot of selects instead of a unique one.

_________________
Don't forget to rate useful posts


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.