[Hibernate-JIRA] Updated: (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 updated HHH-939:
-------------------------------
Component: query-hql
(was: core)
Summary: 'class' property in HQL results in incorrect SQL for joined-subclass (was: wrong sql for hsql with count and class)
Fix Version: 3.2.1
Assign To: Steve Ebersole
> '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] 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:
------------------------------------
The problem appears to be with the implementation of JoinSequence.Selector.includeSubclass(String alias) in JoinProcessor.processJoins(QueryNode query, boolean inSubquery). JoinSequence.Selector.includeSubclass(String alias) returns false when 'shallowQuery = true', so JoinSequence.addExtraJoins(JoinFragment, String alias, Joinable joinable, boolean innerJoin) passes false to includeSubclasses argument of Joinable.fromJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses). The method fromJoinFragment is where the join is added to the "from" clause.
I think that the criteria in JoinSequence.Selector.includeSubclass(String alias) should also consider "where" clause components that reference a joined tables or alias.
I hope this info helps.
> ".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: (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=c... ]
Steve Ebersole commented on HHH-1895:
-------------------------------------
Where is it said that this *is* a supported syntax? You are not asking for a "little improvement". A "little improvement" would be maybe a different error message. You are asking to probably ignore it or something like that...
So let me ask you something... why did you feel the need to throw in "This kind of problem didn't occur with Hibernate2" comment? Do you think we who wrote this stuff in the first place don't know what did and did not work previously?
> 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] Updated: (HHH-951) setMaxResults causes "ORA-00918: column ambiguously defined" exception
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-951?page=all ]
Steve Ebersole updated HHH-951:
-------------------------------
Summary: setMaxResults causes "ORA-00918: column ambiguously defined" exception (was: ORA-00918: column ambiguously defined)
Priority: Major (was: Minor)
> setMaxResults causes "ORA-00918: column ambiguously defined" exception
> -----------------------------------------------------------------------
>
> Key: HHH-951
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-951
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.0.5, 3.1 beta 2
> Environment: hibernate3.0.5, hibernate3.1b2, Oracle 9
> Reporter: Karel Sommer
>
>
> when create criteria with associations, i get this error:
> ORA-00918: column ambiguously defined
> mapping:
> <class name="User" table="FRAME_USER" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_user_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="user_name" type="string" not-null="true"/>
> <property name="blocked" type="yes_no" not-null="true"/>
> <property name="access_logon" type="timestamp"/>
> <property name="denied_logon" type="timestamp"/>
> <property name="inactivity_time" type="long"/>
> <property name="session_count" type="long"/>
> <idbag name="terminalGroups" table="FRAME_USER_TERMINAL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long">
> <generator class="sequence">
> <param name="sequence">frame_user_terminal_seq</param>
> </generator>
> </collection-id>
> <key column="id_user"/>
> <many-to-many column="id_terminal_groups" class="TerminalGroup" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="TerminalGroup" table="FRAME_TERMINAL_GROUPS" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_groups_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="name" column="group_name" type="string" not-null="true"/>
> <idbag name="terminals" table="FRAME_TERMINAL_REL" fetch="join" outer-join="true">
> <collection-id column="ID" type="long" >
> <generator class="sequence">
> <param name="sequence">frame_terminal_rel_seq</param>
> </generator>
> </collection-id>
> <key column="id_term_group"/>
> <many-to-many column="id_term" class="Terminal" fetch="join" outer-join="true"/>
> </idbag>
> </class>
> <class name="Terminal" table="FRAME_TERMINAL" where="status != 'D'" dynamic-update="true" dynamic-insert="true">
> <id name="id" type="long" unsaved-value="null">
> <column name="ID" not-null="true"/>
> <generator class="sequence">
> <param name="sequence">frame_terminal_seq</param>
> </generator>
> </id>
> <version type="timestamp" column="stamp" name="timestamp" unsaved-value="null"/>
> <property name="status" type="char" not-null="true"/>
> <property name="mac" type="string" not-null="true"/>
> <property name="name" column="ident" type="string" not-null="true"/>
> <property name="description" type="string"/>
> code:
> session.createCriteria(User.class)
> .add(Restrictions.like("user_name", "%")
> .createCriteria("terminalGroups")
> .add( Restrictions.like("group_name", "%").
> .setProjection(Projections.rowCount())
> .uniqueResult();
--
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:
------------------------------------
"an unsupported", language bug fixed.
> 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] Closed: (HHH-1436) setMaxResults causes column ambiguously defined exception
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1436?page=all ]
Steve Ebersole closed HHH-1436:
-------------------------------
Resolution: Duplicate
> setMaxResults causes column ambiguously defined exception
> ---------------------------------------------------------
>
> Key: HHH-1436
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1436
> Project: Hibernate3
> Type: Bug
> Components: core
> Versions: 3.1.2
> Environment: Oracle 10g
> Reporter: Petri Rautakoski
> Priority: Minor
>
>
> This is duplicate to HHH-951, but in my opinion this is a bug with Blocker status and I recreated it
> It seems that if you set any WHERE clause into HQL query it appends this WHERE clause column into SELECT part. This works fine if you just execute it, but if you for example set maximum result size for Query it will produce this HQL query as inner select and wraps it into SELECT * FROM (...) WHERE rownum <= ? query. For example:
> Mapping:
> <?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>
> <class
> name="Foo"
> table="foo"
> lazy="true"
> >
> <id
> name="id"
> column="id"
> type="integer"
> >
> <generator
> class="sequence"
> >
> <param name="sequence">
> <![CDATA[S_FOO]>
> </param>
> </generator>
> </id>
> </class>
> </hibernate-mapping>
> Java code:
> Query hql = session.createQuery("FROM Foo WHERE id = 123");
> hql.setMaxResultSize(2);
> List results query.list();
> produced SQL:
> SELECT * FROM (SELECT foo0_.id as id12_, foo0_.ID as ID12_ FROM foo as foo0_ WHERE foo0_.id=123) WHERE rownum <= 2
> Thrown Exception:
> [JDBCExceptionReporter] SQL Error: 918, SQLState: 42000
> [JDBCExceptionReporter] ORA-00918: column ambiguously defined
> org.hibernate.exception.SQLGrammarException: could not execute query
> at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
> 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:1129)
> 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] Closed: (HHH-1810) Classic query parser inefficiency on WebLogic
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1810?page=all ]
Steve Ebersole closed HHH-1810:
-------------------------------
Resolution: Rejected
I am not going to waste time working on the classic query parser for anything other than super critical bugs. Good luck finding one ;)
> Classic query parser inefficiency on WebLogic
> ---------------------------------------------
>
> Key: HHH-1810
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1810
> Project: Hibernate3
> Type: Improvement
> Components: query-hql
> Environment: Hibernate 3.0.5 with HHH-525 patch
> WebLogic 8.1 SP4
> SQL Server 2000 SP3
> Reporter: Hemanta Gupta
> Priority: Minor
> Attachments: QueryTranslatorImpl.java
>
>
> With around 1600 named queries in the system, SessionFactory.checkNamedQueries() takes around 5 1/2 min on WebLogic 8.1, as compared to < 1/2 min on JBoss 4.0.3. The classic query translator is being used, mainly because the new AST based translator has issues on WebLogic (http://hibernate.org/250.html#A24).
> The issue boils down to the classic query parser trying to load bad class names on a system with relatively inefficient classloading. The parser breaks down queries into tokens and then tries to resolve many of the tokens (even the obviously 'bad' ones like '=', '(', ')', 'AND', 'OR', etc) as Java classes by calling ReflectHelper.classForName() on the tokens. Because of the way the method is written, ClassLoader.loadClass() and then Class.forName() will both be called before it can be determined that a token doesn't resolve to a Java class. This overhead is really killing performance on WebLogic.
> I patched QueryTranslatorImpl.getEntityPersisterUsingImports(String) to skip tokens which can't resolve to Java classes (i.e are not Java identifiers or are HQL keywords). The file is attached. After applying this patch, the time taken by SessionFactory.checkNamedQueries() went down to around 20 sec on WebLogic. The patch isn't too beautiful or exhaustive, but it did the trick on our environment.
> Please also see the forum thread at http://forum.hibernate.org/viewtopic.php?t=943427
--
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:
------------------------------------
Some questions:
Rejected? Why? Where is said that this a unsupported syntax? Why not to do a little improvement with this exception handle (in the case this would be a unsupported syntax)?
Thank you for your work.
> 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] Closed: (HHH-1652) Missing join clause on generated SQL for a select of a subclass property
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1652?page=all ]
Steve Ebersole closed HHH-1652:
-------------------------------
Resolution: Duplicate
> Missing join clause on generated SQL for a select of a subclass property
> ------------------------------------------------------------------------
>
> Key: HHH-1652
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1652
> Project: Hibernate3
> Type: Bug
> Components: query-sql
> Versions: 3.2.0.cr2, 3.1.3, 3.2.0 cr1
> Environment: Hibernate 3.2 from SVN, MS SQL Server 2005
> Reporter: William Monti
> Attachments: MissingJoinClause.zip
>
>
> Hibernate isn't generating the join clause of a subclass when I try to select a subclass property.
> Class hierarchy:
> @Entity
> @Inheritance(strategy = InheritanceType.JOINED)
> public class A
> {
> private String a;
> }
> @Entity
> public class B extends A
> {
> private String b;
> }
> With the following HQL it generates a SQL with a unknown alias name "a0_1_":
> HQL: SELECT a.b FROM com.nm.test.A a
> SQL: select a0_1_.b as col_0_0_ from A a0_
> What raises the error:
> ERROR JDBCExceptionReporter:72 - The multi-part identifier "a0_1_.b" could not be bound.
> Looks like it is generating the alias for the select clause, but it isn't creating the alias on the from clause.
> If I add the full object a to the select clause, it works (but it is just a workaround since it will degrade performance):
> HQL: SELECT a, a.b FROM com.nm.test.A a
> SQL: select a0_.id as col_0_0_, a0_1_.b as col_1_0_, a0_.id as id0_, a0_.a as a0_, a0_1_.b as b1_, case when a0_1_.id is not null then 1 when a0_.id is not null then 0 end as clazz_ from A a0_ left outer join B a0_1_ on a0_.id=a0_1_.id
--
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