[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1895) HqlSqlWalker throws NullPointerException with explicit joins and component mapping

Sam Wilson (JIRA) noreply at atlassian.com
Tue Sep 12 15:02:24 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1895?page=comments#action_24417 ] 

Sam Wilson commented on HHH-1895:
---------------------------------

I have a very similar issue with 3.2.0CR2 (about to test 3.2.0CR4) running on SQL Server 2000/2005.

I'm going to do more research on the issue and post it here and may open a separate defect if it turns out to be different.

> 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.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list