From: <leg...@at...> - 2003-07-14 02:37:43
|
The following comment has been added to this issue: Author: Will Glass-Husain Created: Sun, 13 Jul 2003 9:37 PM Body: wow! that's quick. version 2.0.1 17 June 2003 This was downloaded just a few days ago. sorry if I missed a duplicate issue, I'm new to Jira. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-190 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-190 Summary: codegenerator creates SortedMap when it should create Map Type: Bug Status: Assigned Priority: Major Project: Hibernate2 Components: toolset Versions: 2.0 final Assignee: Max Rydahl Andersen Reporter: Will Glass-Husain Created: Sun, 13 Jul 2003 9:30 PM Updated: Sun, 13 Jul 2003 9:34 PM Environment: Win XP/JDK 1.3.1 Description: 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. --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |