From: Christian B. (JIRA) <no...@at...> - 2006-01-26 03:29:39
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_21824 ] Christian Bauer commented on ANN-120: ------------------------------------- As my last comment, despite the smiley, seems to have triggered an outburst of pure hate by Mr. Bush against me in private email, I now formally apologize for not making this statement in private - and to an audience who understands that the issue we are talking about here is indeed not really important and that there is no reason to update a website and tell thousands of people that a software is unusable. Thank you. Please don't send me any further emails. > Map, OneToMany, join table or @ManyToMany does not work > ------------------------------------------------------- > > Key: ANN-120 > URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-120 > Project: Hibernate Annotations > Type: Bug > Components: binder > Versions: 3.1beta6 > Environment: Hibernate 3.1 RC1, Annotations 3.1b6, Java 1.5.0_05 > Reporter: Mattias Arbin > Attachments: KeyValue.java, MyEntity.java, TestKeyValue.java > > > Seems like there is a problem with mapping a Map using join table. > I have a relation like this: > @OneToMany(cascade=CascadeType.ALL) > @MapKey(name="name") > public Map<String, KeyValue> getProps() { > return props; > } > The correct tables are created and inserting data works fine. When loading, however, I get the error below. > When using a join column, everything works fine: > @OneToMany(cascade=CascadeType.ALL) > @MapKey(name="name") > @JoinColumn(name="myentity_id") > public Map<String, KeyValue> getProps() { > return props; > } > Attached the two test classes. > The error: > ... > Hibernate: select this_.id as id3_0_ from test_MyEntity this_ > Hibernate: select props0_.MyEntity_id as MyEntity1_1_, props0_.props_id as props2_1_, props0_.name as formula0_1_, keyvalue1_.id as id2_0_, keyvalue1_.val as val2_0_, keyvalue1_.name as name2_0_ from test_MyEntity_KeyValue props0_ left outer join test_KeyValue keyvalue1_ on props0_.props_id=keyvalue1_.id where props0_.MyEntity_id=? > 15:11:49,078 WARN JDBCExceptionReporter:71 - SQL Error: 1054, SQLState: 42S22 > Exception in thread "main" 15:11:49,078 ERROR JDBCExceptionReporter:72 - null, message from server: "Unknown column 'props0_.name' in 'field list'" > org.hibernate.exception.SQLGrammarException: could not initialize a collection: [test.data.MyEntity.props#1] > at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65) > at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) > at org.hibernate.loader.Loader.loadCollection(Loader.java:1923) > at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71) > at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520) > at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) > at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1565) > at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344) > at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) > at org.hibernate.collection.AbstractPersistentCollection.readElementByIndex(AbstractPersistentCollection.java:161) > at org.hibernate.collection.PersistentMap.get(PersistentMap.java:127) > at test.TestKeyValue.test(TestKeyValue.java:43) > at test.TestKeyValue.main(TestKeyValue.java:57) > Caused by: java.sql.SQLException: null, message from server: "Unknown column 'props0_.name' in 'field list'" > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1876) > at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098) > at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192) > at com.mysql.jdbc.Connection.execSQL(Connection.java:2051) > at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1496) > at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:137) > at org.hibernate.loader.Loader.getResultSet(Loader.java:1676) > at org.hibernate.loader.Loader.doQuery(Loader.java:662) > at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223) > at org.hibernate.loader.Loader.loadCollection(Loader.java:1916) > ... 10 more -- 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 - For more information on JIRA, see: http://www.atlassian.com/software/jira |