[Hibernate-JIRA] Created: (HHH-2248) support for deferred constraint (in delete action)
by Tomasz Bech (JIRA)
support for deferred constraint (in delete action)
--------------------------------------------------
Key: HHH-2248
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2248
Project: Hibernate3
Type: Improvement
Components: core
Versions: 3.2.0.ga
Reporter: Tomasz Bech
Currently Hibernate does not have support for deferred constraints.
In good design usage of deferred constraints can be avoided, but the module which we work on, recieves the data/records/transactions
from other system - and it doesn't keep the proper order of the records in the transaction.
(the problem is also described under: http://forum.hibernate.org/viewtopic.php?t=965663)
Scenario:
Object A has reference to B (unidirectional).
'Normal' delete scenario:
delete A
delete B
The proper order of deleting and all is ok.
Problematic scenario is (one transaction):
delete B
delete A
Of course after first delete (B), database throws an 'foreign' key constraint.
It is easily solvable using deferred contraints - on DB level (Informix/Oracle, etc).
But now Hibernate does a check and throws 'not-null property references a null or transient value'
(in this case B is transient during delete of A).
Looks to me that Hibernate checks to strictly.
Lets analyze this code:
(DefaultDeleteEventListener.java)
protected final void deleteEntity(
final EventSource session,
final Object entity,
final EntityEntry entityEntry,
final boolean isCascadeDeleteEnabled,
final EntityPersister persister)
throws HibernateException {
....
session.getInterceptor().onDelete(
entity,
entityEntry.getId(),
deletedState,
persister.getPropertyNames(),
propTypes
);
// before any callbacks, etc, so subdeletions see that this deletion happened first
persistenceContext.setEntryStatus(entityEntry, Status.DELETED);
EntityKey key = new EntityKey( entityEntry.getId(), persister, session.getEntityMode() );
cascadeBeforeDelete(session, persister, entity, entityEntry);
new ForeignKeys.Nullifier(entity, true, false, session)
.nullifyTransientReferences( entityEntry.getDeletedState(), propTypes );
new Nullability(session).checkNullability( entityEntry.getDeletedState(), persister, true );
...
The last three lines does the check which throws an error.
I don't see the reason of this check here - object is just being deleted, so it doesn't matter that some of its
properties is null or transient.
After commenting the code:
// new ForeignKeys.Nullifier(entity, true, false, session)
// .nullifyTransientReferences( entityEntry.getDeletedState(), propTypes );
// new Nullability(session).checkNullability( entityEntry.getDeletedState(), persister, true );
the scenario with deferred constraints works properly. Also any side effects wasn't observed.
If it isn't fully correct change, let me know how to improve it.
--
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
19 years, 5 months
[Hibernate-JIRA] Created: (HHH-2247) Finder method giving : ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
by Gibu George (JIRA)
Finder method giving : ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
--------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2247
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2247
Project: Hibernate3
Type: Bug
Environment: Hibernate 3.2, Oracle
Reporter: Gibu George
The scenario is like I have a page where I can create a new entity, the first time when I create the entity it works fine with a particular code which is a Unique key on the table, then I tried to create a new entity with a different code that also worked fine. But when I tried to change the code of second entity to the same as that of the first one, in my *validate method* which tries to *find* whether there any enitity with such a code, it gives the follwoing stack trace. This is happening before the save is called also if I try to refresh the page after the error occurs it works fine and gives a proper validation failed message.
ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
--
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
19 years, 5 months
[Hibernate-JIRA] Resolved: (HHH-939) 'class' property in HQL results in incorrect SQL for joined-subclass
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-939?page=all ]
Steve Ebersole resolved HHH-939:
--------------------------------
Resolution: Fixed
trunk / 3.2
> 'class' property in HQL results in incorrect SQL for joined-subclass
> --------------------------------------------------------------------
>
> Key: HHH-939
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-939
> Project: Hibernate3
> Type: Bug
> Components: query-hql
> Versions: 3.1 beta 2
> Environment: H3.1b2, Oracle
> Reporter: Den Raskovalov
> Assignee: Steve Ebersole
> Fix For: 3.2.1
>
>
> select count(distinct obj.BO) from ru.naumen.core.indexer.CoreBOTitleIndexerSubstring as obj where obj.BO.class=ru.naumen.core.bobjects.person.CoreEmployee
> produces
> select count(distinct corebotitl0_.bo_) as col_0_0_ from TBL_BOTitleIndexerSS corebotitl0_, TBL_BO corebo1_ where corebotitl0_.bo_=corebo1_.UUID and upper(corebotitl0_.substring_)=upper(?) and decode(corebo1_.UUID, corebo1_10_.NCCP_UUID, 10, corebo1_18_.JC_ContactPerson_UUID, 18, corebo1_3_.SuperPerson_UUID, 3, corebo1_4_.Employee_UUID, 4, corebo1_8_.ContactPerson_UUID, 8, corebo1_11_.JuridicalClient_UUID, 11, corebo1_12_.NaturalClient_UUID, 12, corebo1_15_.AdditionalAgreement_UUID, 15, corebo1_27_.Project_UUID, 27, corebo1_1_.Root_UUID, 1, corebo1_2_.Person_UUID, 2, corebo1_5_.OU_UUID, 5, corebo1_6_.DBFile_UUID, 6, corebo1_7_.ClientCatalog_UUID, 7, corebo1_9_.Client_UUID, 9, corebo1_13_.Deal_UUID, 13, corebo1_14_.Contract_UUID, 14, corebo1_16_.Penalty_UUID, 16, corebo1_17_.Payment_UUID, 17, corebo1_19_.Agent_UUID, 19, corebo1_20_.Agent_Cat_UUID, 20, corebo1_21_.PaymentAct_UUID, 21, corebo1_22_.PaymentActComment_UUID, 22, corebo1_23_.PaymentActPaym_UUID, 23, corebo1_24_.MiniOffice_UUID, 24, corebo1_25_.MiniOffice_Cat_UUID, 25, corebo1_26_.Project_UUID, 26, corebo1_28_.Task_UUID, 28, 0)=4
> certainly,
> select distinct obj.BO from ru.naumen.core.indexer.CoreBOTitleIndexerSubstring as obj where obj.BO.class=ru.naumen.core.bobjects.person.CoreEmployee
> works fine
--
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
19 years, 5 months
[Hibernate-JIRA] Resolved: (HHH-1631) Missing table in SQL from clause that is referenced in where clause when using joined subclass
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1631?page=all ]
Steve Ebersole resolved HHH-1631:
---------------------------------
Resolution: Fixed
trunk / 3.2
> Missing table in SQL from clause that is referenced in where clause when using joined subclass
> ----------------------------------------------------------------------------------------------
>
> Key: HHH-1631
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1631
> Project: Hibernate3
> Type: Bug
> Components: query-hql
> Versions: 3.1.3
> Environment: Hibernate 3.1.3
> Annotations 3.1 beta 8
> Postgresql 8.1.3
> Reporter: Pat Double
> Assignee: Steve Ebersole
> Fix For: 3.2.1
> Attachments: BrokenHibernateDowncast.java
>
>
> I have an HQL statement that is missing a join clause in the generated SQL. The entity is using a hierarchy with joined subclass. I am using annotations to define the mapping. I want to query based on a subclass property, so hibernate has to do a "downcast" of some sort. Here's the HQL:
>
> select pound.location.state from "+Pound.class.getName()+" as pound inner join pound.cats as cat where pound.location.name='Anytown' and cat.meanness > 5
>
> This works fine if I do not have the select clause, when I add the select clause it fails and removes the join for the subclass "Bobcat", which has the property "meanness". I have included a full test case including configuration.
>
> This looks related to the recently fixed bug HHH-1248. It could also be related to HHH-940, but I'm not sure.
>
> 06-03-22 15:05:24,467 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42P01
> 2006-03-22 15:05:24,469 ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: missing FROM-clause entry for table "brokenhibe2_2_"
> Exception in thread "main" 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:2148)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
> at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at com.i2rd.occasio.test.BrokenHibernateDowncast.main(BrokenHibernateDowncast.java:179)
> Caused by: org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "brokenhibe2_2_"
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:437)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:257)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> 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:2145)
> ... 8 more
> 06-03-22 15:05:24,467 WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42P01
> 2006-03-22 15:05:24,469 ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: missing FROM-clause entry for table "brokenhibe2_2_"
> Exception in thread "main" 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:2148)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
> at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at com.i2rd.occasio.test.BrokenHibernateDowncast.main(BrokenHibernateDowncast.java:179)
> Caused by: org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "brokenhibe2_2_"
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:437)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:257)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> 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:2145)
> ... 8 more
> select
> brokenhibe3_.state as col_0_0_
> from
> pound brokenhibe0_
> inner join
> pound_cat cats1_
> on brokenhibe0_.id=cats1_.pound_id
> inner join
> cat brokenhibe2_
> on cats1_.cats_id=brokenhibe2_.id,
> city brokenhibe3_
> where
> brokenhibe0_.location_id=brokenhibe3_.id
> and brokenhibe3_.name='Anytown'
> and brokenhibe2_2_.meanness>5
>
>
> 2006-03-22 15:18:18,127 DEBUG [null main] query.QueryPlanCache (QueryPlanCache.java:69) - unable to locate HQL query plan in cache; generating (select pound.location.state from com.i2rd.occasio.test.BrokenHibernateDowncast$Pound as pound inner join pound.cats as cat where pound.location.name='Anytown' and cat.meanness > 5)
> 2006-03-22 15:18:18,129 DEBUG [null main] ast.QueryTranslatorImpl (QueryTranslatorImpl.java:236) - parse() - HQL: select pound.location.state from com.i2rd.occasio.test.BrokenHibernateDowncast$Pound as pound inner join pound.cats as cat where pound.location.name='Anytown' and cat.meanness > 5
> 2006-03-22 15:18:18,140 DEBUG [null main] ast.QueryTranslatorImpl (QueryTranslatorImpl.java:252) - --- HQL AST ---
> \-[QUERY] 'query'
> +-[SELECT_FROM] 'SELECT_FROM'
> | +-[FROM] 'from'
> | | +-[RANGE] 'RANGE'
> | | | +-[DOT] '.'
> | | | | +-[DOT] '.'
> | | | | | +-[DOT] '.'
> | | | | | | +-[DOT] '.'
> | | | | | | | +-[IDENT] 'com'
> | | | | | | | \-[IDENT] 'i2rd'
> | | | | | | \-[IDENT] 'occasio'
> | | | | | \-[IDENT] 'test'
> | | | | \-[IDENT] 'BrokenHibernateDowncast$Pound'
> | | | \-[ALIAS] 'pound'
> | | \-[JOIN] 'join'
> | | +-[INNER] 'inner'
> | | +-[DOT] '.'
> | | | +-[IDENT] 'pound'
> | | | \-[IDENT] 'cats'
> | | \-[ALIAS] 'cat'
> | \-[SELECT] 'select'
> | \-[DOT] '.'
> | +-[DOT] '.'
> | | +-[IDENT] 'pound'
> | | \-[IDENT] 'location'
> | \-[IDENT] 'state'
> \-[WHERE] 'where'
> \-[AND] 'and'
> +-[EQ] '='
> | +-[DOT] '.'
> | | +-[DOT] '.'
> | | | +-[IDENT] 'pound'
> | | | \-[IDENT] 'location'
> | | \-[IDENT] 'name'
> | \-[QUOTED_STRING] ''Anytown''
> \-[GT] '>'
> +-[DOT] '.'
> | +-[IDENT] 'cat'
> | \-[IDENT] 'meanness'
> \-[NUM_INT] '5'
>
> 2006-03-22 15:18:18,143 DEBUG [null main] ast.ErrorCounter (ErrorCounter.java:68) - throwQueryException() : no errors
> 2006-03-22 15:18:18,143 DEBUG [null main] antlr.HqlSqlBaseWalker (HqlSqlBaseWalker.java:111) - select << begin [level=1, statement=select]
> 2006-03-22 15:18:18,152 DEBUG [null main] tree.FromElement (FromElement.java:104) - FromClause{level=1} : com.i2rd.occasio.test.BrokenHibernateDowncast$Pound (pound) -> brokenhibe0_
> 2006-03-22 15:18:18,153 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound -> brokenhibe0_.id
> 2006-03-22 15:18:18,155 DEBUG [null main] tree.DotNode (DotNode.java:541) - getDataType() : cats -> org.hibernate.type.SetType(com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.cats)
> 2006-03-22 15:18:18,156 DEBUG [null main] tree.FromElementFactory (FromElementFactory.java:368) - createManyToMany() : path = pound.cats role = com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.cats associatedEntityName = com.i2rd.occasio.test.BrokenHibernateDowncast$Cat
> 2006-03-22 15:18:18,156 DEBUG [null main] tree.FromElement (FromElement.java:104) - FromClause{level=1} : com.i2rd.occasio.test.BrokenHibernateDowncast$Cat (cat) -> brokenhibe2_
> 2006-03-22 15:18:18,157 DEBUG [null main] tree.FromClause (FromClause.java:218) - addJoinByPathMap() : pound.cats -> cat brokenhibe2_
> 2006-03-22 15:18:18,158 DEBUG [null main] tree.DotNode (DotNode.java:265) - dereferenceCollection() : Created new FROM element for pound.cats : pound_cat brokenhibe2_
> 2006-03-22 15:18:18,158 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound.cats -> .
> 2006-03-22 15:18:18,164 DEBUG [null main] ast.HqlSqlWalker (HqlSqlWalker.java:327) - createFromJoinElement() : -- join tree --
> \-[JOIN_FRAGMENT] FromElement: 'pound_cat brokenhibe2_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=cat,role=com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.cats,tableName=cat,tableAlias=brokenhibe2_,origin=pound brokenhibe0_,colums={brokenhibe0_.id ,className=com.i2rd.occasio.test.BrokenHibernateDowncast$Cat}}
>
> 2006-03-22 15:18:18,165 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound -> brokenhibe0_.id
> 2006-03-22 15:18:18,168 DEBUG [null main] tree.DotNode (DotNode.java:541) - getDataType() : location -> org.hibernate.type.ManyToOneType(com.i2rd.occasio.test.BrokenHibernateDowncast$City)
> 2006-03-22 15:18:18,169 DEBUG [null main] tree.DotNode (DotNode.java:348) - dereferenceEntityJoin() : generating join for location in com.i2rd.occasio.test.BrokenHibernateDowncast$Pound {no alias} parent = [ ( . ( . brokenhibe0_.id location ) state ) ]
> 2006-03-22 15:18:18,169 DEBUG [null main] tree.FromElement (FromElement.java:104) - FromClause{level=1} : com.i2rd.occasio.test.BrokenHibernateDowncast$City (no alias) -> brokenhibe3_
> 2006-03-22 15:18:18,170 DEBUG [null main] tree.FromClause (FromClause.java:218) - addJoinByPathMap() : pound.location -> city brokenhibe3_
> 2006-03-22 15:18:18,170 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound.location -> brokenhibe0_.location_id
> 2006-03-22 15:18:18,171 DEBUG [null main] tree.DotNode (DotNode.java:541) - getDataType() : state -> org.hibernate.type.StringType@ea3932
> 2006-03-22 15:18:18,172 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound.location.state -> brokenhibe3_.state
> 2006-03-22 15:18:18,173 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound -> brokenhibe0_.id
> 2006-03-22 15:18:18,174 DEBUG [null main] tree.DotNode (DotNode.java:541) - getDataType() : location -> org.hibernate.type.ManyToOneType(com.i2rd.occasio.test.BrokenHibernateDowncast$City)
> 2006-03-22 15:18:18,174 DEBUG [null main] tree.DotNode (DotNode.java:348) - dereferenceEntityJoin() : generating join for location in com.i2rd.occasio.test.BrokenHibernateDowncast$Pound {no alias} parent = [ ( . ( . brokenhibe0_.id location ) name ) ]
> 2006-03-22 15:18:18,175 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound.location -> brokenhibe0_.location_id
> 2006-03-22 15:18:18,176 DEBUG [null main] tree.DotNode (DotNode.java:541) - getDataType() : name -> org.hibernate.type.StringType@ea3932
> 2006-03-22 15:18:18,176 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : pound.location.name -> brokenhibe3_.name
> 2006-03-22 15:18:18,177 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : cat -> brokenhibe2_.id
> 2006-03-22 15:18:18,178 DEBUG [null main] tree.DotNode (DotNode.java:541) - getDataType() : meanness -> org.hibernate.type.IntegerType@170ec24
> 2006-03-22 15:18:18,180 DEBUG [null main] tree.FromReferenceNode (FromReferenceNode.java:51) - Resolved : cat.meanness -> brokenhibe2_2_.meanness
> 2006-03-22 15:18:18,180 DEBUG [null main] antlr.HqlSqlBaseWalker (HqlSqlBaseWalker.java:117) - select : finishing up [level=1, statement=select]
> 2006-03-22 15:18:18,181 DEBUG [null main] ast.HqlSqlWalker (HqlSqlWalker.java:511) - processQuery() : ( SELECT ( {select clause} ( brokenhibe3_.state ( brokenhibe0_.location_id brokenhibe0_.id location ) state ) ) ( FromClause{level=1} ( pound brokenhibe0_ pound_cat brokenhibe2_ city brokenhibe3_ ) ) ( where ( and ( = ( brokenhibe3_.name ( brokenhibe0_.location_id brokenhibe0_.id location ) name ) 'Anytown' ) ( > ( brokenhibe2_2_.meanness brokenhibe2_.id meanness ) 5 ) ) ) )
> 2006-03-22 15:18:18,186 DEBUG [null main] util.SyntheticAndFactory (SyntheticAndFactory.java:58) - Using WHERE fragment [brokenhibe0_.location_id=brokenhibe3_.id]
> 2006-03-22 15:18:18,186 DEBUG [null main] util.JoinProcessor (JoinProcessor.java:128) - Using FROM fragment [inner join pound_cat cats1_ on brokenhibe0_.id=cats1_.pound_id inner join cat brokenhibe2_ on cats1_.cats_id=brokenhibe2_.id]
> 2006-03-22 15:18:18,187 DEBUG [null main] util.JoinProcessor (JoinProcessor.java:128) - Using FROM fragment [pound brokenhibe0_]
> 2006-03-22 15:18:18,187 DEBUG [null main] antlr.HqlSqlBaseWalker (HqlSqlBaseWalker.java:123) - select >> end [level=1, statement=select]
> 2006-03-22 15:18:18,193 DEBUG [null main] ast.QueryTranslatorImpl (QueryTranslatorImpl.java:222) - --- SQL AST ---
> \-[SELECT] QueryNode: 'SELECT' querySpaces (pound_cat,pound,cat,city)
> +-[SELECT_CLAUSE] SelectClause: '{select clause}'
> | +-[DOT] DotNode: 'brokenhibe3_.state' {propertyName=state,dereferenceType=4,propertyPath=state,path=pound.location.state,tableAlias=brokenhibe3_,className=com.i2rd.occasio.test.BrokenHibernateDowncast$City,classAlias=null}
> | | +-[DOT] DotNode: 'brokenhibe0_.location_id' {propertyName=location,dereferenceType=1,propertyPath=location,path=pound.location,tableAlias=brokenhibe3_,className=com.i2rd.occasio.test.BrokenHibernateDowncast$City,classAlias=null}
> | | | +-[ALIAS_REF] IdentNode: 'brokenhibe0_.id' {alias=pound, className=com.i2rd.occasio.test.BrokenHibernateDowncast$Pound, tableAlias=brokenhibe0_}
> | | | \-[IDENT] IdentNode: 'location' {originalText=location}
> | | \-[IDENT] IdentNode: 'state' {originalText=state}
> | \-[SELECT_COLUMNS] SqlNode: ' as col_0_0_'
> +-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=3, fromElements=3, fromElementByClassAlias=[pound, cat, null], fromElementByTableAlias=[brokenhibe3_, brokenhibe0_, brokenhibe2_], fromElementsByPath=[pound.cats, pound.location], collectionJoinFromElementsByPath=[], impliedElements=[]}
> | \-[FROM_FRAGMENT] FromElement: 'pound brokenhibe0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=pound,role=null,tableName=pound,tableAlias=brokenhibe0_,origin=null,colums={,className=com.i2rd.occasio.test.BrokenHibernateDowncast$Pound}}
> | +-[JOIN_FRAGMENT] FromElement: 'inner join pound_cat cats1_ on brokenhibe0_.id=cats1_.pound_id inner join cat brokenhibe2_ on cats1_.cats_id=brokenhibe2_.id' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=cat,role=com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.cats,tableName=cat,tableAlias=brokenhibe2_,origin=pound brokenhibe0_,colums={brokenhibe0_.id ,className=com.i2rd.occasio.test.BrokenHibernateDowncast$Cat}}
> | \-[FROM_FRAGMENT] ImpliedFromElement: 'city brokenhibe3_' ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=city,tableAlias=brokenhibe3_,origin=pound brokenhibe0_,colums={brokenhibe0_.location_id ,className=com.i2rd.occasio.test.BrokenHibernateDowncast$City}}
> \-[WHERE] SqlNode: 'where'
> +-[THETA_JOINS] SqlNode: '{theta joins}'
> | \-[SQL_TOKEN] SqlFragment: 'brokenhibe0_.location_id=brokenhibe3_.id'
> \-[AND] SqlNode: 'and'
> +-[EQ] BinaryLogicOperatorNode: '='
> | +-[DOT] DotNode: 'brokenhibe3_.name' {propertyName=name,dereferenceType=4,propertyPath=name,path=pound.location.name,tableAlias=brokenhibe3_,className=com.i2rd.occasio.test.BrokenHibernateDowncast$City,classAlias=null}
> | | +-[DOT] DotNode: 'brokenhibe0_.location_id' {propertyName=location,dereferenceType=1,propertyPath=location,path=pound.location,tableAlias=brokenhibe3_,className=com.i2rd.occasio.test.BrokenHibernateDowncast$City,classAlias=null}
> | | | +-[ALIAS_REF] IdentNode: 'brokenhibe0_.id' {alias=pound, className=com.i2rd.occasio.test.BrokenHibernateDowncast$Pound, tableAlias=brokenhibe0_}
> | | | \-[IDENT] IdentNode: 'location' {originalText=location}
> | | \-[IDENT] IdentNode: 'name' {originalText=name}
> | \-[QUOTED_STRING] LiteralNode: ''Anytown''
> \-[GT] BinaryLogicOperatorNode: '>'
> +-[DOT] DotNode: 'brokenhibe2_2_.meanness' {propertyName=meanness,dereferenceType=4,propertyPath=meanness,path=cat.meanness,tableAlias=brokenhibe2_,className=com.i2rd.occasio.test.BrokenHibernateDowncast$Cat,classAlias=cat}
> | +-[ALIAS_REF] IdentNode: 'brokenhibe2_.id' {alias=cat, className=com.i2rd.occasio.test.BrokenHibernateDowncast$Cat, tableAlias=brokenhibe2_}
> | \-[IDENT] IdentNode: 'meanness' {originalText=meanness}
> \-[NUM_INT] LiteralNode: '5'
>
> 2006-03-22 15:18:18,197 DEBUG [null main] ast.ErrorCounter (ErrorCounter.java:68) - throwQueryException() : no errors
> 2006-03-22 15:18:18,198 DEBUG [null main] ast.QueryTranslatorImpl (QueryTranslatorImpl.java:206) - HQL: select pound.location.state from com.i2rd.occasio.test.BrokenHibernateDowncast$Pound as pound inner join pound.cats as cat where pound.location.name='Anytown' and cat.meanness > 5
> 2006-03-22 15:18:18,198 DEBUG [null main] ast.QueryTranslatorImpl (QueryTranslatorImpl.java:207) - SQL: select brokenhibe3_.state as col_0_0_ from pound brokenhibe0_ inner join pound_cat cats1_ on brokenhibe0_.id=cats1_.pound_id inner join cat brokenhibe2_ on cats1_.cats_id=brokenhibe2_.id, city brokenhibe3_ where brokenhibe0_.location_id=brokenhibe3_.id and brokenhibe3_.name='Anytown' and brokenhibe2_2_.meanness>5
> 2006-03-22 15:18:18,199 DEBUG [null main] ast.ErrorCounter (ErrorCounter.java:68) - throwQueryException() : no errors
> 2006-03-22 15:18:18,200 DEBUG [null main] query.HQLQueryPlan (HQLQueryPlan.java:219) - HQL param location recognition took 0 mills (select pound.location.state from com.i2rd.occasio.test.BrokenHibernateDowncast$Pound as pound inner join pound.cats as cat where pound.location.name='Anytown' and cat.meanness > 5)
> 2006-03-22 15:18:18,201 DEBUG [null main] query.QueryPlanCache (QueryPlanCache.java:75) - located HQL query plan in cache (select pound.location.state from com.i2rd.occasio.test.BrokenHibernateDowncast$Pound as pound inner join pound.cats as cat where pound.location.name='Anytown' and cat.meanness > 5)
> 2006-03-22 15:18:18,202 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:58) - flushing session
> 2006-03-22 15:18:18,202 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:111) - processing flush-time cascades
> 2006-03-22 15:18:18,202 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:153) - dirty checking collections
> 2006-03-22 15:18:18,203 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:170) - Flushing entities and processing referenced collections
> 2006-03-22 15:18:18,204 DEBUG [null main] engine.Collections (Collections.java:176) - Collection found: [com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.cats#1], was: [com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.cats#1] (initialized)
> 2006-03-22 15:18:18,204 DEBUG [null main] engine.Collections (Collections.java:176) - Collection found: [com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.dogs#1], was: [com.i2rd.occasio.test.BrokenHibernateDowncast$Pound.dogs#1] (initialized)
> 2006-03-22 15:18:18,205 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:209) - Processing unreferenced collections
> 2006-03-22 15:18:18,206 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:223) - Scheduling collection removes/(re)creates/updates
> 2006-03-22 15:18:18,207 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:85) - Flushed: 0 insertions, 0 updates, 0 deletions to 6 objects
> 2006-03-22 15:18:18,207 DEBUG [null main] def.AbstractFlushingEventListener (AbstractFlushingEventListener.java:91) - Flushed: 0 (re)creations, 0 updates, 0 removals to 2 collections
> 2006-03-22 15:18:18,208 DEBUG [null main] pretty.Printer (Printer.java:83) - listing entities:
> 2006-03-22 15:18:18,209 DEBUG [null main] pretty.Printer (Printer.java:90) - com.i2rd.occasio.test.BrokenHibernateDowncast$Pound{cats=[com.i2rd.occasio.test.BrokenHibernateDowncast$Cat#2, com.i2rd.occasio.test.BrokenHibernateDowncast$Cat#1], dogs=[com.i2rd.occasio.test.BrokenHibernateDowncast$Dog#2, com.i2rd.occasio.test.BrokenHibernateDowncast$Dog#1], location=com.i2rd.occasio.test.BrokenHibernateDowncast$City#1, id=1}
> 2006-03-22 15:18:18,209 DEBUG [null main] pretty.Printer (Printer.java:90) - com.i2rd.occasio.test.BrokenHibernateDowncast$LargeDog{largeness=100, name=max, id=2}
> 2006-03-22 15:18:18,210 DEBUG [null main] pretty.Printer (Printer.java:90) - com.i2rd.occasio.test.BrokenHibernateDowncast$DomesticCat{region=Midwest USA, name=charley, id=1}
> 2006-03-22 15:18:18,210 DEBUG [null main] pretty.Printer (Printer.java:90) - com.i2rd.occasio.test.BrokenHibernateDowncast$Bobcat{meanness=10, name=bobby, id=2}
> 2006-03-22 15:18:18,211 DEBUG [null main] pretty.Printer (Printer.java:90) - com.i2rd.occasio.test.BrokenHibernateDowncast$ToyDog{tinyness=1, name=fifi, id=1}
> 2006-03-22 15:18:18,211 DEBUG [null main] pretty.Printer (Printer.java:90) - com.i2rd.occasio.test.BrokenHibernateDowncast$City{state=NE, name=Anytown, id=1}
> 2006-03-22 15:18:18,211 DEBUG [null main] def.DefaultAutoFlushEventListener (DefaultAutoFlushEventListener.java:53) - Dont need to execute flush
> 2006-03-22 15:18:18,212 DEBUG [null main] query.HQLQueryPlan (HQLQueryPlan.java:148) - find: select pound.location.state from com.i2rd.occasio.test.BrokenHibernateDowncast$Pound as pound inner join pound.cats as cat where pound.location.name='Anytown' and cat.meanness > 5
> 2006-03-22 15:18:18,212 DEBUG [null main] engine.QueryParameters (QueryParameters.java:262) - named parameters: {}
> 2006-03-22 15:18:18,212 DEBUG [null main] jdbc.AbstractBatcher (AbstractBatcher.java:311) - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
> 2006-03-22 15:18:18,214 DEBUG [null main] jdbc.AbstractBatcher (AbstractBatcher.java:346) -
> select
> brokenhibe3_.state as col_0_0_
> from
> pound brokenhibe0_
> inner join
> pound_cat cats1_
> on brokenhibe0_.id=cats1_.pound_id
> inner join
> cat brokenhibe2_
> on cats1_.cats_id=brokenhibe2_.id,
> city brokenhibe3_
> where
> brokenhibe0_.location_id=brokenhibe3_.id
> and brokenhibe3_.name='Anytown'
> and brokenhibe2_2_.meanness>5
> Hibernate:
> select
> brokenhibe3_.state as col_0_0_
> from
> pound brokenhibe0_
> inner join
> pound_cat cats1_
> on brokenhibe0_.id=cats1_.pound_id
> inner join
> cat brokenhibe2_
> on cats1_.cats_id=brokenhibe2_.id,
> city brokenhibe3_
> where
> brokenhibe0_.location_id=brokenhibe3_.id
> and brokenhibe3_.name='Anytown'
> and brokenhibe2_2_.meanness>5
> 2006-03-22 15:18:18,215 DEBUG [null main] jdbc.AbstractBatcher (AbstractBatcher.java:424) - preparing statement
> 2006-03-22 15:18:18,237 DEBUG [null main] jdbc.AbstractBatcher (AbstractBatcher.java:319) - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
> 2006-03-22 15:18:18,239 DEBUG [null main] jdbc.AbstractBatcher (AbstractBatcher.java:470) - closing statement
> 2006-03-22 15:18:18,252 DEBUG [null main] util.JDBCExceptionReporter (JDBCExceptionReporter.java:63) - could not execute query [select brokenhibe3_.state as col_0_0_ from pound brokenhibe0_ inner join pound_cat cats1_ on brokenhibe0_.id=cats1_.pound_id inner join cat brokenhibe2_ on cats1_.cats_id=brokenhibe2_.id, city brokenhibe3_ where brokenhibe0_.location_id=brokenhibe3_.id and brokenhibe3_.name='Anytown' and brokenhibe2_2_.meanness>5]
> org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "brokenhibe2_2_"
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:437)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:257)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> 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:2145)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
> at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at com.i2rd.occasio.test.BrokenHibernateDowncast.main(BrokenHibernateDowncast.java:181)
> 2006-03-22 15:18:18,253 WARN [null main] util.JDBCExceptionReporter (JDBCExceptionReporter.java:71) - SQL Error: 0, SQLState: 42P01
> 2006-03-22 15:18:18,254 ERROR [null main] util.JDBCExceptionReporter (JDBCExceptionReporter.java:72) - ERROR: missing FROM-clause entry for table "brokenhibe2_2_"
> 2006-03-22 15:18:18,255 DEBUG [null main] jdbc.JDBCContext (JDBCContext.java:217) - after autocommit
> 2006-03-22 15:18:18,255 DEBUG [null main] jdbc.ConnectionManager (ConnectionManager.java:296) - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
> Exception in thread "main" 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:2148)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
> at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
> at com.i2rd.occasio.test.BrokenHibernateDowncast.main(BrokenHibernateDowncast.java:181)
> Caused by: org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table "brokenhibe2_2_"
> at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1512)
> at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1297)
> at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:437)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:257)
> at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
> at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
> 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:2145)
> ... 8 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
19 years, 5 months
[Hibernate-JIRA] Commented: (HHH-1895) HqlSqlWalker throws NullPointerException with explicit joins and component mapping
by Victor Suarez (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1895?page=c... ]
Victor Suarez commented on HHH-1895:
------------------------------------
Firstly I want to apologize if I offended to anybody, that was not my intention.
1) HQL is supposed to be a OO query language, must HQL to know the underlying mapping approach to work?
2) I think different error message would be a GREAT improvement. I agree with you, and if this type of HQL query is finally unsupported, this may be the bug fix, instead of rejecting (I think). I would be happy if I get this new Exception (sure this new Exception would be more friendly than a NullPointerException).
3) Again I apologize if I offended you, but I only wanted to remark that this behaviour didn't appear in H2, it was only a tip (maybe the word "kind" in English connotes something wrong). Previously I search in the docs and forums, and then posted to the forum. I know Hibernate is a VERY BIG (and very useful) project, and maybe this problem could be new in H3. Sure that the people that wrote all this GOOD stuff knows better than anybody what does or doesn't work previously, but as you say in previous comment: "If this worked in Hibernate2 (which I seriously, seriously doubt) it was totally by accident and not a supported syntax". Maybe something would pass unnoticed.
Greetings
> HqlSqlWalker throws NullPointerException with explicit joins and component mapping
> ----------------------------------------------------------------------------------
>
> Key: HHH-1895
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1895
> Project: Hibernate3
> Type: Bug
> Versions: 3.1.3
> Environment: Oracle 9i, Hibernate 3.1.3
> Reporter: Victor Suarez
> Priority: Minor
>
>
> HqlSqlWalker throws a NPE if a explicit join is used with fields that are mapped with component mapping. If explicit join is removed and implicit join is used, the HQL works fine. This kind of problem didn't occur with Hibernate2.
> Examples (hbm below):
> The query:
> String query = "FROM " + Pais.class.getName() + " AS pais JOIN pais.metaInfo AS minfo WHERE minfo.activo = true";
> fails with this stacktrace:
> Exception in thread "main" java.lang.NullPointerException
> at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:317)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3268)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3060)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
> at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
> at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
> at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
> at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
> at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
> at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
> at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
> at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
> at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)
> This one works fine:
> String query = "FROM " + Pais.class.getName() + " AS pais WHERE pais.metaInfo.activo = true";
> With this behaviour, HQL seems not to be totally transparent to mappings.
> Mapping file:
> <hibernate-mapping>
> <class name="Pais" table="Paises" lazy="true">
> <id name="id" type="long" column="id">
> <generator class="increment"/>
> </id>
> <component name="metaInfo" class="MetaInfo">
> <property name="usuarioAlta" column="usuarioAltaMetaInfo" type="string" not-null="false"/>
> <property name="fechaBaja" column="fechaBajaMetaInfo" type="timestamp" not-null="false"/>
> <property name="fechaAlta" column="fechaAltaMetaInfo" type="timestamp" not-null="false"/>
> <property name="activo" column="activoMetaInfo" type="boolean" not-null="false"/>
> <property name="usuarioBaja" column="usuarioBajaMetaInfo" type="string" not-null="false"/>
> </component>
> <property name="nombre" column="nombre" type="string" not-null="true"/>
> <property name="codigo" column="codigo" type="string" not-null="false"/>
>
> <set name="localidades" access="field" inverse="true"
> cascade="all-delete-orphan" lazy="true" batch-size="5">
> <key column="pais" />
> <one-to-many class="Localidad"/>
> </set>
> <set name="provincias" access="field" inverse="true"
> cascade="all-delete-orphan" lazy="true" batch-size="5">
> <key column="pais" />
> <one-to-many class="Provincia"/>
> </set>
>
> <property name="codAS400" type="string" not-null="false"/>
> </class>
> </hibernate-mapping>
--
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
19 years, 5 months
[Hibernate-JIRA] Commented: (HB-281) ".class" with <joined-subclass> problem
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-281?page=com... ]
Steve Ebersole commented on HB-281:
-----------------------------------
Unfortunately the issue is much more insidious and much more complex than just that. True, the JoinSequence.Selector applied during JoinProcessor.processJoins() is wrong, but it is wrong because it does not have all the info it needs at that time. I actually already have this fixed (well the HHH version, as this will obviously not be getting backported to Hibernate2) on my local box in regards to both .class and general sub/super-class property references...
> ".class" with <joined-subclass> problem
> ---------------------------------------
>
> Key: HB-281
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HB-281
> Project: Hibernate2
> Type: Bug
> Components: core
> Environment: windows 2000
> Reporter: Simone Ricciardi
> Priority: Minor
>
>
> I've acknowledged an error that happens using "select count (*) ..."
> together to a where clause "... where alias.class = ClassName ".
> Suppose to have two classes:
> public class Foo
> {
> String id;
> String attr1;
> public String getId(){ return id; }
> public void setId(String id){ this.id = id; }
> public String getAttr1(){ return attr1; }
> public void setAttr1(String attr1){ this.attr1 = attr1; }
> }
> public class Bar extends Foo
> {
> String attr2;
> public String getAttr2(){ return attr2; }
> public void setAttr2(String attr2){ this.attr2 = attr2; }
> }
> and the corresponding mapping file:
> <hibernate-mapping>
> <class name="test.persistents.Foo" table="Foo">
> <id name="id" type="string">
> <column name="id" length="32"/>
> <generator class="uuid.hex"/>
> </id>
> <property name="attr1" column="attr1" type="string"/>
> <joined-subclass name="test.persistents.Bar" table="Bar">
> <key column="foo_id"/>
> <property name="attr2" column="attr2" type="string"/>
> </joined-subclass>
> </class>
> </hibernate-mapping>
> When I try to make the following query:
> Query query = session.createQuery("select count(*) from Foo foo where foo.class = Foo");
> I get an error of this type:
> java.sql.SQLException: General error, message from server: "Unknown table 'foo0__1' in where clause"
> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)
> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)
> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:956)
> at com.mysql.jdbc.Connection.execSQL(Connection.java:1874)
> at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1538)
> at com.p6spy.engine.logging.P6LogPreparedStatement.executeQuery(P6LogPreparedStatement.java:171)
> at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:71)
> at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:551)
> at net.sf.hibernate.loader.Loader.doFind(Loader.java:140)
> at net.sf.hibernate.loader.Loader.find(Loader.java:620)
> at net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:928)
> at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1343)
> at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:76)
> at test.Test.main(Test.java:42)
> 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:324)
> while if I perform the same query without the select count(*) (select foo from Foo foo where foo.class = Foo)
> all works fine.
> Comparing the two queries produced by hibernate in both cases,
> it seems that the error derives from the lack of the "left outer join" with the Bar table in the "from" clause:
> with select count(*):
> select count(*) as x0_0_
> from Foo foo0_
> where (case when foo0__1.foo_id is not null then 1 when foo0_.id is not null then 0 end=0 )
> without select count(*):
> select foo0_.id as id,
> case when foo0__1.foo_id is not null then 1
> when foo0_.id is not null then 0 end
> as clazz_,
> foo0_.attr1 as attr10_,
> foo0__1.attr2 as attr21_
> from Foo foo0_ left outer join Bar foo0__1 on foo0_.id=foo0__1.foo_id
> where (case when foo0__1.foo_id is not null then 1 when foo0_.id is not null then 0 end=0 )
> in fact the query should be the following:
> select count(*) as x0_0_
> from Foo foo0_ left outer join Bar foo0__1 on foo0_.id=foo0__1.foo_id
> where (case when foo0__1.foo_id is not null then 1 when foo0_.id is not null then 0 end=0 )
--
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
19 years, 5 months