-->
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.  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: ExceptionInInitializerError
PostPosted: Fri Apr 25, 2008 2:33 pm 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Hi,

Could anybody help me to understand in which situation the following error is thrown?

java.lang.ExceptionInInitializerError
at net.sf.cglib.core.DuplicatesPredicate.evaluate(DuplicatesPredicate.java:25)
at net.sf.cglib.core.CollectionUtils.filter(CollectionUtils.java:52)
at net.sf.cglib.reflect.FastClassEmitter.<init>(FastClassEmitter.java:68)
at net.sf.cglib.reflect.FastClass$Generator.generateClass(FastClass.java:72)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:64)
at net.sf.cglib.proxy.MethodProxy.helper(MethodProxy.java:81)
at net.sf.cglib.proxy.MethodProxy.create(MethodProxy.java:46)
at br.fapesp.tidia.ae.common.portfolio.commontypes.vo.RootVO$$EnhancerByCGLIB$$555248d1.CGLIB$STATICHOOK77(<generated>)
at br.fapesp.tidia.ae.common.portfolio.commontypes.vo.RootVO$$EnhancerByCGLIB$$555248d1.<clinit>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.hibernate.proxy.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:99)
at org.hibernate.proxy.CGLIBProxyFactory.getProxy(CGLIBProxyFactory.java:47)
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at br.fapesp.tidia.ae.infra.portfolio.db.impl.HibernatePortfolioDAO.selectByContext(HibernatePortfolioDAO.java:92)

Basically it is happening when I call "query.list()", in a method of one of the HibernateDAO classes of my project. I'm also using JTA UserTransaction API directly to control my transaction.

Thanks in advance for any help!

Cristina


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 27, 2008 3:45 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
Check if your session is open when you do query.list().

_________________
Sukirtha


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 27, 2008 2:13 pm 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Hi,

Yes, my session is opened and connected.

I've called session.isOpened() and session.isConnected() to verify, and both return true.

In fact, when query.list() is called by the first time, the java.lang.ExceptionInInitializerError problem does not happen.
In this case, the session is opened, connected and dirty.

The java.lang.ExceptionInInitializerError problem happens when query is called by the 2nd time, and in a situation where the session is opened, connected but is not dirty...

Any other hint?

Thanks in advance for your help!

Cristina


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 28, 2008 2:53 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
Can you please post the code between session.open() and session.close(). I got this issue before and it was due to session. Have to see your code to be sure.

_________________
Sukirtha


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 28, 2008 9:04 am 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Hi Sukirtha,

I'm using JTA UserTransaction API directly to control my transaction, so I'm not calling directly session.open() and session.close(). I'm assuming that the session is being opened when I start the transaction, and that the session is being closed when I commit the transaction.

The code that starts the transaction and depending on the result, commit/rollback is:

try {
trans = (UserTransaction)
new InitialContext().lookup("java:comp/UserTransaction");
trans.begin();

IPortfolioDAO dao = (IPortfolioDAO)
ComponentLocator.getInstance().
getInstanceOfType(IPortfolioDAO.class);

// !!! --------------------------------------------------------------
// !!! THE PROBLEM HAPPENS WHEN THE FOLLOWING
// !!! METHOD IS CALLED
// !!! --------------------------------------------------------------
List portfolio = dao.selectByContext(contextKey);

trans.commit();
transactionSuccess = true;

} catch (Exception e) {
throw new SystemException(e.getMessage(),
e.getCause(),
"errors.user.portfolio.access");
} finally {
if (transactionSuccess == false) {
try {
trans.rollback();
} catch (Exception e) {
e.printStackTrace();
}
}
}

------------------------------------------------------------------
Here is the code of selectedByContext method...

public List selectByContext(String contextKey) throws InfraException {

final String portfolio = this.getVOClass().getName();
final String className = this.getClass().getName();

List list = new ArrayList();

Session session = hibernateUtil.currentSession();

try {
String hql = "select p from " + portfolio + " as p"
+ " where p.ctxPart.contextID = :id";

Query query = session.createQuery(hql);
query.setString("id", contextKey);

// !!! ----------------------------------------------------------------
// THE java.lang.ExceptionInInitializerError HAPPENS HERE!!!
// !!! ----------------------------------------------------------------
list = query.list();


this.initializeCollection(list);

} catch (Exception e) {
throw new InfraException(e.getMessage(),e.getCause());
} catch (Throwable e) {
throw new InfraException(e.getMessage(), e.getCause());
}
return list;
}


The code of hibernateUtil.currentSession() is:
public Session currentSession() {
return factory.getCurrentSession();
}

where factory is being initialized with the following code:

factory = new Configuration().
configure(hibernateConfig).buildSessionFactory();

hibernateConfig is a file with the following contents:
-------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<!-- Arquivo gerado automaticamente - não edite!! -->

<hibernate-configuration>

<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>

<!-- properties -->
<property
name="connection.datasource">java:/comp/env/jdbc/tidiaportfolioDS</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">false</property>
<property name="use_outer_join">false</property>

<property name="current_session_context_class">jta</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</property>
<property name="hibernate.connection.provider_class">org.hibernate.connection.DatasourceConnectionProvider</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<property name="hibernate.transaction.auto_close_session">false</property>
<property name="hibernate.connection.release_mode">on_close</property>

<!-- mapping files -->
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/SharingTypeVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/FolderVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/FolderAssessmentVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/AssessmentItemVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/ItemStatusVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/ActionVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/FolderStatusVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/ObjectWithAttachedFilesVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/ContextParticipantPortfolioVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/ActionTypeVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/ObjectFileVO.hbm.xml"/>
<mapping resource="br/fapesp/tidia/ae/common/portfolio/commontypes/vo/PortfolioVO.hbm.xml"/>
</session-factory>

</hibernate-configuration>
-------------------------------------------------------------------------------------

Please let me know if you need any further information, ok?

Thanks in advance for your help!

Cristina


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 4:26 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
Cristina

Where does the error occur?
Code:
list = query.list();

(or)
Code:
this.initializeCollection(list);


To make sure, comment the second line and try executing your code. I feel lazy initialization is not happening under certain scenarios. I am not sure though!

_________________
Sukirtha


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 6:06 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Ciao Cristina,

java.lang.ExceptionInInitializerError usually means there is some exception thrown in some static initialization block, do you have static code in you entities?

Could we see the source of the entities you are trying to get a list of?
is it "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.RootVO" ?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 9:21 am 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Hi Sukirtha,

The error occurs when the line "list = query.list();" is executed. Even if I comment the line "this.initializeCollection(list);", the error stills there.

What looks more strange to me is that I'm not using lazy classes in my project, and in the error stack trace I see "org.hibernate.proxy.CGLIBLazyInitializer.getProxy(CGLIBLazyInitializer.java:99)"... Isn't strange a lazy initializer method being called, even when there is no lazy class or attribute in my project???

Thanks a lot for your help!

Cristina


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 9:44 am 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Ciao Sanne,

I don't have static code in my entities :(

The entity I'm trying to load is PortfolioVO. This class has an attribute of type RootVO.

I'm sending the code of these classes... Maybe you can see a problem...

Thanks in advance for your help,

Cristina

------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
/*
* This file is part of Tidia-Ae Project.
*
* Tidia-Ae Project is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Tidia-Ae Project is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tidia-Ae Project; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

package br.fapesp.tidia.ae.common.portfolio.commontypes.vo;

import br.fapesp.tidia.ae.common.commontypes.vo.ObjectVO;


/**
* @hibernate.class table="PORTFOLIO"
*
*/
public class PortfolioVO extends ObjectVO {

private boolean disabled;

private RootVO rootFolder;

private TrashVO trashFolder;

private AssessedFolderVO assessmentFolder;

private ContextParticipantPortfolioVO ctxPart;

public PortfolioVO() {
super();
}

/**
* @param identifier
* @param rootFolder
* @param trashFolder
* @param ctxPart
*/
public PortfolioVO(Long identifier, RootVO rootFolder, TrashVO trashFolder, AssessedFolderVO aFolder,
ContextParticipantPortfolioVO ctxPart) {
super(identifier);
this.rootFolder = rootFolder;
this.trashFolder = trashFolder;
this.assessmentFolder = aFolder;
this.setDisabled(false);
this.setCtxPart(ctxPart);
}




/**
* @return Returns the deleted status.
*
* @hibernate.property column = "DISABLED" not-null = "true"
*/
public boolean getDisabled() {
return disabled;
}

/**
* @param status
* The status to set.
*/
public void setDisabled(boolean status) {
this.disabled = status;
}

/**
* @return Returns the rootFolder.
*
* @hibernate.many-to-one class =
* "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.RootVO"
* column = "ROOT_ID" cascade="all"
*/
public RootVO getRootFolder() {
return rootFolder;
}

/**
* @param rootFolder
* The rootFolder to set.
*/
public void setRootFolder(RootVO rootFolder) {
this.rootFolder = rootFolder;
}

/**
* @return Returns the trashFolder.
*
* @hibernate.many-to-one class =
* "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.TrashVO"
* column = "TRASH_ID" cascade="all"
*/
public TrashVO getTrashFolder() {
return trashFolder;
}

/**
* @param trashFolder
* The trashFolder to set.
*/
public void setTrashFolder(TrashVO trashFolder) {
this.trashFolder = trashFolder;
}






/**
* @return Returns the assessmentFolder.
* @hibernate.many-to-one class =
* "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.AssessedFolderVO"
* column = "ASSESSMENT_ID" cascade="all"
*
*/
public AssessedFolderVO getAssessmentFolder() {
return assessmentFolder;
}
/**
* @param assessmentFolder The assessmentFolder to set.
*/
public void setAssessmentFolder(AssessedFolderVO assessmentFolder) {
this.assessmentFolder = assessmentFolder;
}


/**
* @hibernate.one-to-one class =
* "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.ContextParticipantPortfolioVO"
* property-ref = "portfolio" cascade="all"
*/
public ContextParticipantPortfolioVO getCtxPart() {
return ctxPart;
}

public void setCtxPart(ContextParticipantPortfolioVO ctxPart) {
this.ctxPart = ctxPart;
ctxPart.setPortfolio(this);
}

public int hashCode() {
int hashCode = super.hashCode();
hashCode += Boolean.valueOf(this.getDisabled()).hashCode();
return hashCode;
}

public boolean equals(Object other) {

boolean isEquals = true;

if (this == other) {
isEquals = true;
} else if (other instanceof PortfolioVO) {

PortfolioVO portfolio = (PortfolioVO) other;

if (!portfolio.getId().equals(this.getId())) {
isEquals = false;
} else if (portfolio.disabled != this.disabled) {
isEquals = false;
}
} else {
isEquals = false;
}

return isEquals;
}

public String toString() {
StringBuffer buffer = new StringBuffer();
final String separator = ", ";
buffer.append("{");
buffer.append("id = " + this.getId() + separator);
buffer.append("disabled = " + this.getDisabled() + separator);
buffer.append("rootFolder = " + this.getRootFolder() + separator);
buffer.append("trashFolder = " + this.getTrashFolder());
buffer.append("}");
return buffer.toString();
}

}

------------------------------------------------------------------------------------
------------------------------------------------------------------------------------

/*
* This file is part of Tidia-Ae Project.
*
* Tidia-Ae Project is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Tidia-Ae Project is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tidia-Ae Project; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

package br.fapesp.tidia.ae.common.portfolio.commontypes.vo;

import java.util.Collection;
import java.util.Date;

/**
* @hibernate.subclass discriminator-value = "2"
*/
public class RootVO extends FolderVO {

private Collection children;

private PortfolioVO portfolio;

public RootVO() {
super();
}

/**
* @param name
* @param privateItensQty
* @param publicItensQty
* @param notCommPrivateItensQty
* @param notCommPublicItensQty
* @param lastUpdate
*/
public RootVO(String name, int privateItensQty, int publicItensQty,
int notCommPrivateItensQty, int notCommPublicItensQty,
Date lastUpdate) {
super(name, privateItensQty, publicItensQty, notCommPrivateItensQty,
notCommPublicItensQty, lastUpdate, null);
}

/**
* @param identifier
* @param name
* @param itensQty
* @param notCommPrivateItensQty
* @param notCommPublicItensQty
* @param notEvalQty
* @param lastUpdate
*/
public RootVO(Long identifier, String name, int privateItensQty,
int publicItensQty, int notCommPrivateItensQty,
int notCommPublicItensQty, Date lastUpdate) {
super(identifier, name, privateItensQty, publicItensQty,
notCommPrivateItensQty, notCommPublicItensQty, lastUpdate, null);
}

/**
* @return Returns the children.
*
* @hibernate.collection-one-to-many class =
* "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.FolderVO"
* @hibernate.collection-key column = "PARENT_ID"
*
*/
public Collection getChildren() {
return children;
}

/**
* @param children
* The children to set.
*/
public void setChildren(Collection children) {
this.children = children;
}

/**
* @return Returns the portfolio.
* @hibernate.one-to-one class =
* "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.PortfolioVO"
* property-ref = "rootFolder"
*/
public PortfolioVO getPortfolio() {
return portfolio;
}

/**
* @param portfolio
* The portfolio to set.
*/
public void setPortfolio(PortfolioVO portfolio) {
this.portfolio = portfolio;
}
}

------------------------------------------------------------------------------------
------------------------------------------------------------------------------------

/*
* This file is part of Tidia-Ae Project.
*
* Tidia-Ae Project is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Tidia-Ae Project is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tidia-Ae Project; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

package br.fapesp.tidia.ae.common.portfolio.commontypes.vo;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import br.fapesp.tidia.ae.common.commontypes.vo.ObjectVO;

/**
* @hibernate.class table="FOLDER" discriminator-value = "1"
* @hibernate.discriminator type = "byte" column = "TYPE"
*
*/
public class FolderVO extends ObjectVO {

private String name;

private int publicItensQty;

private int privateItensQty;

private int notCommPublicItensQty;

private int notCommPrivateItensQty;

private Date lastUpdate;

private FolderVO parent;

private Collection userStatus;

private boolean deleted;

private int order;

public FolderVO() {
super();
}

/**
* @param name
* @param publicItensQty
* @param privateItensQty
* @param notCommPrivateItensQty
* @param notCommPublicItensQty
* @param lastUpdate
*/
public FolderVO(String name, int privateItensQty, int publicItensQty, int notCommPrivateItensQty, int notCommPublicItensQty,
Date lastUpdate, FolderVO parent) {
super();
this.name = name;
this.publicItensQty = publicItensQty;
this.privateItensQty = privateItensQty;
this.notCommPrivateItensQty = notCommPrivateItensQty;
this.notCommPublicItensQty = notCommPublicItensQty;
this.lastUpdate = lastUpdate;
this.parent = parent;
}

/**
* @param identifier
* @param name
* @param publicItensQty
* @param privateItensQty
* @param notCommPrivateItensQty
* @param notCommPublicItensQty
* @param lastUpdate
* @param parent
*/
public FolderVO(Long identifier, String name, int privateItensQty, int publicItensQty, int notCommPrivateItensQty,
int notCommPublicItensQty, Date lastUpdate, FolderVO parent) {
super(identifier);
this.name = name;
this.publicItensQty = publicItensQty;
this.privateItensQty = privateItensQty;
this.notCommPrivateItensQty = notCommPrivateItensQty;
this.notCommPublicItensQty = notCommPublicItensQty;
this.lastUpdate = lastUpdate;
this.parent = parent;
}

/**
* @param folder
*/
public FolderVO(FolderVO folder) {
this.name = folder.getName();
this.publicItensQty = folder.getPublicItensQty();
this.privateItensQty = folder.getPrivateItensQty();
this.notCommPublicItensQty = folder.getNotCommPublicItensQty();
this.notCommPrivateItensQty = folder.getNotCommPrivateItensQty();
// this.notEvalQty = folder.getNotEvalQty();
this.lastUpdate = folder.getLastUpdate();
this.parent = folder.getParent();
this.deleted = folder.getDeleted();
}

/**
* @return Returns the name.
*
* @hibernate.property column="NAME" length="100" not-null="true"
*
*/
public String getName() {
return name;
}

/**
* @param name
* The name to set.
*/
public void setName(String name) {
this.name = name;
}

public void addPublicItensQty(int value) {
this.publicItensQty += value;
}

public void addPrivateItensQty(int value) {
this.privateItensQty += value;
}

public void addNotCommPrivateItensQty(int value) {
this.notCommPrivateItensQty += value;
}

public void addNotCommPublicItensQty(int value) {
this.notCommPublicItensQty += value;
}



/**
* @return Returns the notCommPrivateItensQty.
*
* @hibernate.property column = "NOT_COMM_PRIVATE_QTY" not-null = "true"
*/
public int getNotCommPrivateItensQty() {
return notCommPrivateItensQty;
}

/**
* @return Returns the notCommPublicItensQty.
*
* @hibernate.property column = "NOT_COMM_PUBLIC_QTY" not-null = "true"
*/
public int getNotCommPublicItensQty() {
return notCommPublicItensQty;
}

/**
* @param notCommPrivateItensQty
* The notCommPrivateItensQty to set.
*/
public void setNotCommPrivateItensQty(int notCommPrivateItensQty) {
this.notCommPrivateItensQty = notCommPrivateItensQty;
}

/**
* @param notCommPublicItensQty
* The notCommPublicItensQty to set.
*/
public void setNotCommPublicItensQty(int notCommPublicItensQty) {
this.notCommPublicItensQty = notCommPublicItensQty;
}



/**
* @return Returns the lastUpdate.
*
* @hibernate.property column = "LAST_UPDATE" not-null = "true"
*/
public Date getLastUpdate() {
return lastUpdate;
}

/**
* @param lastUpdate
* The lastUpdate to set.
*/
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}

/**
* @return Returns the userStatus.
*
* @hibernate.set order-by = "USER_ID"
* @hibernate.collection-one-to-many class =
* "br.fapesp.tidia.ae.common.portfolio.commontypes.vo.FolderStatusVO"
* @hibernate.collection-key column = "FOLDER_ID"
*/
public Collection getUserStatus() {
return userStatus;
}

/**
* @param userStatus
* The userStatus to set.
*/
public void setUserStatus(Collection userStatus) {
this.userStatus = userStatus;
}

public Map getUserStatusMap() {

Map map = new HashMap();
Iterator iterator = this.getUserStatus().iterator();
FolderStatusVO folderStatus;
String userID;
Boolean status;
while (iterator.hasNext()) {
folderStatus = (FolderStatusVO) iterator.next();
userID = folderStatus.getUserID();
status = Boolean.valueOf(folderStatus.getReadStatus());
map.put(userID, status);
}

return map;
}

/**
* @return Returns the parent.
*
* @hibernate.many-to-one column="PARENT_ID"
*/
public FolderVO getParent() {
return parent;
}

/**
* @param parent
* The parent to set.
*/
public void setParent(FolderVO parent) {
this.parent = parent;
}

public String toString() {
StringBuffer buffer = new StringBuffer();
final String separator = ", ";
buffer.append("{");
buffer.append("id = " + this.getId() + separator);
buffer.append("name = " + this.getName() + separator);
buffer.append("lastUpdate = " + this.getLastUpdate() + separator);
buffer.append("publicItensQty = " + this.getPublicItensQty() + separator);
buffer.append("privateItensQty = " + this.getPrivateItensQty() + separator);
buffer.append("notCommPrivateItensQty = " + this.getNotCommPrivateItensQty() + separator);
buffer.append("notCommPublicItensQty = " + this.getNotCommPublicItensQty() + separator);
// buffer.append("notEvalQty = " + this.getNotEvalQty());
buffer.append("}");
return buffer.toString();
}

public int hashCode() {
int hashCode = super.hashCode();
if (this.name != null) {
hashCode += this.name.hashCode();
}
if (this.lastUpdate != null) {
hashCode += this.lastUpdate.hashCode();
}
return hashCode;
}

public boolean equals(Object obj) {
boolean isEquals = true;

if (obj == this) {
isEquals = true;
} else if (obj instanceof FolderVO) {
FolderVO folder = (FolderVO) obj;

if (!folder.getId().equals(this.getId())) {
isEquals = false;
} else if (! folder.getName().equals(this.name)) {
isEquals = false;
} else if (folder.publicItensQty != this.publicItensQty) {
isEquals = false;
} else if (folder.privateItensQty != this.privateItensQty) {
isEquals = false;
} else if (folder.notCommPrivateItensQty != this.notCommPrivateItensQty) {
isEquals = false;
} else if (folder.notCommPublicItensQty != this.notCommPublicItensQty) {
isEquals = false;
// } else if (folder.notEvalQty != this.notEvalQty) {
// isEquals = false;
} else {
long fTime = folder.getLastUpdate().getTime() / 1000;
long tTime = this.getLastUpdate().getTime() / 1000;
if (fTime != tTime) {
isEquals = false;
}
}
} else {
isEquals = false;
}
return isEquals;
}


/**
* @return Returns the status.
*
* @hibernate.property column = "DELETED" not-null = "true"
*/
public boolean getDeleted() {
return deleted;
}

/**
* @param deleted The deleted to set.
*/
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}

/**
* @return Returns the privateItensQty.
*
* @hibernate.property column = "PRIVATE_QTY_ITENS" not-null = "true"
*/
public int getPrivateItensQty() {
return privateItensQty;
}

/**
* @param privateItensQty The privateItensQty to set.
*/
public void setPrivateItensQty(int privateItensQty) {
this.privateItensQty = privateItensQty;
}


/**
* @return Returns the publicItensQty.
*
* @hibernate.property column = "PUBLIC_QTY_ITENS" not-null = "true"
*/
public int getPublicItensQty() {
return publicItensQty;
}

/**
* @param publicItensQty The publicItensQty to set.
*/
public void setPublicItensQty(int publicItensQty) {
this.publicItensQty = publicItensQty;
}


/**
* @return Returns the order.
* @hibernate.property column = "FOLDER_ORDER" not-null = "true"
*/
public int getOrder() {
return order;
}
/**
* @param order The order to set.
*/
public void setOrder(int order) {
this.order = order;
}
}

------------------------------------------------------------------------------------
------------------------------------------------------------------------------------

/*
* This file is part of Tidia-Ae Project.
*
* Tidia-Ae Project is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Tidia-Ae Project is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tidia-Ae Project; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

package br.fapesp.tidia.ae.common.commontypes.vo;

import java.io.Serializable;

public abstract class ObjectVO implements Serializable {

protected Long id;

/**
* @param identifier
*/
public ObjectVO(Long identifier) {
this();
this.id = identifier;
}

/**
*
*/
public ObjectVO() {
super();
}

/**
* @return Returns the id.
*
* @hibernate.id column="id" generator-class="native"
*/
public Long getId() {
return id;
}

/**
* @param newId
* The id to set.
*/
public void setId(Long newId) {
this.id = newId;
}

public int hashCode() {
return id.intValue();
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 5:26 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I'm really sorry I don't see any problem related to this issue in your entities,
but I never used this mapping style.
You are probably mixing some library versions, did you verify you are using the same cglib that comes with your hibernate version?

Besides this, I've seen some "unusual" style in your code,
if I may advice you about your toString() methods, if you use StringBuffer (good idea) or StringBuilder (even better) you shouldn't use the "+" sign but issue separated .append() statements.

And please if you have to post so much code use the "code" function, so it gets more readable.

Finally, you should really post your library versions so that hibernate experts can help you out.

regards,

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 10:36 pm 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Hi,

I'm using hibernate-3.2. I've already checked and I'm using the same cglib that comes with hibernate.

Thanks for the advices related to toString method and to "Code" style. I will certainly follow them from now on.

Regards,

Cristina


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 11:41 pm 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
Can we see your mapping files for RootVO and PortfolioVO.

_________________
Sukirtha


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 30, 2008 8:22 am 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Hi Sukirtha,

Here they are. Note that RootVO is a subclass of FolderVO.

Thanks!

Cristina

Code:

<?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">

<hibernate-mapping
>
    <class
        name="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.PortfolioVO"
        table="PORTFOLIO"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-PortfolioVO.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <property
            name="disabled"
            type="boolean"
            update="true"
            insert="true"
            column="DISABLED"
            not-null="true"
        />

        <many-to-one
            name="rootFolder"
            class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.RootVO"
            cascade="all"
            outer-join="auto"
            update="true"
            insert="true"
            column="ROOT_ID"
        />

        <many-to-one
            name="trashFolder"
            class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.TrashVO"
            cascade="all"
            outer-join="auto"
            update="true"
            insert="true"
            column="TRASH_ID"
        />

        <many-to-one
            name="assessmentFolder"
            class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.AssessedFolderVO"
            cascade="all"
            outer-join="auto"
            update="true"
            insert="true"
            column="ASSESSMENT_ID"
        />

        <one-to-one
            name="ctxPart"
            class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.ContextParticipantPortfolioVO"
            cascade="all"
            outer-join="auto"
            constrained="false"
            property-ref="portfolio"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-PortfolioVO.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>



<?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">

<hibernate-mapping
>
    <class
        name="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.FolderVO"
        table="FOLDER"
        discriminator-value="1"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="native">
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-FolderVO.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <discriminator
            column="TYPE"
            type="byte"
        />

        <property
            name="name"
            type="java.lang.String"
            update="true"
            insert="true"
            column="NAME"
            length="100"
            not-null="true"
        />

        <property
            name="notCommPrivateItensQty"
            type="int"
            update="true"
            insert="true"
            column="NOT_COMM_PRIVATE_QTY"
            not-null="true"
        />

        <property
            name="notCommPublicItensQty"
            type="int"
            update="true"
            insert="true"
            column="NOT_COMM_PUBLIC_QTY"
            not-null="true"
        />

        <property
            name="lastUpdate"
            type="java.util.Date"
            update="true"
            insert="true"
            column="LAST_UPDATE"
            not-null="true"
        />

        <set
            name="userStatus"
            lazy="false"
            cascade="none"
            sort="unsorted"
            order-by="USER_ID"
        >

            <key
                column="FOLDER_ID"
            >
            </key>

            <one-to-many
                  class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.FolderStatusVO"
            />

        </set>

        <many-to-one
            name="parent"
            class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.FolderVO"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="PARENT_ID"
        />

        <property
            name="deleted"
            type="boolean"
            update="true"
            insert="true"
            column="DELETED"
            not-null="true"
        />

        <property
            name="privateItensQty"
            type="int"
            update="true"
            insert="true"
            column="PRIVATE_QTY_ITENS"
            not-null="true"
        />

        <property
            name="publicItensQty"
            type="int"
            update="true"
            insert="true"
            column="PUBLIC_QTY_ITENS"
            not-null="true"
        />

        <property
            name="order"
            type="int"
            update="true"
            insert="true"
            column="FOLDER_ORDER"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-FolderVO.xml
            containing the additional properties and place it in your merge dir.
        -->
        <subclass
            name="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.RootVO"
            discriminator-value="2"
        >

        <one-to-one
            name="portfolio"
            class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.PortfolioVO"
            cascade="none"
            outer-join="auto"
            constrained="false"
            property-ref="rootFolder"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-RootVO.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.TrashVO"
            discriminator-value="3"
        >
       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-TrashVO.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>
        <subclass
            name="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.AssessedFolderVO"
            discriminator-value="4"
        >

        <one-to-one
            name="assessment"
            class="br.fapesp.tidia.ae.common.portfolio.commontypes.vo.FolderAssessmentVO"
            cascade="none"
            outer-join="auto"
            constrained="false"
            property-ref="folder"
        />

       <!--
               To add non XDoclet property mappings, create a file named
                hibernate-properties-AssessedFolderVO.xml
      containing the additional properties and place it in your merge dir.
       -->

        </subclass>

    </class>

</hibernate-mapping>






Top
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 1:05 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
Sorry Cristina... Don't see any problem with your mapping files as well.

_________________
Sukirtha


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 11:15 pm 
Newbie

Joined: Fri Apr 25, 2008 1:50 pm
Posts: 10
Hi Sukirtha,

Thanks for your help. In fact, I'm now wondering if the problem isn't related to the fact that PortfolioVO object has a RootVO member variable, which is a "subclass" from hibernate perspective...

I have a similar persistence class in my project (WeblogVO), for which the problem never happens. And the main difference between PortfolioVO and WeblogVO is that WeblogVO does not have member variables which are "subclasses" from hibernate perspective.

Just to give you more information of the context where I found this problem:
my project was originally designed to use JBoss and EJBs. All the persistent classes are exactly the same, and we have never had this problem.
Now we've been requested to not use JBoss and EJBs, and we will run now under tomcat only. So, our transaction control now is based on calls to UserTransaction API directly. In terms of persistent data, there has been no change in my classes. The only change has been in my HibernateDAO classes: before they were calling session.open, session.close, commit or rollback. Now they only get the current transaction, which is opened by the system component of my project...

I have been reading the Hibernate documentation, looking for help about how to handle with inherintance objects in persistence classes. I saw a small section in Chapter 4 of the Hibernate Core documentation. Would you have more references about how to handle or how to avoid inherintance objects is persistence classes? If my suspection is true, I will need to get rid of this "sublcass" RootVO...

Thanks again for your help,

Cristina


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 17 posts ]  Go to page 1, 2  Next

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.