I posted the original link on the general users list:
http://forum.hibernate.org/viewtopic.php?t=994901
My problem is: I can't access a <many-to-many> relationship. I get an error about no database being selected. The db is selected because I can execute other queries and I can even return the object with the <many-to-many>; problem occurs when I try to access the relationship.
There are more details in the other thread. I thought I could move it from Users to Tools but couldn't -
sorry for the cross post. Here is the error message:
Code:
DEBUG - GroupDAOImpl.findById(45) | In Group findById
DEBUG - AbstractBatcher.logOpenPreparedStatement(410) | about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - SQLStatementLogger.logStatement(111) | select this_.groupId as groupId5_1_, this_.companyId as companyId5_1_, this_.creatorUserId as creatorU3_5_1_, this_.classNameId as classNam4_5_1_, this_.classPK as classPK5_1_, this_.parentGroupId as parentGr6_5_1_, this_.liveGroupId as liveGrou7_5_1_, this_.name as name5_1_, this_.description as descript9_5_1_, this_.type_ as type10_5_1_, this_.typeSettings as typeSet11_5_1_, this_.friendlyURL as friendl12_5_1_, this_.active_ as active13_5_1_, roles2_.groupId as groupId3_, role3_.roleId as roleId3_, role3_.roleId as roleId9_0_, role3_.companyId as companyId9_0_, role3_.classNameId as classNam3_9_0_, role3_.classPK as classPK9_0_, role3_.name as name9_0_, role3_.description as descript6_9_0_, role3_.type_ as type7_9_0_ from flair.Group_ this_ left outer join GroupRole roles2_ on this_.groupId=roles2_.groupId left outer join flair.role_ role3_ on roles2_.roleId=role3_.roleId where this_.groupId=?
Hibernate: select this_.groupId as groupId5_1_, this_.companyId as companyId5_1_, this_.creatorUserId as creatorU3_5_1_, this_.classNameId as classNam4_5_1_, this_.classPK as classPK5_1_, this_.parentGroupId as parentGr6_5_1_, this_.liveGroupId as liveGrou7_5_1_, this_.name as name5_1_, this_.description as descript9_5_1_, this_.type_ as type10_5_1_, this_.typeSettings as typeSet11_5_1_, this_.friendlyURL as friendl12_5_1_, this_.active_ as active13_5_1_, roles2_.groupId as groupId3_, role3_.roleId as roleId3_, role3_.roleId as roleId9_0_, role3_.companyId as companyId9_0_, role3_.classNameId as classNam3_9_0_, role3_.classPK as classPK9_0_, role3_.name as name9_0_, role3_.description as descript6_9_0_, role3_.type_ as type7_9_0_ from flair.Group_ this_ left outer join GroupRole roles2_ on this_.groupId=roles2_.groupId left outer join flair.role_ role3_ on roles2_.roleId=role3_.roleId where this_.groupId=?
DEBUG - AbstractBatcher.logClosePreparedStatement(418) | about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - JDBCExceptionReporter.logExceptions(92) | could not execute query [select this_.groupId as groupId5_1_, this_.companyId as companyId5_1_, this_.creatorUserId as creatorU3_5_1_, this_.classNameId as classNam4_5_1_, this_.classPK as classPK5_1_, this_.parentGroupId as parentGr6_5_1_, this_.liveGroupId as liveGrou7_5_1_, this_.name as name5_1_, this_.description as descript9_5_1_, this_.type_ as type10_5_1_, this_.typeSettings as typeSet11_5_1_, this_.friendlyURL as friendl12_5_1_, this_.active_ as active13_5_1_, roles2_.groupId as groupId3_, role3_.roleId as roleId3_, role3_.roleId as roleId9_0_, role3_.companyId as companyId9_0_, role3_.classNameId as classNam3_9_0_, role3_.classPK as classPK9_0_, role3_.name as name9_0_, role3_.description as descript6_9_0_, role3_.type_ as type7_9_0_ from flair.Group_ this_ left outer join GroupRole roles2_ on this_.groupId=roles2_.groupId left outer join flair.role_ role3_ on roles2_.roleId=role3_.roleId where this_.groupId=?]
java.sql.SQLException: No database selected
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1596)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
at com.flair.dao.impl.GroupDAOImpl.findById(GroupDAOImpl.java:50)
at com.flair.service.impl.GroupManagerImpl.findById(GroupManagerImpl.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy5.findById(Unknown Source)
at com.flair.dao.RoleTestCase.testGroupRole(RoleTestCase.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
WARN - JDBCExceptionReporter.logExceptions(100) | SQL Error: 1046, SQLState: 3D000
ERROR - JDBCExceptionReporter.logExceptions(101) | No database selected
DEBUG - JDBCTransaction.rollback(186) | rollback
DEBUG - JDBCTransaction.toggleAutoCommit(227) | re-enabling autocommit
DEBUG - JDBCTransaction.rollback(197) | rolled back JDBC Connection
DEBUG - ConnectionManager.afterTransaction(325) | transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
DEBUG - ConnectionManager.closeConnection(464) | releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG - ConnectionManager.afterTransaction(325) | transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!