-->
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.  [ 1 post ] 
Author Message
 Post subject: How to reload classes implementing Map interface
PostPosted: Tue May 02, 2006 8:22 am 
Newbie

Joined: Mon Jan 16, 2006 8:41 am
Posts: 6
Hello everybody,

I am getting some ClassCast exception (java.lang.ClassCastException: org.hibernate.proxy.MapProxy) while trying to load from DB a class that implements the Map interface. Is there any known "clue" about playing with Maps ?

Many thanks for your help, suggestions...

Here are some details about this pb

First I use the EntityMode.MAP on my session:
Code:
Session sess = sessionFactory.openSession();
Session dynSession = sess.getSession(EntityMode.MAP);


I am trying to save/load a class that implements the Map interface:
Quote:
public class AddressMapImpl implements Address,Serializable, Map {

private HashMap internalMap;
public AddressMapImpl() {
internalMap = new HashMap();
internalMap.put("id",null);
internalMap.put("zipCode",null);
internalMap.put("country",null);
internalMap.put("street",null);
}

public String getId() {...}
public void setId(String id) {...}
...
}

And the hbm file is as follow:
Code:
<hibernate-mapping>
    <class entity-name="com.mb.simpledemo.model.user.Address"  table="ADDRESS">
        <id name="id" type="string" column="ADDRESS_ID">
            <generator class="uuid.hex"/>
        </id>
        <property name="zipCode" type="string">
           <column name="ZIPCODE" unique="false"/>
         </property>
        <property name="country" type="string">
           <column name="COUNTRY" unique="false"/>
         </property>
        <property name="street" type="string">
           <column name="STREET" unique="false"/>
         </property>
...


I am able to persist instances of this class using the following code:
Code:
Session dynSession = sess.getSession(EntityMode.MAP);
Transaction tx=dynSession.beginTransaction();
dynSession.saveOrUpdate("com.mb.simpledemo.model.user.Address",this);
tx.commit();
sess.close();



But if i try to load a class using the following code:
Code:
String id=...
Session dynSession = sess.getSession(EntityMode.MAP);
Address obj = (Address) dynSession.load("com.mb.simpledemo.model.user.Address", id);


i get a ClassCast exception:
java.lang.ClassCastException: org.hibernate.proxy.MapProxy


Any thought, suggestion, magic idea ?

Thanks a lot for your help,

Best Regards


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

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.