java.lang.ClassCastException: net.sf.hibernate.collection.Map

Hibernate JIRA | Will Glass-Husain | 1 decade ago
  1. 0

    The code generator used a SortedMap to represent the following composite element. <class name="com.wgh.om.Rent" table="rent"> <meta attribute="generated-class">com.wgh.om.base.Rent</meta> <id name="rent_id" type="long" unsaved-value="null"> <generator class="identity"/> </id> <map name="amenities"> <key column="rent_id" /> <index column="name" type="string" /> <composite-element class="com.wgh.om.RentAmenity"> <meta attribute="generated-class">com.wgh.om.base.RentAmenity</meta> <property name="name" type="string" not-null="true"/> <property name="category" type="int" /> </composite-element> </map> </class> When I saved the class with this code, I received a PropertyAccessException from cglib. (with the optimizer turned off). hs = HibernateWrapper.getNewSession(ctx); o = new Rent(); o.setAmenities(new TreeMap()); hs.close(); hs = HibernateWrapper.getNewSession(ctx); hs.saveOrUpdate(o); hs.flush(); hs.connection().commit(); hs.close(); 2003-07-13 19:29:04 DEBUG java.lang.ClassCastException: net.sf.hibernate.collection.Map at com.novogradac.valuation.om.RentMetaClass3.setPropertyValues(<generated>) at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:158) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:724) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214) The solution was to either (A) add sort="natural" to the map hbm.xml, or to change the generated code to use Map instead of SortedMap. Recommendation-- have the codegenerator only use SortedMaps when the sorted attribute is present in the hbm.xml.

    Hibernate JIRA | 1 decade ago | Will Glass-Husain
    java.lang.ClassCastException: net.sf.hibernate.collection.Map
  2. 0

    The code generator used a SortedMap to represent the following composite element. <class name="com.wgh.om.Rent" table="rent"> <meta attribute="generated-class">com.wgh.om.base.Rent</meta> <id name="rent_id" type="long" unsaved-value="null"> <generator class="identity"/> </id> <map name="amenities"> <key column="rent_id" /> <index column="name" type="string" /> <composite-element class="com.wgh.om.RentAmenity"> <meta attribute="generated-class">com.wgh.om.base.RentAmenity</meta> <property name="name" type="string" not-null="true"/> <property name="category" type="int" /> </composite-element> </map> </class> When I saved the class with this code, I received a PropertyAccessException from cglib. (with the optimizer turned off). hs = HibernateWrapper.getNewSession(ctx); o = new Rent(); o.setAmenities(new TreeMap()); hs.close(); hs = HibernateWrapper.getNewSession(ctx); hs.saveOrUpdate(o); hs.flush(); hs.connection().commit(); hs.close(); 2003-07-13 19:29:04 DEBUG java.lang.ClassCastException: net.sf.hibernate.collection.Map at com.novogradac.valuation.om.RentMetaClass3.setPropertyValues(<generated>) at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:158) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:724) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214) The solution was to either (A) add sort="natural" to the map hbm.xml, or to change the generated code to use Map instead of SortedMap. Recommendation-- have the codegenerator only use SortedMaps when the sorted attribute is present in the hbm.xml.

    Hibernate JIRA | 1 decade ago | Will Glass-Husain
    java.lang.ClassCastException: net.sf.hibernate.collection.Map
  3. 0

    JaxB cannot be cast to java.lang.Integer

    Stack Overflow | 4 years ago | Rodrigo
    java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to java.lang.Integer
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    app crashes when i change the order of my XML RelativeLayout android

    Stack Overflow | 4 years ago | Aaron Russell
    java.lang.ClassCastException: android.widget.ImageView
  6. 0

    Fragment Activity in tabhost "cannot be cast to android.support.v4.app.Fragment"

    Stack Overflow | 4 years ago | Aoyama Nanami
    java.lang.ClassCastException: id.co.ajsmsig.epolicy.LoginActivity cannot be cast to android.support.v4.app.Fragment

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      net.sf.hibernate.collection.Map

      at com.novogradac.valuation.om.RentMetaClass3.setPropertyValues()
    2. com.novogradac.valuation
      RentMetaClass3.setPropertyValues
      1. com.novogradac.valuation.om.RentMetaClass3.setPropertyValues(<generated>)
      1 frame
    3. net.sf.hibernate
      SessionImpl.saveOrUpdate
      1. net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:158)
      2. net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:724)
      3. net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:620)
      4. net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1214)
      4 frames