From noreply at atlassian.com Wed Mar 12 13:05:34 2008 Content-Type: multipart/mixed; boundary="===============4490170879570708765==" MIME-Version: 1.0 From: Adam Hardy (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Created: (EJB-343) exception trying to load entity with idClass - 'id column not in any table' Date: Wed, 12 Mar 2008 12:05:33 -0500 Message-ID: <110172607.1205341533988.JavaMail.j2ee@atlassian01.managed.contegix.com> --===============4490170879570708765== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable exception trying to load entity with idClass - 'id column not in any table' --------------------------------------------------------------------------- Key: EJB-343 URL: http://opensource.atlassian.com/projects/hibernate/br= owse/EJB-343 Project: Hibernate Entity Manager Issue Type: Bug Components: EntityManager Reporter: Adam Hardy Hibernate EntityManager won't map an id-class for an entity. I have ust one= entity with an inner class as the idClass. Hibernate refuses to load the entity, throwing the following exception (see= further down). I am using hibernate-annotations-3.3.0ga and hibernate-entitymanager-3.3.1g= a. Mapping: DEV This is the entity code: public class HabitatSpeciesLink implements Serializable { private static final long serialVersionUID =3D -7079021236893433038L; private Long habitatId; private Long speciesId; public static class HabitatSpeciesLinkId implements Serializable { //private static final long serialVersionUID =3D 622470364278872311= 2L; private Long habitatId; private Long speciesId; public Long getHabitatId() { return this.habitatId; } public void setHabitatId(Long newHabitatId) { this.habitatId =3D newHabitatId; } public Long getSpeciesId() { return this.speciesId; } public void setSpeciesId(Long newSpeciesId) { this.speciesId =3D newSpeciesId; } public boolean equals(Object other) { if (other =3D=3D this) return true; if (!(other instanceof HabitatSpeciesLinkId)) return false; HabitatSpeciesLinkId mi =3D (HabitatSpeciesLinkId) other; return (habitatId =3D=3D mi.habitatId || (habitatId !=3D null &= & habitatId .equals(mi.habitatId))) && (speciesId =3D=3D mi.speciesId || (speciesId !=3D null &= & speciesId .equals(mi.speciesId))); } public int hashCode() { return ((habitatId =3D=3D null) ? 0 : habitatId.hashCode()) ^ ((speciesId =3D=3D null) ? 0 : speciesId.hashCode()); } public String toString() { return "habitatId[" + habitatId + "],speciesId[" + speciesId + = "]"; } } public Long getHabitatId() { return this.habitatId; } public void setHabitatId(Long newHabitatId) { this.habitatId =3D newHabitatId; } public Long getSpeciesId() { return this.speciesId; } public void setSpeciesId(Long newSpeciesId) { this.speciesId =3D newSpeciesId; } @Override public int hashCode() { final int prime =3D 31; int result =3D 1; result =3D prime * result + ((this.getHabitatId() =3D=3D null) ? 0 : this.getHabitatId().hashCode()); result =3D prime * result + ((this.getSpeciesId() =3D=3D null) ? 0 : this.getSpeciesId().hashCode()); return result; } @Override public boolean equals(Object obj) { if (this =3D=3D obj) return true; if (obj =3D=3D null) return false; if (!(obj instanceof HabitatSpeciesLink)) return false; final HabitatSpeciesLink other =3D (HabitatSpeciesLink) obj; if (this.getHabitatId() =3D=3D null) { if (other.getHabitatId() !=3D null) return false; } else if (!this.getHabitatId().equals(other.getHabitatId())) return false; if (this.getSpeciesId() =3D=3D null) { if (other.getSpeciesId() !=3D null) return false; } else if (!this.getSpeciesId().equals(other.getSpeciesId())) return false; return true; } } This is the test code: EntityManager entityManager =3D entityManagerFactory.createEntityManager(); HabitatSpeciesLink.HabitatSpeciesLinkId id =3D new HabitatSpeciesLink.Habit= atSpeciesLinkId(); id.setHabitatId(new Long(123)); id.setSpeciesId(new Long(234)); HabitatSpeciesLink entity =3D entityManager.find(HabitatSpeciesLink.class, = id); Assert.assertNotNull("should have entity with composite key", entity); Here's the stacktrace: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarE= xception: could not load an entity: [org.permacode.HabitatSpeciesLink#compo= nent[habitatId,speciesId]{habitatId=3D123, speciesId=3D234}] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException= (AbstractEntityManagerImpl.java:630) at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManage= rImpl.java:195) at org.permacode.BugCompositeKeyTest.testCompositeKey(BugCompositeKeyTes= t.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.= java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces= sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.ja= va:98) at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79) at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(= MethodRoadie.java:87) at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77) at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4C= lassRunner.java:88) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRu= nner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.= java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.jav= a:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:= 37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.ja= va:42) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4= TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution= .java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot= eTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot= eTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest= Runner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes= tRunner.java:196) Caused by: org.hibernate.exception.SQLGrammarException: could not load an e= ntity: [org.permacode.HabitatSpeciesLink#component[habitatId,speciesId]{hab= itatId=3D123, speciesId=3D234}] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j= ava:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp= er.java:43) at org.hibernate.loader.Loader.loadEntity(Loader.java:1865) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityL= oader.java:48) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityL= oader.java:42) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractE= ntityPersister.java:2992) at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(D= efaultLoadEventListener.java:395) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEv= entListener.java:375) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEven= tListener.java:139) at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultL= oadEventListener.java:195) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEv= entListener.java:103) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManage= rImpl.java:175) ... 23 more Caused by: java.sql.SQLException: Column 'HABITATSPE0_.HABITATID' is either= not in any table in the FROM list or appears within a join specification a= nd is outside the scope of the join specification or appears in a HAVING cl= ause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE s= tatement then 'HABITATSPE0_.HABITATID' is not a column in the target table. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknow= n Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException= (Unknown Source) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Un= known Source) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown So= urce) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown So= urce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Sour= ce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown So= urce) at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown So= urce) at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown Sour= ce) at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown S= ource) at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown S= ource) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatch= er.java:497) at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatch= er.java:415) at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatc= her.java:139) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) at org.hibernate.loader.Loader.doQuery(Loader.java:661) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo= ader.java:224) at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) ... 35 more Caused by: ERROR 42X04: Column 'HABITATSPE0_.HABITATID' is either not in an= y table in the FROM list or appears within a join specification and is outs= ide the scope of the join specification or appears in a HAVING clause and i= s not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement t= hen 'HABITATSPE0_.HABITATID' is not a column in the target table. at org.apache.derby.iapi.error.StandardException.newException(Unknown So= urce) at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Unkn= own Source) at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(Unknown= Source) at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(Un= known Source) at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknown = Source) at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(Un= known Source) at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Sourc= e) at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown So= urce) at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source) at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepa= reInternalStatement(Unknown Source) ... 48 more I'm using Derby, Hypersonic, H2 or postgresql. It seems to be database-inde= pendent. This is the generated SQL: select habitatspe0_.habitatId as habitatId0_0_, habitatspe0_.speciesId as s= peciesId0_0_ from DEV.HABITAT_SPECIES_LINK habitatspe0_ where habitatspe0_.= habitatId=3D? and habitatspe0_.speciesId=3D? -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============4490170879570708765==-- From noreply at atlassian.com Wed Mar 12 13:15:33 2008 Content-Type: multipart/mixed; boundary="===============6253841060584211461==" MIME-Version: 1.0 From: Adam Hardy (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Updated: (EJB-343) exception trying to load entity with idClass - 'id column not in any table' Date: Wed, 12 Mar 2008 12:15:33 -0500 Message-ID: <144022117.1205342133512.JavaMail.j2ee@atlassian01.managed.contegix.com> In-Reply-To: 110172607.1205341533988.JavaMail.j2ee@atlassian01.managed.contegix.com --===============6253841060584211461== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-343?pa= ge=3Dcom.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Adam Hardy updated EJB-343: --------------------------- Attachment: jpabug.zip Wrote this test that demonstrates the problem. = It's maven-ized and eclipse-ified if anyone trying it uses either of those = build tools, otherwise all dependencies are zipped up in target/dependency/ It's hooked up to derby so it will create its own DB automatically in the w= orking dir. = > exception trying to load entity with idClass - 'id column not in any tabl= e' > -------------------------------------------------------------------------= -- > > Key: EJB-343 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/EJB-343 > Project: Hibernate Entity Manager > Issue Type: Bug > Components: EntityManager > Reporter: Adam Hardy > Attachments: jpabug.zip > > > Hibernate EntityManager won't map an id-class for an entity. I have ust o= ne entity with an inner class as the idClass. > Hibernate refuses to load the entity, throwing the following exception (s= ee further down). > I am using hibernate-annotations-3.3.0ga and hibernate-entitymanager-3.3.= 1ga. > Mapping: > > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm http:/= /java.sun.com/xml/ns/persistence/orm_1_0.xsd" > version=3D"1.0"> > DEV > >
> class=3D"org.permacode.HabitatSpeciesLink$HabitatSpeciesLinkId" /> > > > > > > > > > > > This is the entity code: > public class HabitatSpeciesLink implements Serializable > { > private static final long serialVersionUID =3D -7079021236893433038L; > private Long habitatId; > private Long speciesId; > public static class HabitatSpeciesLinkId implements Serializable > { > //private static final long serialVersionUID =3D 6224703642788723= 112L; > private Long habitatId; > private Long speciesId; > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > public boolean equals(Object other) > { > if (other =3D=3D this) > return true; > if (!(other instanceof HabitatSpeciesLinkId)) > return false; > HabitatSpeciesLinkId mi =3D (HabitatSpeciesLinkId) other; > return (habitatId =3D=3D mi.habitatId || (habitatId !=3D null= && habitatId > .equals(mi.habitatId))) > && (speciesId =3D=3D mi.speciesId || (speciesId !=3D null= && speciesId > .equals(mi.speciesId))); > } > public int hashCode() > { > return ((habitatId =3D=3D null) ? 0 > : habitatId.hashCode()) ^ ((speciesId =3D=3D null) ? 0 > : speciesId.hashCode()); > } > public String toString() > { > return "habitatId[" + habitatId + "],speciesId[" + speciesId = + "]"; > } > } > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > @Override > public int hashCode() > { > final int prime =3D 31; > int result =3D 1; > result =3D prime * result + ((this.getHabitatId() =3D=3D null) ? 0 > : this.getHabitatId().hashCode()); > result =3D prime * result + ((this.getSpeciesId() =3D=3D null) ? 0 > : this.getSpeciesId().hashCode()); > return result; > } > @Override > public boolean equals(Object obj) > { > if (this =3D=3D obj) > return true; > if (obj =3D=3D null) > return false; > if (!(obj instanceof HabitatSpeciesLink)) > return false; > final HabitatSpeciesLink other =3D (HabitatSpeciesLink) obj; > if (this.getHabitatId() =3D=3D null) > { > if (other.getHabitatId() !=3D null) > return false; > } > else if (!this.getHabitatId().equals(other.getHabitatId())) > return false; > if (this.getSpeciesId() =3D=3D null) > { > if (other.getSpeciesId() !=3D null) > return false; > } > else if (!this.getSpeciesId().equals(other.getSpeciesId())) > return false; > return true; > } > } > This is the test code: > EntityManager entityManager =3D entityManagerFactory.createEntityManager(= ); > HabitatSpeciesLink.HabitatSpeciesLinkId id =3D new HabitatSpeciesLink.Hab= itatSpeciesLinkId(); > id.setHabitatId(new Long(123)); > id.setSpeciesId(new Long(234)); > HabitatSpeciesLink entity =3D entityManager.find(HabitatSpeciesLink.class= , id); > Assert.assertNotNull("should have entity with composite key", entity); > Here's the stacktrace: > javax.persistence.PersistenceException: org.hibernate.exception.SQLGramma= rException: could not load an entity: [org.permacode.HabitatSpeciesLink#com= ponent[habitatId,speciesId]{habitatId=3D123, speciesId=3D234}] > at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceExcepti= on(AbstractEntityManagerImpl.java:630) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:195) > at org.permacode.BugCompositeKeyTest.testCompositeKey(BugCompositeKeyT= est.java:181) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp= l.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc= essorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) > at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.= java:98) > at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79) > at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfter= s(MethodRoadie.java:87) > at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:7= 7) > at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) > at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit= 4ClassRunner.java:88) > at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4Class= Runner.java:51) > at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunne= r.java:44) > at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.j= ava:27) > at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.jav= a:37) > at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.= java:42) > at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUni= t4TestReference.java:38) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecuti= on.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:460) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:673) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTe= stRunner.java:386) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteT= estRunner.java:196) > Caused by: org.hibernate.exception.SQLGrammarException: could not load an= entity: [org.permacode.HabitatSpeciesLink#component[habitatId,speciesId]{h= abitatId=3D123, speciesId=3D234}] > at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter= .java:67) > at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHe= lper.java:43) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1865) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:48) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:42) > at org.hibernate.persister.entity.AbstractEntityPersister.load(Abstrac= tEntityPersister.java:2992) > at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource= (DefaultLoadEventListener.java:395) > at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoad= EventListener.java:375) > at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEv= entListener.java:139) > at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(Defaul= tLoadEventListener.java:195) > at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoad= EventListener.java:103) > at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:175) > ... 23 more > Caused by: java.sql.SQLException: Column 'HABITATSPE0_.HABITATID' is eith= er not in any table in the FROM list or appears within a join specification= and is outside the scope of the join specification or appears in a HAVING = clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE = statement then 'HABITATSPE0_.HABITATID' is not a column in the target tabl= e. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unkn= own Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Sour= ce) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLExcepti= on(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(= Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown = Source) > at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:497) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:415) > at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBa= tcher.java:139) > at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) > at org.hibernate.loader.Loader.doQuery(Loader.java:661) > at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(= Loader.java:224) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) > ... 35 more > Caused by: ERROR 42X04: Column 'HABITATSPE0_.HABITATID' is either not in = any table in the FROM list or appears within a join specification and is ou= tside the scope of the join specification or appears in a HAVING clause and= is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement= then 'HABITATSPE0_.HABITATID' is not a column in the target table. > at org.apache.derby.iapi.error.StandardException.newException(Unknown = Source) > at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Un= known Source) > at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(Unkno= wn Source) > at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknow= n Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Sou= rce) > at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown = Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Sourc= e) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.pre= pareInternalStatement(Unknown Source) > ... 48 more > I'm using Derby, Hypersonic, H2 or postgresql. It seems to be database-in= dependent. > This is the generated SQL: > select habitatspe0_.habitatId as habitatId0_0_, habitatspe0_.speciesId as= speciesId0_0_ from DEV.HABITAT_SPECIES_LINK habitatspe0_ where habitatspe0= _.habitatId=3D? and habitatspe0_.speciesId=3D? -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============6253841060584211461==-- From noreply at atlassian.com Fri Mar 14 11:12:33 2008 Content-Type: multipart/mixed; boundary="===============3725924893133036418==" MIME-Version: 1.0 From: Emmanuel Bernard (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Updated: (EJB-343) id class columns not honored when using orm.xml Date: Fri, 14 Mar 2008 10:12:33 -0500 Message-ID: <97425206.1205507553160.JavaMail.j2ee@atlassian01.managed.contegix.com> In-Reply-To: 110172607.1205341533988.JavaMail.j2ee@atlassian01.managed.contegix.com --===============3725924893133036418== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-343?pa= ge=3Dcom.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Emmanuel Bernard updated EJB-343: --------------------------------- Summary: id class columns not honored when using orm.xml (was: excepti= on trying to load entity with idClass - 'id column not in any table') > id class columns not honored when using orm.xml > ----------------------------------------------- > > Key: EJB-343 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/EJB-343 > Project: Hibernate Entity Manager > Issue Type: Bug > Components: EntityManager > Reporter: Adam Hardy > Attachments: jpabug.zip > > > Hibernate EntityManager won't map an id-class for an entity. I have ust o= ne entity with an inner class as the idClass. > Hibernate refuses to load the entity, throwing the following exception (s= ee further down). > I am using hibernate-annotations-3.3.0ga and hibernate-entitymanager-3.3.= 1ga. > Mapping: > > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm http:/= /java.sun.com/xml/ns/persistence/orm_1_0.xsd" > version=3D"1.0"> > DEV > >
> class=3D"org.permacode.HabitatSpeciesLink$HabitatSpeciesLinkId" /> > > > > > > > > > > > This is the entity code: > public class HabitatSpeciesLink implements Serializable > { > private static final long serialVersionUID =3D -7079021236893433038L; > private Long habitatId; > private Long speciesId; > public static class HabitatSpeciesLinkId implements Serializable > { > //private static final long serialVersionUID =3D 6224703642788723= 112L; > private Long habitatId; > private Long speciesId; > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > public boolean equals(Object other) > { > if (other =3D=3D this) > return true; > if (!(other instanceof HabitatSpeciesLinkId)) > return false; > HabitatSpeciesLinkId mi =3D (HabitatSpeciesLinkId) other; > return (habitatId =3D=3D mi.habitatId || (habitatId !=3D null= && habitatId > .equals(mi.habitatId))) > && (speciesId =3D=3D mi.speciesId || (speciesId !=3D null= && speciesId > .equals(mi.speciesId))); > } > public int hashCode() > { > return ((habitatId =3D=3D null) ? 0 > : habitatId.hashCode()) ^ ((speciesId =3D=3D null) ? 0 > : speciesId.hashCode()); > } > public String toString() > { > return "habitatId[" + habitatId + "],speciesId[" + speciesId = + "]"; > } > } > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > @Override > public int hashCode() > { > final int prime =3D 31; > int result =3D 1; > result =3D prime * result + ((this.getHabitatId() =3D=3D null) ? 0 > : this.getHabitatId().hashCode()); > result =3D prime * result + ((this.getSpeciesId() =3D=3D null) ? 0 > : this.getSpeciesId().hashCode()); > return result; > } > @Override > public boolean equals(Object obj) > { > if (this =3D=3D obj) > return true; > if (obj =3D=3D null) > return false; > if (!(obj instanceof HabitatSpeciesLink)) > return false; > final HabitatSpeciesLink other =3D (HabitatSpeciesLink) obj; > if (this.getHabitatId() =3D=3D null) > { > if (other.getHabitatId() !=3D null) > return false; > } > else if (!this.getHabitatId().equals(other.getHabitatId())) > return false; > if (this.getSpeciesId() =3D=3D null) > { > if (other.getSpeciesId() !=3D null) > return false; > } > else if (!this.getSpeciesId().equals(other.getSpeciesId())) > return false; > return true; > } > } > This is the test code: > EntityManager entityManager =3D entityManagerFactory.createEntityManager(= ); > HabitatSpeciesLink.HabitatSpeciesLinkId id =3D new HabitatSpeciesLink.Hab= itatSpeciesLinkId(); > id.setHabitatId(new Long(123)); > id.setSpeciesId(new Long(234)); > HabitatSpeciesLink entity =3D entityManager.find(HabitatSpeciesLink.class= , id); > Assert.assertNotNull("should have entity with composite key", entity); > Here's the stacktrace: > javax.persistence.PersistenceException: org.hibernate.exception.SQLGramma= rException: could not load an entity: [org.permacode.HabitatSpeciesLink#com= ponent[habitatId,speciesId]{habitatId=3D123, speciesId=3D234}] > at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceExcepti= on(AbstractEntityManagerImpl.java:630) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:195) > at org.permacode.BugCompositeKeyTest.testCompositeKey(BugCompositeKeyT= est.java:181) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp= l.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc= essorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) > at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.= java:98) > at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79) > at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfter= s(MethodRoadie.java:87) > at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:7= 7) > at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) > at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit= 4ClassRunner.java:88) > at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4Class= Runner.java:51) > at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunne= r.java:44) > at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.j= ava:27) > at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.jav= a:37) > at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.= java:42) > at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUni= t4TestReference.java:38) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecuti= on.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:460) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:673) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTe= stRunner.java:386) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteT= estRunner.java:196) > Caused by: org.hibernate.exception.SQLGrammarException: could not load an= entity: [org.permacode.HabitatSpeciesLink#component[habitatId,speciesId]{h= abitatId=3D123, speciesId=3D234}] > at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter= .java:67) > at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHe= lper.java:43) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1865) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:48) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:42) > at org.hibernate.persister.entity.AbstractEntityPersister.load(Abstrac= tEntityPersister.java:2992) > at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource= (DefaultLoadEventListener.java:395) > at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoad= EventListener.java:375) > at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEv= entListener.java:139) > at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(Defaul= tLoadEventListener.java:195) > at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoad= EventListener.java:103) > at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:175) > ... 23 more > Caused by: java.sql.SQLException: Column 'HABITATSPE0_.HABITATID' is eith= er not in any table in the FROM list or appears within a join specification= and is outside the scope of the join specification or appears in a HAVING = clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE = statement then 'HABITATSPE0_.HABITATID' is not a column in the target tabl= e. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unkn= own Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Sour= ce) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLExcepti= on(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(= Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown = Source) > at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:497) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:415) > at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBa= tcher.java:139) > at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) > at org.hibernate.loader.Loader.doQuery(Loader.java:661) > at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(= Loader.java:224) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) > ... 35 more > Caused by: ERROR 42X04: Column 'HABITATSPE0_.HABITATID' is either not in = any table in the FROM list or appears within a join specification and is ou= tside the scope of the join specification or appears in a HAVING clause and= is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement= then 'HABITATSPE0_.HABITATID' is not a column in the target table. > at org.apache.derby.iapi.error.StandardException.newException(Unknown = Source) > at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Un= known Source) > at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(Unkno= wn Source) > at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknow= n Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Sou= rce) > at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown = Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Sourc= e) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.pre= pareInternalStatement(Unknown Source) > ... 48 more > I'm using Derby, Hypersonic, H2 or postgresql. It seems to be database-in= dependent. > This is the generated SQL: > select habitatspe0_.habitatId as habitatId0_0_, habitatspe0_.speciesId as= speciesId0_0_ from DEV.HABITAT_SPECIES_LINK habitatspe0_ where habitatspe0= _.habitatId=3D? and habitatspe0_.speciesId=3D? -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============3725924893133036418==-- From noreply at atlassian.com Fri Mar 14 11:14:33 2008 Content-Type: multipart/mixed; boundary="===============2376466136087570917==" MIME-Version: 1.0 From: Emmanuel Bernard (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Moved: (ANN-708) id class columns not honored when using orm.xml Date: Fri, 14 Mar 2008 10:14:32 -0500 Message-ID: <151652475.1205507672851.JavaMail.j2ee@atlassian01.managed.contegix.com> In-Reply-To: 110172607.1205341533988.JavaMail.j2ee@atlassian01.managed.contegix.com --===============2376466136087570917== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-708?pa= ge=3Dcom.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Emmanuel Bernard moved EJB-343 to ANN-708: ------------------------------------------ Component/s: (was: EntityManager) binder Key: ANN-708 (was: EJB-343) Project: Hibernate Annotations (was: Hibernate Entity Manager) > id class columns not honored when using orm.xml > ----------------------------------------------- > > Key: ANN-708 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/ANN-708 > Project: Hibernate Annotations > Issue Type: Bug > Components: binder > Reporter: Adam Hardy > Attachments: jpabug.zip > > > Hibernate EntityManager won't map an id-class for an entity. I have ust o= ne entity with an inner class as the idClass. > Hibernate refuses to load the entity, throwing the following exception (s= ee further down). > I am using hibernate-annotations-3.3.0ga and hibernate-entitymanager-3.3.= 1ga. > Mapping: > > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm http:/= /java.sun.com/xml/ns/persistence/orm_1_0.xsd" > version=3D"1.0"> > DEV > >
> class=3D"org.permacode.HabitatSpeciesLink$HabitatSpeciesLinkId" /> > > > > > > > > > > > This is the entity code: > public class HabitatSpeciesLink implements Serializable > { > private static final long serialVersionUID =3D -7079021236893433038L; > private Long habitatId; > private Long speciesId; > public static class HabitatSpeciesLinkId implements Serializable > { > //private static final long serialVersionUID =3D 6224703642788723= 112L; > private Long habitatId; > private Long speciesId; > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > public boolean equals(Object other) > { > if (other =3D=3D this) > return true; > if (!(other instanceof HabitatSpeciesLinkId)) > return false; > HabitatSpeciesLinkId mi =3D (HabitatSpeciesLinkId) other; > return (habitatId =3D=3D mi.habitatId || (habitatId !=3D null= && habitatId > .equals(mi.habitatId))) > && (speciesId =3D=3D mi.speciesId || (speciesId !=3D null= && speciesId > .equals(mi.speciesId))); > } > public int hashCode() > { > return ((habitatId =3D=3D null) ? 0 > : habitatId.hashCode()) ^ ((speciesId =3D=3D null) ? 0 > : speciesId.hashCode()); > } > public String toString() > { > return "habitatId[" + habitatId + "],speciesId[" + speciesId = + "]"; > } > } > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > @Override > public int hashCode() > { > final int prime =3D 31; > int result =3D 1; > result =3D prime * result + ((this.getHabitatId() =3D=3D null) ? 0 > : this.getHabitatId().hashCode()); > result =3D prime * result + ((this.getSpeciesId() =3D=3D null) ? 0 > : this.getSpeciesId().hashCode()); > return result; > } > @Override > public boolean equals(Object obj) > { > if (this =3D=3D obj) > return true; > if (obj =3D=3D null) > return false; > if (!(obj instanceof HabitatSpeciesLink)) > return false; > final HabitatSpeciesLink other =3D (HabitatSpeciesLink) obj; > if (this.getHabitatId() =3D=3D null) > { > if (other.getHabitatId() !=3D null) > return false; > } > else if (!this.getHabitatId().equals(other.getHabitatId())) > return false; > if (this.getSpeciesId() =3D=3D null) > { > if (other.getSpeciesId() !=3D null) > return false; > } > else if (!this.getSpeciesId().equals(other.getSpeciesId())) > return false; > return true; > } > } > This is the test code: > EntityManager entityManager =3D entityManagerFactory.createEntityManager(= ); > HabitatSpeciesLink.HabitatSpeciesLinkId id =3D new HabitatSpeciesLink.Hab= itatSpeciesLinkId(); > id.setHabitatId(new Long(123)); > id.setSpeciesId(new Long(234)); > HabitatSpeciesLink entity =3D entityManager.find(HabitatSpeciesLink.class= , id); > Assert.assertNotNull("should have entity with composite key", entity); > Here's the stacktrace: > javax.persistence.PersistenceException: org.hibernate.exception.SQLGramma= rException: could not load an entity: [org.permacode.HabitatSpeciesLink#com= ponent[habitatId,speciesId]{habitatId=3D123, speciesId=3D234}] > at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceExcepti= on(AbstractEntityManagerImpl.java:630) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:195) > at org.permacode.BugCompositeKeyTest.testCompositeKey(BugCompositeKeyT= est.java:181) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp= l.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc= essorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) > at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.= java:98) > at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79) > at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfter= s(MethodRoadie.java:87) > at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:7= 7) > at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) > at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit= 4ClassRunner.java:88) > at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4Class= Runner.java:51) > at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunne= r.java:44) > at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.j= ava:27) > at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.jav= a:37) > at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.= java:42) > at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUni= t4TestReference.java:38) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecuti= on.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:460) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:673) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTe= stRunner.java:386) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteT= estRunner.java:196) > Caused by: org.hibernate.exception.SQLGrammarException: could not load an= entity: [org.permacode.HabitatSpeciesLink#component[habitatId,speciesId]{h= abitatId=3D123, speciesId=3D234}] > at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter= .java:67) > at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHe= lper.java:43) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1865) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:48) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:42) > at org.hibernate.persister.entity.AbstractEntityPersister.load(Abstrac= tEntityPersister.java:2992) > at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource= (DefaultLoadEventListener.java:395) > at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoad= EventListener.java:375) > at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEv= entListener.java:139) > at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(Defaul= tLoadEventListener.java:195) > at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoad= EventListener.java:103) > at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:175) > ... 23 more > Caused by: java.sql.SQLException: Column 'HABITATSPE0_.HABITATID' is eith= er not in any table in the FROM list or appears within a join specification= and is outside the scope of the join specification or appears in a HAVING = clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE = statement then 'HABITATSPE0_.HABITATID' is not a column in the target tabl= e. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unkn= own Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Sour= ce) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLExcepti= on(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(= Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown = Source) > at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:497) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:415) > at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBa= tcher.java:139) > at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) > at org.hibernate.loader.Loader.doQuery(Loader.java:661) > at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(= Loader.java:224) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) > ... 35 more > Caused by: ERROR 42X04: Column 'HABITATSPE0_.HABITATID' is either not in = any table in the FROM list or appears within a join specification and is ou= tside the scope of the join specification or appears in a HAVING clause and= is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement= then 'HABITATSPE0_.HABITATID' is not a column in the target table. > at org.apache.derby.iapi.error.StandardException.newException(Unknown = Source) > at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Un= known Source) > at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(Unkno= wn Source) > at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknow= n Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Sou= rce) > at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown = Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Sourc= e) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.pre= pareInternalStatement(Unknown Source) > ... 48 more > I'm using Derby, Hypersonic, H2 or postgresql. It seems to be database-in= dependent. > This is the generated SQL: > select habitatspe0_.habitatId as habitatId0_0_, habitatspe0_.speciesId as= speciesId0_0_ from DEV.HABITAT_SPECIES_LINK habitatspe0_ where habitatspe0= _.habitatId=3D? and habitatspe0_.speciesId=3D? -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============2376466136087570917==-- From noreply at atlassian.com Sat May 31 15:18:33 2008 Content-Type: multipart/mixed; boundary="===============7361643748638115638==" MIME-Version: 1.0 From: Emmanuel Bernard (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Updated: (ANN-708) id class columns not honored when using orm.xml Date: Sat, 31 May 2008 14:18:33 -0500 Message-ID: <129801513.1212261513076.JavaMail.j2ee@atlassian01.managed.contegix.com> In-Reply-To: 110172607.1205341533988.JavaMail.j2ee@atlassian01.managed.contegix.com --===============7361643748638115638== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-708?pa= ge=3Dcom.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Emmanuel Bernard updated ANN-708: --------------------------------- Fix Version/s: 4.0 > id class columns not honored when using orm.xml > ----------------------------------------------- > > Key: ANN-708 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/ANN-708 > Project: Hibernate Annotations > Issue Type: Bug > Components: binder > Reporter: Adam Hardy > Fix For: 4.0 > > Attachments: jpabug.zip > > > Hibernate EntityManager won't map an id-class for an entity. I have ust o= ne entity with an inner class as the idClass. > Hibernate refuses to load the entity, throwing the following exception (s= ee further down). > I am using hibernate-annotations-3.3.0ga and hibernate-entitymanager-3.3.= 1ga. > Mapping: > > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm http:/= /java.sun.com/xml/ns/persistence/orm_1_0.xsd" > version=3D"1.0"> > DEV > >
> class=3D"org.permacode.HabitatSpeciesLink$HabitatSpeciesLinkId" /> > > > > > > > > > > > This is the entity code: > public class HabitatSpeciesLink implements Serializable > { > private static final long serialVersionUID =3D -7079021236893433038L; > private Long habitatId; > private Long speciesId; > public static class HabitatSpeciesLinkId implements Serializable > { > //private static final long serialVersionUID =3D 6224703642788723= 112L; > private Long habitatId; > private Long speciesId; > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > public boolean equals(Object other) > { > if (other =3D=3D this) > return true; > if (!(other instanceof HabitatSpeciesLinkId)) > return false; > HabitatSpeciesLinkId mi =3D (HabitatSpeciesLinkId) other; > return (habitatId =3D=3D mi.habitatId || (habitatId !=3D null= && habitatId > .equals(mi.habitatId))) > && (speciesId =3D=3D mi.speciesId || (speciesId !=3D null= && speciesId > .equals(mi.speciesId))); > } > public int hashCode() > { > return ((habitatId =3D=3D null) ? 0 > : habitatId.hashCode()) ^ ((speciesId =3D=3D null) ? 0 > : speciesId.hashCode()); > } > public String toString() > { > return "habitatId[" + habitatId + "],speciesId[" + speciesId = + "]"; > } > } > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > @Override > public int hashCode() > { > final int prime =3D 31; > int result =3D 1; > result =3D prime * result + ((this.getHabitatId() =3D=3D null) ? 0 > : this.getHabitatId().hashCode()); > result =3D prime * result + ((this.getSpeciesId() =3D=3D null) ? 0 > : this.getSpeciesId().hashCode()); > return result; > } > @Override > public boolean equals(Object obj) > { > if (this =3D=3D obj) > return true; > if (obj =3D=3D null) > return false; > if (!(obj instanceof HabitatSpeciesLink)) > return false; > final HabitatSpeciesLink other =3D (HabitatSpeciesLink) obj; > if (this.getHabitatId() =3D=3D null) > { > if (other.getHabitatId() !=3D null) > return false; > } > else if (!this.getHabitatId().equals(other.getHabitatId())) > return false; > if (this.getSpeciesId() =3D=3D null) > { > if (other.getSpeciesId() !=3D null) > return false; > } > else if (!this.getSpeciesId().equals(other.getSpeciesId())) > return false; > return true; > } > } > This is the test code: > EntityManager entityManager =3D entityManagerFactory.createEntityManager(= ); > HabitatSpeciesLink.HabitatSpeciesLinkId id =3D new HabitatSpeciesLink.Hab= itatSpeciesLinkId(); > id.setHabitatId(new Long(123)); > id.setSpeciesId(new Long(234)); > HabitatSpeciesLink entity =3D entityManager.find(HabitatSpeciesLink.class= , id); > Assert.assertNotNull("should have entity with composite key", entity); > Here's the stacktrace: > javax.persistence.PersistenceException: org.hibernate.exception.SQLGramma= rException: could not load an entity: [org.permacode.HabitatSpeciesLink#com= ponent[habitatId,speciesId]{habitatId=3D123, speciesId=3D234}] > at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceExcepti= on(AbstractEntityManagerImpl.java:630) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:195) > at org.permacode.BugCompositeKeyTest.testCompositeKey(BugCompositeKeyT= est.java:181) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp= l.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc= essorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) > at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.= java:98) > at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79) > at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfter= s(MethodRoadie.java:87) > at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:7= 7) > at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) > at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit= 4ClassRunner.java:88) > at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4Class= Runner.java:51) > at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunne= r.java:44) > at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.j= ava:27) > at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.jav= a:37) > at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.= java:42) > at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUni= t4TestReference.java:38) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecuti= on.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:460) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:673) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTe= stRunner.java:386) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteT= estRunner.java:196) > Caused by: org.hibernate.exception.SQLGrammarException: could not load an= entity: [org.permacode.HabitatSpeciesLink#component[habitatId,speciesId]{h= abitatId=3D123, speciesId=3D234}] > at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter= .java:67) > at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHe= lper.java:43) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1865) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:48) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:42) > at org.hibernate.persister.entity.AbstractEntityPersister.load(Abstrac= tEntityPersister.java:2992) > at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource= (DefaultLoadEventListener.java:395) > at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoad= EventListener.java:375) > at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEv= entListener.java:139) > at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(Defaul= tLoadEventListener.java:195) > at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoad= EventListener.java:103) > at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:175) > ... 23 more > Caused by: java.sql.SQLException: Column 'HABITATSPE0_.HABITATID' is eith= er not in any table in the FROM list or appears within a join specification= and is outside the scope of the join specification or appears in a HAVING = clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE = statement then 'HABITATSPE0_.HABITATID' is not a column in the target tabl= e. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unkn= own Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Sour= ce) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLExcepti= on(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(= Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown = Source) > at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:497) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:415) > at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBa= tcher.java:139) > at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) > at org.hibernate.loader.Loader.doQuery(Loader.java:661) > at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(= Loader.java:224) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) > ... 35 more > Caused by: ERROR 42X04: Column 'HABITATSPE0_.HABITATID' is either not in = any table in the FROM list or appears within a join specification and is ou= tside the scope of the join specification or appears in a HAVING clause and= is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement= then 'HABITATSPE0_.HABITATID' is not a column in the target table. > at org.apache.derby.iapi.error.StandardException.newException(Unknown = Source) > at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Un= known Source) > at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(Unkno= wn Source) > at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknow= n Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Sou= rce) > at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown = Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Sourc= e) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.pre= pareInternalStatement(Unknown Source) > ... 48 more > I'm using Derby, Hypersonic, H2 or postgresql. It seems to be database-in= dependent. > This is the generated SQL: > select habitatspe0_.habitatId as habitatId0_0_, habitatspe0_.speciesId as= speciesId0_0_ from DEV.HABITAT_SPECIES_LINK habitatspe0_ where habitatspe0= _.habitatId=3D? and habitatspe0_.speciesId=3D? -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============7361643748638115638==-- From noreply at atlassian.com Wed Jan 13 12:53:30 2010 Content-Type: multipart/mixed; boundary="===============8617730160343136225==" MIME-Version: 1.0 From: Hardy Ferentschik (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Assigned: (HHH-4282) id class columns not honored when using orm.xml Date: Wed, 13 Jan 2010 11:53:29 -0600 Message-ID: <1178461915.2376.1263405209490.JavaMail.j2ee-opensource-projects@vps07.contegix.com> In-Reply-To: 110172607.1205341533988.JavaMail.j2ee@atlassian01.managed.contegix.com --===============8617730160343136225== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4282?p= age=3Dcom.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Hardy Ferentschik reassigned HHH-4282: -------------------------------------- Assignee: Hardy Ferentschik > id class columns not honored when using orm.xml > ----------------------------------------------- > > Key: HHH-4282 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/HHH-4282 > Project: Hibernate Core > Issue Type: Bug > Components: annotations > Reporter: Adam Hardy > Assignee: Hardy Ferentschik > Attachments: jpabug.zip > > > Hibernate EntityManager won't map an id-class for an entity. I have ust o= ne entity with an inner class as the idClass. > Hibernate refuses to load the entity, throwing the following exception (s= ee further down). > I am using hibernate-annotations-3.3.0ga and hibernate-entitymanager-3.3.= 1ga. > Mapping: > > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm http:/= /java.sun.com/xml/ns/persistence/orm_1_0.xsd" > version=3D"1.0"> > DEV > >
> class=3D"org.permacode.HabitatSpeciesLink$HabitatSpeciesLinkId" /> > > > > > > > > > > > This is the entity code: > public class HabitatSpeciesLink implements Serializable > { > private static final long serialVersionUID =3D -7079021236893433038L; > private Long habitatId; > private Long speciesId; > public static class HabitatSpeciesLinkId implements Serializable > { > //private static final long serialVersionUID =3D 6224703642788723= 112L; > private Long habitatId; > private Long speciesId; > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > public boolean equals(Object other) > { > if (other =3D=3D this) > return true; > if (!(other instanceof HabitatSpeciesLinkId)) > return false; > HabitatSpeciesLinkId mi =3D (HabitatSpeciesLinkId) other; > return (habitatId =3D=3D mi.habitatId || (habitatId !=3D null= && habitatId > .equals(mi.habitatId))) > && (speciesId =3D=3D mi.speciesId || (speciesId !=3D null= && speciesId > .equals(mi.speciesId))); > } > public int hashCode() > { > return ((habitatId =3D=3D null) ? 0 > : habitatId.hashCode()) ^ ((speciesId =3D=3D null) ? 0 > : speciesId.hashCode()); > } > public String toString() > { > return "habitatId[" + habitatId + "],speciesId[" + speciesId = + "]"; > } > } > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > @Override > public int hashCode() > { > final int prime =3D 31; > int result =3D 1; > result =3D prime * result + ((this.getHabitatId() =3D=3D null) ? 0 > : this.getHabitatId().hashCode()); > result =3D prime * result + ((this.getSpeciesId() =3D=3D null) ? 0 > : this.getSpeciesId().hashCode()); > return result; > } > @Override > public boolean equals(Object obj) > { > if (this =3D=3D obj) > return true; > if (obj =3D=3D null) > return false; > if (!(obj instanceof HabitatSpeciesLink)) > return false; > final HabitatSpeciesLink other =3D (HabitatSpeciesLink) obj; > if (this.getHabitatId() =3D=3D null) > { > if (other.getHabitatId() !=3D null) > return false; > } > else if (!this.getHabitatId().equals(other.getHabitatId())) > return false; > if (this.getSpeciesId() =3D=3D null) > { > if (other.getSpeciesId() !=3D null) > return false; > } > else if (!this.getSpeciesId().equals(other.getSpeciesId())) > return false; > return true; > } > } > This is the test code: > EntityManager entityManager =3D entityManagerFactory.createEntityManager(= ); > HabitatSpeciesLink.HabitatSpeciesLinkId id =3D new HabitatSpeciesLink.Hab= itatSpeciesLinkId(); > id.setHabitatId(new Long(123)); > id.setSpeciesId(new Long(234)); > HabitatSpeciesLink entity =3D entityManager.find(HabitatSpeciesLink.class= , id); > Assert.assertNotNull("should have entity with composite key", entity); > Here's the stacktrace: > javax.persistence.PersistenceException: org.hibernate.exception.SQLGramma= rException: could not load an entity: [org.permacode.HabitatSpeciesLink#com= ponent[habitatId,speciesId]{habitatId=3D123, speciesId=3D234}] > at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceExcepti= on(AbstractEntityManagerImpl.java:630) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:195) > at org.permacode.BugCompositeKeyTest.testCompositeKey(BugCompositeKeyT= est.java:181) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp= l.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc= essorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) > at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.= java:98) > at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79) > at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfter= s(MethodRoadie.java:87) > at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:7= 7) > at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) > at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit= 4ClassRunner.java:88) > at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4Class= Runner.java:51) > at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunne= r.java:44) > at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.j= ava:27) > at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.jav= a:37) > at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.= java:42) > at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUni= t4TestReference.java:38) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecuti= on.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:460) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:673) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTe= stRunner.java:386) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteT= estRunner.java:196) > Caused by: org.hibernate.exception.SQLGrammarException: could not load an= entity: [org.permacode.HabitatSpeciesLink#component[habitatId,speciesId]{h= abitatId=3D123, speciesId=3D234}] > at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter= .java:67) > at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHe= lper.java:43) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1865) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:48) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:42) > at org.hibernate.persister.entity.AbstractEntityPersister.load(Abstrac= tEntityPersister.java:2992) > at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource= (DefaultLoadEventListener.java:395) > at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoad= EventListener.java:375) > at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEv= entListener.java:139) > at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(Defaul= tLoadEventListener.java:195) > at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoad= EventListener.java:103) > at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:175) > ... 23 more > Caused by: java.sql.SQLException: Column 'HABITATSPE0_.HABITATID' is eith= er not in any table in the FROM list or appears within a join specification= and is outside the scope of the join specification or appears in a HAVING = clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE = statement then 'HABITATSPE0_.HABITATID' is not a column in the target tabl= e. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unkn= own Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Sour= ce) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLExcepti= on(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(= Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown = Source) > at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:497) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:415) > at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBa= tcher.java:139) > at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) > at org.hibernate.loader.Loader.doQuery(Loader.java:661) > at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(= Loader.java:224) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) > ... 35 more > Caused by: ERROR 42X04: Column 'HABITATSPE0_.HABITATID' is either not in = any table in the FROM list or appears within a join specification and is ou= tside the scope of the join specification or appears in a HAVING clause and= is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement= then 'HABITATSPE0_.HABITATID' is not a column in the target table. > at org.apache.derby.iapi.error.StandardException.newException(Unknown = Source) > at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Un= known Source) > at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(Unkno= wn Source) > at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknow= n Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Sou= rce) > at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown = Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Sourc= e) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.pre= pareInternalStatement(Unknown Source) > ... 48 more > I'm using Derby, Hypersonic, H2 or postgresql. It seems to be database-in= dependent. > This is the generated SQL: > select habitatspe0_.habitatId as habitatId0_0_, habitatspe0_.speciesId as= speciesId0_0_ from DEV.HABITAT_SPECIES_LINK habitatspe0_ where habitatspe0= _.habitatId=3D? and habitatspe0_.speciesId=3D? -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============8617730160343136225==-- From noreply at atlassian.com Wed Jan 13 13:07:36 2010 Content-Type: multipart/mixed; boundary="===============1814050297194856506==" MIME-Version: 1.0 From: Hardy Ferentschik (JIRA) To: hibernate-issues at lists.jboss.org Subject: [hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-4282) id class columns not honored when using orm.xml Date: Wed, 13 Jan 2010 12:07:35 -0600 Message-ID: <1953975171.2391.1263406055278.JavaMail.j2ee-opensource-projects@vps07.contegix.com> In-Reply-To: 110172607.1205341533988.JavaMail.j2ee@atlassian01.managed.contegix.com --===============1814050297194856506== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4282?p= age=3Dcom.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Hardy Ferentschik resolved HHH-4282. ------------------------------------ Resolution: Fixed Added provided test case to show that problem got fixed by HHH-4528 > id class columns not honored when using orm.xml > ----------------------------------------------- > > Key: HHH-4282 > URL: http://opensource.atlassian.com/projects/hibernate/b= rowse/HHH-4282 > Project: Hibernate Core > Issue Type: Bug > Components: annotations > Reporter: Adam Hardy > Assignee: Hardy Ferentschik > Attachments: jpabug.zip > > > Hibernate EntityManager won't map an id-class for an entity. I have ust o= ne entity with an inner class as the idClass. > Hibernate refuses to load the entity, throwing the following exception (s= ee further down). > I am using hibernate-annotations-3.3.0ga and hibernate-entitymanager-3.3.= 1ga. > Mapping: > > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm http:/= /java.sun.com/xml/ns/persistence/orm_1_0.xsd" > version=3D"1.0"> > DEV > >
> class=3D"org.permacode.HabitatSpeciesLink$HabitatSpeciesLinkId" /> > > > > > > > > > > > This is the entity code: > public class HabitatSpeciesLink implements Serializable > { > private static final long serialVersionUID =3D -7079021236893433038L; > private Long habitatId; > private Long speciesId; > public static class HabitatSpeciesLinkId implements Serializable > { > //private static final long serialVersionUID =3D 6224703642788723= 112L; > private Long habitatId; > private Long speciesId; > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > public boolean equals(Object other) > { > if (other =3D=3D this) > return true; > if (!(other instanceof HabitatSpeciesLinkId)) > return false; > HabitatSpeciesLinkId mi =3D (HabitatSpeciesLinkId) other; > return (habitatId =3D=3D mi.habitatId || (habitatId !=3D null= && habitatId > .equals(mi.habitatId))) > && (speciesId =3D=3D mi.speciesId || (speciesId !=3D null= && speciesId > .equals(mi.speciesId))); > } > public int hashCode() > { > return ((habitatId =3D=3D null) ? 0 > : habitatId.hashCode()) ^ ((speciesId =3D=3D null) ? 0 > : speciesId.hashCode()); > } > public String toString() > { > return "habitatId[" + habitatId + "],speciesId[" + speciesId = + "]"; > } > } > public Long getHabitatId() > { > return this.habitatId; > } > public void setHabitatId(Long newHabitatId) > { > this.habitatId =3D newHabitatId; > } > public Long getSpeciesId() > { > return this.speciesId; > } > public void setSpeciesId(Long newSpeciesId) > { > this.speciesId =3D newSpeciesId; > } > @Override > public int hashCode() > { > final int prime =3D 31; > int result =3D 1; > result =3D prime * result + ((this.getHabitatId() =3D=3D null) ? 0 > : this.getHabitatId().hashCode()); > result =3D prime * result + ((this.getSpeciesId() =3D=3D null) ? 0 > : this.getSpeciesId().hashCode()); > return result; > } > @Override > public boolean equals(Object obj) > { > if (this =3D=3D obj) > return true; > if (obj =3D=3D null) > return false; > if (!(obj instanceof HabitatSpeciesLink)) > return false; > final HabitatSpeciesLink other =3D (HabitatSpeciesLink) obj; > if (this.getHabitatId() =3D=3D null) > { > if (other.getHabitatId() !=3D null) > return false; > } > else if (!this.getHabitatId().equals(other.getHabitatId())) > return false; > if (this.getSpeciesId() =3D=3D null) > { > if (other.getSpeciesId() !=3D null) > return false; > } > else if (!this.getSpeciesId().equals(other.getSpeciesId())) > return false; > return true; > } > } > This is the test code: > EntityManager entityManager =3D entityManagerFactory.createEntityManager(= ); > HabitatSpeciesLink.HabitatSpeciesLinkId id =3D new HabitatSpeciesLink.Hab= itatSpeciesLinkId(); > id.setHabitatId(new Long(123)); > id.setSpeciesId(new Long(234)); > HabitatSpeciesLink entity =3D entityManager.find(HabitatSpeciesLink.class= , id); > Assert.assertNotNull("should have entity with composite key", entity); > Here's the stacktrace: > javax.persistence.PersistenceException: org.hibernate.exception.SQLGramma= rException: could not load an entity: [org.permacode.HabitatSpeciesLink#com= ponent[habitatId,speciesId]{habitatId=3D123, speciesId=3D234}] > at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceExcepti= on(AbstractEntityManagerImpl.java:630) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:195) > at org.permacode.BugCompositeKeyTest.testCompositeKey(BugCompositeKeyT= est.java:181) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImp= l.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc= essorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) > at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.= java:98) > at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79) > at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfter= s(MethodRoadie.java:87) > at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:7= 7) > at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42) > at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit= 4ClassRunner.java:88) > at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4Class= Runner.java:51) > at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunne= r.java:44) > at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.j= ava:27) > at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.jav= a:37) > at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.= java:42) > at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUni= t4TestReference.java:38) > at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecuti= on.java:38) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:460) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Rem= oteTestRunner.java:673) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTe= stRunner.java:386) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteT= estRunner.java:196) > Caused by: org.hibernate.exception.SQLGrammarException: could not load an= entity: [org.permacode.HabitatSpeciesLink#component[habitatId,speciesId]{h= abitatId=3D123, speciesId=3D234}] > at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter= .java:67) > at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHe= lper.java:43) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1865) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:48) > at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntit= yLoader.java:42) > at org.hibernate.persister.entity.AbstractEntityPersister.load(Abstrac= tEntityPersister.java:2992) > at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource= (DefaultLoadEventListener.java:395) > at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoad= EventListener.java:375) > at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEv= entListener.java:139) > at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(Defaul= tLoadEventListener.java:195) > at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoad= EventListener.java:103) > at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815) > at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808) > at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityMana= gerImpl.java:175) > ... 23 more > Caused by: java.sql.SQLException: Column 'HABITATSPE0_.HABITATID' is eith= er not in any table in the FROM list or appears within a join specification= and is outside the scope of the join specification or appears in a HAVING = clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE = statement then 'HABITATSPE0_.HABITATID' is not a column in the target tabl= e. > at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unkn= own Source) > at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Sour= ce) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLExcepti= on(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(= Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown = Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown = Source) > at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown So= urce) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown= Source) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:497) > at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBat= cher.java:415) > at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBa= tcher.java:139) > at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538) > at org.hibernate.loader.Loader.doQuery(Loader.java:661) > at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(= Loader.java:224) > at org.hibernate.loader.Loader.loadEntity(Loader.java:1851) > ... 35 more > Caused by: ERROR 42X04: Column 'HABITATSPE0_.HABITATID' is either not in = any table in the FROM list or appears within a join specification and is ou= tside the scope of the join specification or appears in a HAVING clause and= is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement= then 'HABITATSPE0_.HABITATID' is not a column in the target table. > at org.apache.derby.iapi.error.StandardException.newException(Unknown = Source) > at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Un= known Source) > at org.apache.derby.impl.sql.compile.ResultColumn.bindExpression(Unkno= wn Source) > at org.apache.derby.impl.sql.compile.ResultColumnList.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknow= n Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(= Unknown Source) > at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Sou= rce) > at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown = Source) > at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Sourc= e) > at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source) > at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.pre= pareInternalStatement(Unknown Source) > ... 48 more > I'm using Derby, Hypersonic, H2 or postgresql. It seems to be database-in= dependent. > This is the generated SQL: > select habitatspe0_.habitatId as habitatId0_0_, habitatspe0_.speciesId as= speciesId0_0_ from DEV.HABITAT_SPECIES_LINK habitatspe0_ where habitatspe0= _.habitatId=3D? and habitatspe0_.speciesId=3D? -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira =20 --===============1814050297194856506==--