[
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