-->
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: Hibernate 3.3.1 throwing ClassCstException for java.util.Map
PostPosted: Mon Apr 04, 2011 4:18 pm 
Newbie

Joined: Mon Apr 04, 2011 4:03 pm
Posts: 4
hi,

I have just migrated my Hibernate code from 3.1.3 to 3.3.1 (one that comes default with Jboss 5.1.0 GA).

I have a simple class, Mapping and execution code, this code works fine with earlier version but in latter, it throws exception.

I have changed dialect from Oracle9Dialect to Oracle9iDialect (still getting same exception).

In this particular application.functionality I am connecting to 2 different db, for this I have made changes in jbossts-properties.xml file. So not getting any session/transaction related exception, anymore.


I am struggling with this error for last 2-3 days, I have tried changing datatype of class attribute from primitive to Object, but not luck thr.


Bean Class (class has getter/setter as well. I have changes data type from int to Integer, but in both cases same exception).
_________

public class IDWSetupAuditLog
implements Serializable
{
private Integer auditId = 0;
private Integer tableId = 0;
private String changeReqId;
private String changeReqName;
private Integer changeImplId = 0;
private String changeImplName;
private String changeDetail;
private String changeType;
private String changeReasonDesc;
private Date lastUpdateDt;
}

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

<hibernate-mapping>

<class name="com.geam.dese.hibernate.dto.IDWSetupAuditLog" table="DESE.IDW_SETUP_AUDIT_LOG" >
<id name="auditId" type="integer" column="AUDIT_ID">
<generator class="sequence"><param name="sequence">DESE.IDW_SETUP_AUDIT_LOG_SEQ</param></generator>
</id>
<property name="tableId" column="TABLE_ID" type="integer"/>
<property name="changeReqId" column="CHANGE_REQUESTER_ID" type="string"/>
<property name="changeReqName" column="CHANGE_REQUESTER_NM" type="string"/>
<property name="changeImplId" column="CHANGE_IMPLEMENTER_ID" type="integer"/>
<property name="changeImplName" column="CHANGE_IMPLEMENTER_NM" type="string"/>
<property name="changeDetail" column="CHANGE_DETAIL_TXT" type="string"/>
<property name="changeType" column="CHANGE_TYPE" type="string"/>
<property name="changeReasonDesc" column="CHANGE_REASON_DESC" type="string"/>
<property name="lastUpdateDt" column="LAST_UPDATE_DTM" type="timestamp"/>
</class>
</hibernate-mapping>


Exception is coming in following code
--------------------------------------

public void insertAuditData(IDWSetupAuditLog auditLog, Session session)
throws Exception
{
this.log.debug("Begin of EventDAO : insertAuditData()");
try
{
session.save(auditLog);/////------------->This line throws following exception
session.flush();
session.clear();

Following few 9 lines r coming because I have added SOP in setter method
2011-04-04 15:48:58,284 INFO [STDOUT] (http-0.0.0.0-8280-2) setTableId->1
2011-04-04 15:48:58,284 INFO [STDOUT] (http-0.0.0.0-8280-2) setChangeDetail
2011-04-04 15:48:58,284 INFO [STDOUT] (http-0.0.0.0-8280-2) setChangeImplId=>200011691
2011-04-04 15:48:58,284 INFO [STDOUT] (http-0.0.0.0-8280-2) setChangeImplName
2011-04-04 15:48:58,284 INFO [STDOUT] (http-0.0.0.0-8280-2) setChangeReqId
2011-04-04 15:48:58,284 INFO [STDOUT] (http-0.0.0.0-8280-2) setChangeReqName
2011-04-04 15:48:58,284 INFO [STDOUT] (http-0.0.0.0-8280-2) setChangeReasonDesc
2011-04-04 15:48:58,285 INFO [STDOUT] (http-0.0.0.0-8280-2) setChangeType
2011-04-04 15:48:58,285 INFO [STDOUT] (http-0.0.0.0-8280-2) setLastUpdateDt
2011-04-04 15:48:58,285 DEBUG [com.geam.dese.hibernate.utils.HibernateSessionFactory] (http-0.0.0.0-8280-2) Begin of HibernateSessionFactory : getCurrentSession()
2011-04-04 15:48:58,285 DEBUG [com.geam.dese.hibernate.dao.EventDAO] (http-0.0.0.0-8280-2) Begin of EventDAO : insertAuditData()
2011-04-04 15:48:58,289 WARN [com.arjuna.ats.jta.logging.loggerI18N] (http-0.0.0.0-8280-2) [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.multipleWarning] Multiple last resources have been added to the current transaction. This is transactionally unsafe and should not be relied upon. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@6dce3f7e
Following line is coming, it means value is getting generated for sequence (current value of this sequence in db is 11500 (so well in the rage of int variable
2011-04-04 15:48:58,289 INFO [STDOUT] (http-0.0.0.0-8280-2) Hibernate: select DESE.IDW_SETUP_AUDIT_LOG_SEQ.nextval from dual
2011-04-04 15:48:58,295 DEBUG [com.geam.dese.hibernate.dao.EventDAO] (http-0.0.0.0-8280-2) Exception in EventDAO::insertAuditData ==> java.lang.ClassCastException: com.geam.dese.hibernate.dto.IDWSetupAuditLog cannot be cast to java.util.Map
2011-04-04 15:48:58,295 DEBUG [com.geam.dese.hibernate.businessobject.EventBO] (http-0.0.0.0-8280-2) Exception in EventBO::insertData ==> java.lang.ClassCastException: com.geam.dese.hibernate.dto.IDWSetupAuditLog cannot be cast to java.util.Map
2011-04-04 15:48:58,296 DEBUG [com.geam.dese.hibernate.ejb.SessionFacadeBean] (http-0.0.0.0-8280-2) Exception in SessionFacadeBean::insertData ==> java.lang.ClassCastException: com.geam.dese.hibernate.dto.IDWSetupAuditLog cannot be cast to java.util.Map
2011-04-04 15:48:58,297 ERROR [org.jboss.ejb.plugins.LogInterceptor] (http-0.0.0.0-8280-2) TransactionRolledbackLocalException in method: public abstract boolean com.geam.dese.hibernate.ejb.Business.insertData(java.util.List,java.lang.String,int,java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws java.lang.Exception, causedBy:
java.lang.ClassCastException: com.geam.dese.hibernate.dto.IDWSetupAuditLog cannot be cast to java.util.Map
at org.hibernate.property.MapAccessor$MapSetter.set(MapAccessor.java:68)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:234)
at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:3624)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
at com.geam.dese.hibernate.dao.EventDAO.insertAuditData(EventDAO.java:193)
at com.geam.dese.hibernate.businessobject.EventBO.insertData(EventBO.java:124)
at com.geam.dese.hibernate.ejb.SessionFacadeBean.insertData(SessionFacadeBean.java:174)
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:597)
at org.jboss.invocation.Invocation.performCall(Invocation.java:386)


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.1 throwing ClassCstException for java.util.Map
PostPosted: Tue Apr 05, 2011 8:28 am 
Newbie

Joined: Mon Apr 04, 2011 4:03 pm
Posts: 4
Resolved it,

No need to change any setting any where, but just the one.

session = session.getSession(EntityMode.POJO);

by default its DynaMap.


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.1 throwing ClassCstException for java.util.Map
PostPosted: Thu Apr 07, 2011 2:15 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
by default its DynaMap.

Hu? The default is definitely POJO, I guess you're having some configuration file laying around which you didn't spot.

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


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.1 throwing ClassCstException for java.util.Map
PostPosted: Thu Apr 07, 2011 2:50 pm 
Newbie

Joined: Mon Apr 04, 2011 4:03 pm
Posts: 4
hi,

Surely not from my java file.

may be from conf file if you are said so. But, can you tell me which conf file can lead to this type of behavior?


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.1 throwing ClassCstException for java.util.Map
PostPosted: Thu Apr 07, 2011 6:19 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
there must be some hibernate.properties file around having an option like "hibernate.default_entity_mode" (see http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#configuration-optional-properties).
Configuration file can be in other formats, like XML. I'd use a filesystem search tool for "dynamic-map" or "dom4j" to find where it's hiding in your classpath. maybe you have another jar on the classpath which contains it, so make sure to search inside jars as well.

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


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.1 throwing ClassCstException for java.util.Map
PostPosted: Thu Apr 07, 2011 10:16 pm 
Newbie

Joined: Mon Apr 04, 2011 4:03 pm
Posts: 4
you are super awesome

it was
<property name="hibernate.default_entity_mode">dynamic-map</property>

i changed it to
<property name="hibernate.default_entity_mode">pojo</property>


Top
 Profile  
 
 Post subject: Re: Hibernate 3.3.1 throwing ClassCstException for java.util.Map
PostPosted: Fri Apr 08, 2011 5:33 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I'm glad it helped. Just make sure you don't use configuration parameters which you don't know what their effect will be. reading the manual might help as well ;)

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


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.