[Hibernate-JIRA] Closed: (HHH-1895) HqlSqlWalker throws NullPointerException with explicit joins and component mapping
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1895?page=all ]
Steve Ebersole closed HHH-1895:
-------------------------------
Resolution: Rejected
If this worked in Hibernate2 (which I seriously, seriously doubt) it was totally by accident and not a supported syntax.
And it is still not a supported syntax.
> 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] Created: (HHH-2244) Problem with data type 'Blob'
by Gulshanrai BABAJEE (JIRA)
Problem with data type 'Blob'
-----------------------------
Key: HHH-2244
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2244
Project: Hibernate3
Type: Bug
Environment: Hibernate version:3.2
DB: postgresql 8.1
Reporter: Gulshanrai BABAJEE
I have created a table in which I have a field of type BLOB which I store pictures. I insert a picture, note the oid generated. Then I do the following select statement on table 'pg_largeobject' (system table) : select * from pg_largeobject where loid = 'oid of my picture'. I found the oid.
Then I update my picture. Its oid has been changed. I now make another select from table 'pg_largeobject' where loid = 'my OLD oid' and I was surprised to see that the old oid is STILL in the table. So I conclude that each time I update a picture from my table. The old oids are still there and eventually my database is increasing in size.
Is this not a bug in hibernate?
thanks in advance
--
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-2229) Performance issue with fix for HHH-1293, CGLIBLazyInitializer may be slower for certain Java classes
by Scott Marlow (JIRA)
Performance issue with fix for HHH-1293, CGLIBLazyInitializer may be slower for certain Java classes
----------------------------------------------------------------------------------------------------
Key: HHH-2229
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2229
Project: Hibernate3
Type: Bug
Versions: 3.2.0.ga
Reporter: Scott Marlow
Assigned to: Scott Marlow
Fix For: 3.2.1
Customer reports:
"we've used the Hibernate for Version 3.2.0 CR 2 with Hibernate Annotations and Proxy interfaces for Lazy initialization. After we changed to Version 3.2.0 GA our Application is 5-7 times slower than before. My Java Profiler says that the Class org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.addCheckingTypes is called over 11 Million times (with recursion). This method was not present in the old release candidate. The problem is that this methods adds recursively all interfaces of a type and its subclasses into a List in our non trivial object hierarchy.
"
And later:
"The CGLIBLazyInitializer.invoke() method was called 64.000 Times. I found out that the Problem were the @Proxy annotations with a specified proxy interface in all of our classes (this was necessary in the old version to prevent ClassCastExceptions). If we specify the proxy interface only on the classes where we need it, the performance is much better.
"
Forum reference: http://forum.hibernate.org/viewtopic.php?t=967060
I'll look into some suggestions that Steve suggested that I try:
1. use class.isAssignableFrom() .
2. use class.isInstance(). if ( !method.getDeclaringClass().isInstance( target ) ) {throw new ClassCastException( target.getClass() .getName() );}
3. use instanceof test
--
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: (HBX-815) [hbmlint] Detect repeated columns
by David Balažic (JIRA)
[hbmlint] Detect repeated columns
---------------------------------
Key: HBX-815
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-815
Project: Hibernate Tools
Type: New Feature
Versions: 3.2beta8
Environment: hibernate v3.2, MySQL 5.1.12-beta-community-nt
Reporter: David Balažic
(verbatim from the forum , http://forum.hibernate.org/viewtopic.php?t=967007 )
Hi!
I use hbm2ddl (from Hibernate Tools v3.2 beta 8) to create the DB schema and noticed, that duplicate column names are not detected.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.manning.hq.stein.data">
<class name="TelefonskiImenik">
<id name="id" column="imid">
<generator class="native" />
</id>
<property name="izdajatelj" column="col"/>
<property name="verzija" column="col"/>
</class>
</hibernate-mapping>
The same thing happens if one column name is implicit :
<property name="izdajatelj" column="verzija"/>
<property name="verzija"/>
If I try to use this mapping with an application, hibernate (v3.2) fails (in both cases) in buildSessionFactory() :
Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: com.manning.hq.stein.data.TelefonskiImenik column: verzija (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:605)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:627)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:645)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:420)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1026)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
at com.manning.hq.stein.Main2.persist_all(Main2.java:284)
at com.manning.hq.stein.Main2.main(Main2.java:45)
While this is not a severe bug, it would be nice to detect it as early as possible.
--
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] Updated: (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 updated HHH-1631:
--------------------------------
Fix Version: 3.2.1
Assign To: Steve Ebersole
I have confirmed this is a bug.
Would like to get the fix into 3.2.1, but that needs to go out *soon*, lets see...
> 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] Closed: (HHH-940) Generated SQL missing table join in from clause
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-940?page=all ]
Steve Ebersole closed HHH-940:
------------------------------
Resolution: Fixed
closing this in favor of HHH-1631 since it appears to be the same cause and it has a much more easily reproducible test case.
> Generated SQL missing table join in from clause
> -----------------------------------------------
>
> Key: HHH-940
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-940
> Project: Hibernate3
> Type: Bug
> Components: query-hql
> Versions: 3.0.5, 3.1 beta 2
> Environment: Hibernate 3.0.5 & 3.1 beta 2, MySQL 4.1
> Reporter: Mike
> Priority: Minor
> Attachments: hbms.zip
>
>
> Since moving from hibernate 2 to hibernate 3 a previously working HQL statement now results in the throwing of an SQLGrammarException.
> The HQL is:
> select spc.category, count( spc.category )
> from SearchableProductCategory as spc
> left join spc.searchableProduct sp
> inner join spc.category c
> inner join c.categoryHierarchiesByCategoryId ch
> where ch.comp_id.categoryTypeId = 'PRODUCT_CATEGORY'
> and sp.id in (
> select sp.id
> from SearchableProduct sp
> left join sp.products p left
> join sp.searchableProductCategories spc
> left join spc.category cat
> left join cat.categoryHierarchiesByCategoryId hi
> inner join p.channelPricings cp
> inner join cp.channel c
> where
> (hi.categoryType.id = 'PRODUCT_BRAND')
> and
> ((lower(cat.name) like '%washing%')
> or (lower(p.sku) like '%washing%') or (lower(p.manufacturer) like '%washing%')
> or (lower(sp.keywords) like '%washing%') or (lower(sp.title) like '%washing%')
> or (lower(sp.longDescription) like '%washing%') or (lower(sp.shortDescription) like '%washing%'))
> and (sp.isVisible = 'T') and (c.name = 'PWS') and (cp.isVisible = 'T') )
> group by spc.category order by count( spc.category ) desc
> The exception is:
> 11:43:02,714 WARN [JDBCExceptionReporter] SQL Error: 1054, SQLState: 42S22
> 11:43:02,714 ERROR [JDBCExceptionReporter] null, message from server: "Unknown column 'categoryhi9_.category_type_id' in 'where clause'"
>
> Generated SQL is:
> select
> searchable0_.category as col_0_0_, count(searchable0_.category) as col_1_0_, category2_.category_id as category1_, category2_.name as name4_, category2_.short_description as short3_4_, category2_.long_description as long4_4_, category2_.small_image as small5_4_, category2_.large_image as large6_4_, category2_.opt_img1 as opt7_4_, category2_.opt_img2 as opt8_4_, category2_.opt_img3 as opt9_4_, category2_.version as version4_, category2_.created_dts as created11_4_, category2_.created_by as created12_4_, category2_.last_updated_dts as last13_4_, category2_.last_updated_by as last14_4_
> from
> searchable_product_category searchable0_ left outer join searchable_product searchable1_ on searchable0_.id=searchable1_.id, category category2_ inner join category_hierarchy categoryhi3_ on category2_.category_id=categoryhi3_.category_id
> where
> searchable0_.category=category2_.category_id and categoryhi3_.category_type_id='PRODUCT_CATEGORY'
> and (searchable1_.id in
> (select searchable5_.id from searchable_product searchable5_, product products6_, channel_pricing channelpri10_, channel channel11_, searchable_product_category searchable7_
> where
> channelpri10_.id=channel11_.id and products6_.sku=channelpri10_.sku and categoryhi9_.category_type_id='PRODUCT_BRAND' and (lower(category2_.name)like '%washing%' or lower(products6_.sku)like '%washing%' or lower(products6_.manufacturer)like '%washing%' or lower(searchable5_.keywords)like '%washing%' or lower(searchable5_.title)like '%washing%' or lower(searchable5_.long_description)like '%washing%' or lower(searchable5_.short_description)like '%washing%') and searchable5_.is_visible='T' and channel11_.name='PWS' and channelpri10_.is_visible='T')) group by searchable0_.category order by count(searchable0_.category) desc
>
> The SQL refers to categoryhi9 in the where clause but the table alias is not declared in the from clause despite being in the original HQL.
> Thanks.
--
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 Stephen M. Wick (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-281?page=com... ]
Stephen M. Wick commented on HB-281:
------------------------------------
This issue affects Query.list() when the HQL is "select <anything specific> from SuperClass as s where s.class = SuperClass".
It also affects Query.iterator() when the HQL is "from SuperClass as s where s.class = SuperClass".
So I can't do "select count(*) from blah..", and I can't do "session.createQuery("from Blah as b where b.class = Blah").iterator()", so how can I get the total number of matching records without loading all 100000 objects that may match the query?
I really need help with this issue. I'm applying Hibernate to a very large resource management system, and I need to paginate search and listing results for 100,000+ objects with any number of criterias.
> ".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
[Hibernate-JIRA] Commented: (HB-281) ".class" with <joined-subclass> problem
by Daniel Thompson (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-281?page=com... ]
Daniel Thompson commented on HB-281:
------------------------------------
I wish my project was not a high priority.
> ".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