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.  [ 6 posts ] 
Author Message
 Post subject: ClassCastException: at MapGetter.get(MapAccessor.java:67)
PostPosted: Tue Jan 08, 2008 6:31 am 
Newbie

Joined: Tue Jan 08, 2008 6:17 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate ver 3.2.

[b] Bean :-
package myhibernate;

class Mmm implements java.io.Serializable
{
private String msg;
private int id;
public Mmm()
{
id = 0;
}

public void setMsg(String aMessage)
{
msg = aMessage;
}
public String getMsg()
{
return msg;
}
public void setId(int aID)
{
id = aID;
}

public int getId()
{
return id;
}
}

Configuration:-
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:oci8:@syntera</property>
<property name="hibernate.connection.username">syntera</property>
<property name="hibernate.connection.password">syntera</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="hibernate.default_entity_mode">dynamic-map</property>
<property name="jdbc.batch_size">0</property>
<property name="show_sql">true</property>


<!-- Mapping files -->
<mapping resource="Mmm.hbm.xml"/>

</session-factory>
</hibernate-configuration>

Mapping:-

<hibernate-mapping>
<class name="myhibernate.Mmm" table="MESSAGE" schema="SYNTERA">
<composite-id name="id" class="myhibernate.Mmm">
<key-property name="id" type="int">
<column name="MESSAGE_ID" />
</key-property>
<key-property name="msg" type="string">
<column name="MESSAGE" length="100" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>



[b]Code between sessionFactory.openSession() and session.close():
Mmm msg = new Mmm();
msg.setId(new Long(12));
msg.setMsg("Message1");

session.save(msg);
session.flush();
session.close();

[b]Full stack trace of any exception that occurs
java.lang.ClassCastException: myhibernate.Mmm
at org.hibernate.property.MapAccessor$MapGetter.get(MapAccessor.java:67)

at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(Abstr
actEntityTuplizer.java:183)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(
AbstractEntityPersister.java:3591)
at org.hibernate.id.Assigned.generate(Assigned.java:28)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId
(AbstractSaveEventListener.java:99)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGene
ratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrR
equestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTran
sient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(
DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpda
te(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at myhibernate.CreateMessage.main(CreateMessage.java:24)
myhibernate.Mmm

[b]Name and version of the database you are using:- Oracle 10g

[b]The generated SQL (show_sql=true):


i am new to hibernate please tell me the problem


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject: Re: ClassCastException: at MapGetter.get(MapAccessor.java:67
PostPosted: Wed Jan 09, 2008 10:44 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Remove the class attribute from composite-id tag and see if it works.



Farzad-


Top
 Profile  
 
 Post subject: Re: ClassCastException: at MapGetter.get(MapAccessor.java:67
PostPosted: Thu Jan 10, 2008 8:22 am 
Newbie

Joined: Tue Jan 08, 2008 6:17 am
Posts: 4
farzad wrote:
Remove the class attribute from composite-id tag and see if it works.



Farzad-


i tried with the following mapping file , but still showing the same exception.

<?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="myhibernate.Mmm" table="MESSAGE">
<id name="msg" type="string" column="MESSAGE">
<generator class="assigned"/>
</id>
<property name="id" type="int" column="MESSAGE_ID"/>
</class>
</hibernate-mapping>

please tell me the solution.


Top
 Profile  
 
 Post subject: Re: ClassCastException: at MapGetter.get(MapAccessor.java:67
PostPosted: Thu Jan 10, 2008 1:01 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Sorry. I was blind not to see you have set default_entity_mode to maps but you are passing a POJO. Removing that line from the config file might solve the problem. Let me know if you run into another one.


Farzad-


Top
 Profile  
 
 Post subject: Re: ClassCastException: at MapGetter.get(MapAccessor.java:67
PostPosted: Fri Jan 11, 2008 1:32 am 
Newbie

Joined: Tue Jan 08, 2008 6:17 am
Posts: 4
farzad wrote:
Sorry. I was blind not to see you have set default_entity_mode to maps but you are passing a POJO. Removing that line from the config file might solve the problem. Let me know if you run into another one.


Farzad-


Farzad,

it is wrking , Thank you , Thank you ,..... i am soooo happpy.


Apparao.


Top
 Profile  
 
 Post subject: Re: ClassCastException: at MapGetter.get(MapAccessor.java:67
PostPosted: Fri Jan 11, 2008 4:45 am 
Newbie

Joined: Tue Jan 08, 2008 6:17 am
Posts: 4
raoaryan_n wrote:
farzad wrote:
Sorry. I was blind not to see you have set default_entity_mode to maps but you are passing a POJO. Removing that line from the config file might solve the problem. Let me know if you run into another one.


Farzad-


Farzad,

Thank you
it is not throwing any exceptions,but the data is not inserted into the table.



Apparao.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.