-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Explicit join with component mapping
PostPosted: Mon Jul 03, 2006 9:36 am 
Newbie

Joined: Mon Jul 03, 2006 5:16 am
Posts: 5
We have a problem with our HQL generator: by reflection (and some parameters) this component builds HQL sentences and generates needed joins, but it doesn't know if a relation is mapped with a component or many-to-one schema.

With Hibernate 2.1.x this HQL worked:

Code:
"FROM " + Pais.class.getName() + " AS pais JOIN pais.metaInfo AS minfo WHERE minfo.activo = true";


Now, with Hiberante 3.1.x the query fails. If explicit join is removed, query works fine (but our generator cannot remove it automatically):
Code:
"FROM " + Pais.class.getName() + " AS pais WHERE pais.metaInfo.activo = true";


Shouldn't HQL be totally transparent to mappings?

Stack trace is showed below.

Hibernate version: 3.1.3

Mapping documents:
Code:
<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>


Code between sessionFactory.openSession() and session.close():
This is our test code:
Code:
      String queryString = "FROM " + Pais.class.getName() + " AS pais JOIN pais.metaInfo AS minfo WHERE minfo.activo = true";
      Query query = session.createQuery(queryString);


Full stack trace of any exception that occurs:
Code:
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)


Name and version of the database you are using:
We are using Oracle 9.

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 4:05 am 
Newbie

Joined: Mon Jul 03, 2006 5:16 am
Posts: 5
Somebody can help me? This can be a big problem if it can not be resolved.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 5:11 am 
Newbie

Joined: Mon Jul 03, 2006 5:16 am
Posts: 5
Jira issue filled: HHH-1895


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.