From: Mattias A. (JIRA) <no...@at...> - 2005-10-17 13:17:15
|
Map, OneToMany, join table does not work ---------------------------------------- Key: ANN-120 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-120 Project: Hibernate Annotations Type: Bug Versions: 3.1beta6 Environment: Hibernate 3.1 RC1, Annotations 3.1b6, Java 1.5.0_05 Reporter: Mattias Arbin Attachments: KeyValue.java, MyEntity.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 |
From: Mattias A. (JIRA) <no...@at...> - 2005-10-17 13:19:15
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Mattias Arbin updated ANN-120: ------------------------------ Attachment: TestKeyValue.java > Map, OneToMany, join table does not work > ---------------------------------------- > > Key: ANN-120 > URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-120 > Project: Hibernate Annotations > Type: Bug > 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2005-12-28 12:18:33
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Emmanuel Bernard updated ANN-120: --------------------------------- Component: binder > Map, OneToMany, join table 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 |
From: Daniel F. (JIRA) <no...@at...> - 2006-01-07 21:05:28
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_21577 ] Daniel Fielder commented on ANN-120: ------------------------------------ Have you figured anything out yet on this issue? From examining the SQL produced, you can see that it's looking for the mapping column on the join table instead of the table that is connected to the query via the left outer join. Using the @OneToMany(mappedBy="columnname") notation doesn't work as I am getting a ClassCastException: org.hibernate.mapping.SimpleValue. > Map, OneToMany, join table 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-01-25 20:17:16
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Emmanuel Bernard updated ANN-120: --------------------------------- Summary: Map, OneToMany, join table or @ManyToMany does not work (was: Map, OneToMany, join table does not work) > 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 |
From: Noel B. (JIRA) <no...@at...> - 2006-01-25 23:50:10
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_21820 ] Noel Bush commented on ANN-120: ------------------------------- This problem is really serious. I can't understand why it is not even assigned to anyone. It still exists with Hibernate 3.1.1 + Annotations 3.1beta8. It is clear that the wrong table name is being used in the generated SQL. I inadvertently posted another JIRA issue about this today, and it was marked "resolved" because it was a duplicate of this bug -- but this bug is not even being addressed! I don't understand how the Annotations product is usable at all with this particular problem. There ought to be a very big notice on the main page for Annotations saying "You cannot use Hibernate Annotations to persist java.util.Maps that have entities as values." I have begun looking through the Annotations code to try to understand where the problem is and to see whether I might be able to submit a patch. > 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-01-26 00:42:09
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_21821 ] Emmanuel Bernard commented on ANN-120: -------------------------------------- I have some other priorities, and I don't see this one as an important feature for mapping a relational model. Than why I didn't work on it so far. Of course, patches are welcome and speed up resolution. The limitation comes from Hibernate core. > 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 |
From: Noel B. (JIRA) <no...@at...> - 2006-01-26 01:46:17
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_21822 ] Noel Bush commented on ANN-120: ------------------------------- I'm hoping I can come up with a simple patch -- Hibernate and the Annotations project are pretty complex, but I believe I see the place where this formula is generated. But I am really curious about your point of view that this isn't important. You've mentioned that before, and perhaps I am just misunderstanding something, but I cannot understand how it would not seem *essential* that Hibernate (with or without Annotations) should be able to persist members of a class that are Maps, just like any other member of a class. You don't think that Maps themselves are inessential, do you? If I adopt the position that Maps are not important because they don't match up neatly with a relational model, then I am basically saying that I have to re-work my application to work only in terms that are "friendly" to relational concepts. And this seems to be in the wrong direction, purpose-wise, from what ORM tools are supposed to be. But I say all this out of naivete, without a solid background in relational modeling. I admit that I'm one of the people looking for something that "just works", rather than requiring me to become a database expert. In any case, I will try my (limited) best to come up with a patch that deals with this issue, and will see if it is actually usable in the grander scheme of all things Hibernate. > 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 |
From: Christian B. (JIRA) <no...@at...> - 2006-01-26 02:09:18
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_21823 ] Christian Bauer commented on ANN-120: ------------------------------------- And here I am after Emmanuels comment with my hands on my eyes saying to myself "never give them an opening"... :) > 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 |
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 |
From: Christian B. (JIRA) <no...@at...> - 2006-01-26 04:07:16
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_21825 ] Christian Bauer commented on ANN-120: ------------------------------------- http://blog.hibernate.org/cgi-bin/blosxom.cgi/2006/01/25#collectionmapping > 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 |
From: Adam K. (JIRA) <no...@at...> - 2006-03-29 19:38:19
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_22644 ] Adam Kramer commented on ANN-120: --------------------------------- Hi Christian, Without entering the flame war, I'd like to weigh in. I do agree with you that this is technically a feature, but it is a feature that is in Hibernate mappings that is not in Annotations, thus I think alot of people expect it to be there; they are obviously intertwined projects. I was trying to migrate to Annotations from XDoclet generated mapping files and encountered this roadblock. And while I agree that I could do something like construct a custom query to retrieve mappings, etc... it is not a practical option at this point due to time constraints. The other option is to drastically change our domain model to match the limitations of Annotations, but again, this is too drastic for our requirements at this point. I thank you and others like Emmanuel for your hard work on this, and look forward to future releases. I will attempt to contribute if have time in the future. Thanks, Adam > 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-04-26 16:59:26
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_22868 ] Emmanuel Bernard commented on ANN-120: -------------------------------------- Adam, if you're suck with it in your migration from XDoclet to Annotation, you are actually looking for ANN-1, witch is a different story. > 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-04-30 19:28:26
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Emmanuel Bernard updated ANN-120: --------------------------------- Fix Version: 3.2.0 > 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 > Fix For: 3.2.0 > 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-05-05 18:03:57
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Emmanuel Bernard resolved ANN-120: ---------------------------------- Resolution: Fixed Assign To: Emmanuel Bernard > 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 > Assignee: Emmanuel Bernard > Fix For: 3.2.0 > 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-05-05 23:06:32
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Emmanuel Bernard updated ANN-120: --------------------------------- Fix Version: 3.2.0.cr1 (was: 3.2.0) > 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 > Assignee: Emmanuel Bernard > Fix For: 3.2.0.cr1 > 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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-05-05 23:29:26
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Emmanuel Bernard updated ANN-120: --------------------------------- type: Improvement (was: Bug) > 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: Improvement > Components: binder > Versions: 3.1beta6 > Environment: Hibernate 3.1 RC1, Annotations 3.1b6, Java 1.5.0_05 > Reporter: Mattias Arbin > Assignee: Emmanuel Bernard > Fix For: 3.2.0.cr1 > 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 |
From: Todd O (JIRA) <no...@at...> - 2006-06-14 04:41:35
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=all ] Todd O updated ANN-120: ----------------------- Attachment: KeyValue2.java MyEntity2.java TestKeyValue2.java I've upgraded to core 3.2.0cr2 and annotations 3.2.0.cr1. I've attached v2 sources. Hibernate is still writing incorrect sql, but now it's different incorrect sql: Hibernate: insert into MyEntity2 values ( ) Hibernate: insert into KeyValue2 (val, name) values (?, ?) Hibernate: insert into KeyValue2 (val, name) values (?, ?) Hibernate: insert into MyEntity2_KeyValue2 (MyEntity2_id, props_id) values (?, ?) Hibernate: insert into MyEntity2_KeyValue2 (MyEntity2_id, props_id) values (?, ?) Hibernate: select this_.id as id1_0_ from MyEntity2 this_ Hibernate: select props0_.MyEntity2_id as MyEntity1_1_, props0_.props_id as props2_1_, select a15.name from KeyValue2 as a15 where a15.id=props0_.props_id as formula0_1_, keyvalue2x1_.id as id0_0_, keyvalue2x1_.val as val0_0_, keyvalue2x1_.name as name0_0_ from MyEntity2_KeyValue2 props0_ left outer join KeyValue2 keyvalue2x1_ on props0_.props_id=keyvalue2x1_.id where props0_.MyEntity2_id=? Jun 13, 2006 9:36:09 PM org.hibernate.util.JDBCExceptionReporter logExceptions WARNING: SQL Error: 1064, SQLState: 42000 Jun 13, 2006 9:36:09 PM org.hibernate.util.JDBCExceptionReporter logExceptions SEVERE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select a15.name from KeyValue2 as a15 where a15.id=props0_.props_id as formula0_' at line 1 > 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: Improvement > Components: binder > Versions: 3.1beta6 > Environment: Hibernate 3.1 RC1, Annotations 3.1b6, Java 1.5.0_05 > Reporter: Mattias Arbin > Assignee: Emmanuel Bernard > Fix For: 3.2.0.cr1 > Attachments: KeyValue.java, KeyValue2.java, MyEntity.java, MyEntity2.java, TestKeyValue.java, TestKeyValue2.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 |
From: Emmanuel B. (JIRA) <no...@at...> - 2006-06-15 15:22:53
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-120?page=comments#action_23342 ] Emmanuel Bernard commented on ANN-120: -------------------------------------- Hi Todd, can you open a new case with that. I'm pretty sure this is not the same problem > 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: Improvement > Components: binder > Versions: 3.1beta6 > Environment: Hibernate 3.1 RC1, Annotations 3.1b6, Java 1.5.0_05 > Reporter: Mattias Arbin > Assignee: Emmanuel Bernard > Fix For: 3.2.0.cr1 > Attachments: KeyValue.java, KeyValue2.java, MyEntity.java, MyEntity2.java, TestKeyValue.java, TestKeyValue2.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 |