[Hibernate-JIRA] Created: (HHH-2258) Bad SQL Grammer: Implicit join when using r.fooClass.attributes[?]=?
by Darryl Miles (JIRA)
Bad SQL Grammer: Implicit join when using r.fooClass.attributes[?]=?
--------------------------------------------------------------------
Key: HHH-2258
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2258
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: MySQL server this has been tested with.
Reporter: Darryl Miles
Priority: Critical
Attachments: test_joinedmapfilter.zip
Please find this test case atteched to demonstrate the bug, maybe you can add to the hibernate distribution for future testing and piece of mind for me.
The error:
Testsuite: org.hibernate.test.joinedmapfilter.JoinedMapFilterTest
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.498 sec
Testcase: testJoinedMapFilter took 0.495 sec
Caused an ERROR
could not execute query
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.test.joinedmapfilter.JoinedMapFilterTest.testJoinedMapFilter(JoinedMapFilterTest.java:116)
at org.hibernate.test.TestCase.runTest(TestCase.java:250)
at org.hibernate.test.TestCase.runBare(TestCase.java:316)
Caused by: java.sql.SQLException: Unknown table 'productdet1_' in where clause
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1668)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
... 25 more
SELECT r FROM com.company.Toplevel AS r WHERE r.toplevel=? AND rec.productDetail.attributes[?]=?
Also my recent post: http://forum.hibernate.org/viewtopic.php?t=966374&start=0&postdays=0&post...
This testcase has been tested with 3.1.3 and 3.2.0-ga.
2nd problem:
There is also another situation in the testcase which I found through serendipity which causes a NPE inside hibernate because I misspelled "r" as "rec". Check out the commented out section and swap over the createQuery() lines to demonstrate that NPE.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
16 years, 2 months
[Hibernate-JIRA] Created: (HHH-3062) Incompleted Collection Returned from Joined Fetch
by Tony Lin (JIRA)
Incompleted Collection Returned from Joined Fetch
-------------------------------------------------
Key: HHH-3062
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3062
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.5
Environment: Windows XP SP2, JDK 1.6_03, MySQL 5, Toncat 5.5.25
Reporter: Tony Lin
Attachments: subsets.sql
Executing the following query:
select subset from com.alphait.domain.snomed.object.SubsetImpl as subset join fetch subset.members as members left join fetch members.parent
The members returned after the first subset are not complete, all but the first member are missing.
The classes are attached in HHH-3056. The test data is in the attached file, please load it to a mysql database.
After investigation, the problem seems be in Loader.java's sequentialLoad method:
try {
do {
Object loaded = getRowFromResultSet(
resultSet,
session,
queryParameters,
getLockModes( queryParameters.getLockModes() ),
null,
hydratedObjects,
loadedKeys,
returnProxies
);
if ( result == null ) {
result = loaded;
}
}
while ( keyToRead.equals( loadedKeys[0] ) && resultSet.next() );
}
catch ( SQLException sqle ) {
throw JDBCExceptionHelper.convert(
factory.getSQLExceptionConverter(),
sqle,
"could not perform sequential read of results (forward)",
getSQLString()
);
}
initializeEntitiesAndCollections(
hydratedObjects,
resultSet,
session,
queryParameters.isReadOnly()
);
session.getPersistenceContext().initializeNonLazyCollections();
return result;
It will fetch the next subset also, but only the first member, and the member's parent. These three are hydrated, and resolved when initializeEntitiesAndCollections is called.
This makes the members collection to be freezed, and no member can be added.
We put the following:
key = getKeyFromResultSet(
0,
persisters[0],
null,
resultSet,
session
);
if (!keyToRead.equals(key)) { // we are done, no moving forward
break;
}
before calling getRowFromResultSet(). This temporarily solved the problem for us.
Also this kind of query cannot have order by containing only the members' properties as it will return rows not ordered by Subset's ID. I think the HQL query parser should not permit this.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 2 months
[Hibernate-JIRA] Created: (HHH-3351) Dynamic entity model and inheritance - exception when trying to persist
by Adam Warski (JIRA)
Dynamic entity model and inheritance - exception when trying to persist
-----------------------------------------------------------------------
Key: HHH-3351
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Reporter: Adam Warski
I have two dynamic model entites mapped as follows:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class entity-name="Superclass" discriminator-value="A">
<id name="id" type="integer"><generator class="native"/></id>
<discriminator column="DISC" type="string" />
<property name="dataA" type="string"/>
<subclass entity-name="Subclass" discriminator-value="B">
<property name="dataB" type="string"/>
</subclass>
</class>
</hibernate-mapping>
When I try to persist one of them (just invoking session.persist("Superclass", new HashMap()); is enough) I get the following exception:
Exception in thread "main" org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: Superclass
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3640)
at org.jboss.envers.test.working.MyPersister.getSubclassEntityPersister(MyPersister.java:22)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1347)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:512)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:70)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
at org.jboss.envers.test.working.WorkingMain.main(WorkingMain.java:62)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 2 months
[Hibernate-JIRA] Created: (EJB-300) create-drop with c3p0 causes SQLException
by Chris Redekop (JIRA)
create-drop with c3p0 causes SQLException
-----------------------------------------
Key: EJB-300
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-300
Project: Hibernate Entity Manager
Issue Type: Bug
Components: EntityManager
Affects Versions: 3.2.1
Environment: hibernate-entitymanager 3.2.1.ga, c3p0 0.9.0, and postgreSQL 8.1.8 or hsqldb 1.8.7
Reporter: Chris Redekop
Attachments: c3p0Test.tar.gz
In the attached test application, an EntityManagerFactory is created and then closed.
Closing the EMF causes line 801 of org.hibernate.impl.SessionFactoryImpl to call getConnectionProvider().close(), which eventually results in c3p0's PooledDataSource being closed.
Line 808 of org.hibernate.impl.SessionFactoryImpl the calls schemaExport.drop(), which attempts to acquire a connection from the data source and causes the following SQLException.
java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@fced4 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@9505f [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 9505f, idleConnectionTestPeriod -> 100, initialPoolSize -> 10, maxIdleTime -> 100, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@80cac9 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 80cac9, jdbcUrl -> jdbc:hsqldb:., properties -> {user=******, password=******, autocommit=true, release_mode=auto} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> fced4, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
This exception is swallowed so it does not cause a test error, but it does appear in the console output.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
16 years, 2 months