-->
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.  [ 6 posts ] 
Author Message
 Post subject: NullPointerException while parsing HQL (worked in 3.0)
PostPosted: Tue Dec 27, 2005 9:49 am 
Newbie

Joined: Tue Dec 27, 2005 9:21 am
Posts: 4
Location: Le Lavandou (France)
The following HQL causes a NullPointerException :

select distinct(aux) from agpm.nogs.gestion.fournisseur.pub.objets.ExpertVTM aux left join fetch aux.personne per left join aux.zonesIntervention zone where aux.type = ? and zone = ?


I also noticed another problem with the new version, using
setParameter(int, Object) on a query (works once changed in
setString(int, String))

However, many thanks for this wonderful product !
P.O.

Hibernate version: 3.1

Mapping documents:

(Partial)

Code:
<class name="agpm.nogs.gestion.fournisseur.pub.objets.Prestataire" table="PRESTATAIRE">

   <id name="pk" type="integer" column="PK_PRESTATAIRE" unsaved-value="null">
      <generator class="agpm.commun.hibernate.PkGenerator">
         <param name="table">SEQUENCE</param>
         <param name="primary_key_column">ENTITE</param>
         <param name="primary_key_value">PRESTATAIRE</param>
         <param name="value_column">NUMERO</param>
      </generator>
   </id>

   <timestamp column="DATE_VERSION" name="version" unsaved-value="null" />

   <property name="codeDARVA" column="CODE_DARVA" />
   <property name="commentaire" column="COMMENTAIRE" />
   <property name="dateCreation" type="timestamp" column="DATE_CREATION" />
   <property name="dateDerniereIntervention" type="timestamp" column="DATE_DERNIERE_INTERVENTION" />
   <property name="etat" column="ETAT_PRESTATAIRE" />
   <property name="identifiant" column="IDENTIFIANT_PRESTATAIRE" />
   <property name="modePaiement" column="MODE_PAIEMENT" />
   <property name="type" column="TYPE_PRESTATAIRE" />
   <property name="niveau" column="NIVEAU_PRESTATAIRE" />
   <property name="tauxT1" column="TAUX_T1" />
   <property name="tauxT2" column="TAUX_T2" />
   <property name="tauxT3" column="TAUX_T3" />
   <property name="tauxTU" column="TAUX_TU" />
   
   <many-to-one name="personne" column="PK_PERSONNE" class="agpm.nogs.commun.personne.pub.objets.Personne" cascade="persist,merge,save-update" fetch="join" lazy="false" />

   <set name="zonesIntervention" table="ZONE_INTERVENTION_PRESTATAIRE" cascade="all,delete-orphan" fetch="join" lazy="false" >
      <key column="PK_PRESTATAIRE" not-null="true" />
      <element column="CODE_ZONE" type="string" />
   </set>

</class>


<class name="agpm.nogs.commun.personne.pub.objets.Personne" table="PERSONNE" abstract="true">

   <id name="pk" type="integer" column="PK_PERSONNE" unsaved-value="null">
      <generator class="agpm.commun.hibernate.PkGenerator">
         <param name="table">SEQUENCE</param>
         <param name="primary_key_column">ENTITE</param>
         <param name="primary_key_value">PERSONNE</param>
         <param name="value_column">NUMERO</param>
      </generator>
   </id>

   <timestamp column="DATE_VERSION" name="version" unsaved-value="null" />

   <property name="courriel" column="COURRIEL" />
   <property name="fax" column="FAX" />
   <property name="telephoneFixe" column="TELEPHONE_FIXE" />
   <property name="telephoneMobile" column="TELEPHONE_MOBILE" />

   <many-to-one name="adressePostale" column="PK_ADRESSE_POSTALE" class="agpm.nogs.commun.personne.pub.objets.AdressePostale" unique="true" cascade="all" fetch="join" lazy="false"/>

   <joined-subclass name="agpm.nogs.commun.personne.pub.objets.PersonneMorale" table="PERSONNE_MORALE" >

      <key column="PK_PERSONNE" />

      <property name="codeNAF" column="CODE_NAF" />
      <property name="numeroSIRET" column="NUMERO_SIRET" />
      <property name="raisonSociale" column="RAISON_SOCIALE" />

   </joined-subclass>

   <joined-subclass name="agpm.nogs.commun.personne.pub.objets.PersonnePhysique"
      table="PERSONNE_PHYSIQUE" >

      <key column="PK_PERSONNE" />

      <property name="dateNaissance" type="timestamp" column="DATE_NAISSANCE" />
      <property name="grade" column="GRADE" />
      <property name="nom" column="NOM_PERSONNE" />
      <property name="prenom" column="PRENOM_PERSONNE" />
      <property name="profession" column="PROFESSION" />
      <property name="sexe" column="SEXE" />
      <property name="titre" column="TITRE_PERSONNE" />

      <many-to-one name="organisation" column="PK_ORGANISATION" class="agpm.nogs.commun.personne.pub.objets.PersonneMorale" unique="true" cascade="all" fetch="join" lazy="false"/>

   </joined-subclass>

</class>


<class name="agpm.nogs.commun.personne.pub.objets.AdressePostale" table="ADRESSE_POSTALE">

   <id name="pk" type="integer" column="PK_ADRESSE_POSTALE" unsaved-value="null" access="field">
      <generator class="agpm.commun.hibernate.PkGenerator">
         <param name="table">SEQUENCE</param>
         <param name="primary_key_column">ENTITE</param>
         <param name="primary_key_value">ADRESSE_POSTALE</param>
         <param name="value_column">NUMERO</param>
      </generator>
   </id>

   <timestamp column="DATE_VERSION" name="version" unsaved-value="null" />

   <property name="codePostal" column="CODE_POSTAL" />
   <property name="champ1" column="CHAMP1" />
   <property name="champ2" column="CHAMP2" />
   <property name="champ3" column="CHAMP3" />
   <property name="pays" column="CODE_PAYS" />
   <property name="ville" column="VILLE" />

</class>


Full stack trace of any exception that occurs:

ERROR agpm.nogs.gestion.fournisseur.impl.services.FournisseurServiceImpl - Echec de la recherche multi-critères de prestataires
java.lang.NullPointerException
at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:175)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:637)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:466)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:643)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:279)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:227)
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:105)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:53)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1540)
at agpm.nogs.gestion.fournisseur.impl.dao.FournisseurDAOHibernate.rechercherPrestataires(FournisseurDAOHibernate.java:135)
at agpm.nogs.gestion.fournisseur.impl.services.FournisseurServiceImpl.rechercherPrestataires(FournisseurServiceImpl.java:38)
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)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy7.rechercherPrestataires(Unknown Source)
at agpm.nogs.gestion.fournisseur.impl.test.TestServicesFournisseur.testRechercheGaragisteParCodePostal(TestServicesFournisseur.java:1238)
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)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Name and version of the database you are using:

SQLServer 2000

The generated SQL (show_sql=true):
Not even generated

Debug level Hibernate log excerpt:

DEBUG org.hibernate.impl.SessionImpl - opened session at timestamp: 4651790375505920
DEBUG org.hibernate.impl.SessionImpl - setting flush mode to: NEVER
DEBUG org.hibernate.engine.query.QueryPlanCache - unable to locate HQL query plan in cache; generating (select distinct(prest) from agpm.nogs.gestion.fournisseur.pub.objets.Prestataire prest left join fetch prest.personne per left join prest.zonesIntervention zone where prest.type = ? and zone = ?)
DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - parse() - HQL: select distinct(prest) from agpm.nogs.gestion.fournisseur.pub.objets.Prestataire prest left join fetch prest.personne per left join prest.zonesIntervention zone where prest.type = ? and zone = ?
DEBUG org.hibernate.hql.ast.AST - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | +-[RANGE] 'RANGE'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[DOT] '.'
| | | | | | | +-[DOT] '.'
| | | | | | | | +-[DOT] '.'
| | | | | | | | | +-[IDENT] 'agpm'
| | | | | | | | | \-[IDENT] 'nogs'
| | | | | | | | \-[IDENT] 'gestion'
| | | | | | | \-[IDENT] 'fournisseur'
| | | | | | \-[IDENT] 'pub'
| | | | | \-[IDENT] 'objets'
| | | | \-[IDENT] 'Prestataire'
| | | \-[ALIAS] 'prest'
| | +-[JOIN] 'join'
| | | +-[LEFT] 'left'
| | | +-[FETCH] 'fetch'
| | | +-[DOT] '.'
| | | | +-[IDENT] 'prest'
| | | | \-[IDENT] 'personne'
| | | \-[ALIAS] 'per'
| | \-[JOIN] 'join'
| | +-[LEFT] 'left'
| | +-[DOT] '.'
| | | +-[IDENT] 'prest'
| | | \-[IDENT] 'zonesIntervention'
| | \-[ALIAS] 'zone'
| \-[SELECT] 'select'
| +-[DISTINCT] 'distinct'
| \-[IDENT] 'prest'
\-[WHERE] 'where'
\-[AND] 'and'
+-[EQ] '='
| +-[DOT] '.'
| | +-[IDENT] 'prest'
| | \-[IDENT] 'type'
| \-[PARAM] '?'
\-[EQ] '='
+-[IDENT] 'zone'
\-[PARAM] '?'

DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - select << begin [level=1, statement=select]
DEBUG org.hibernate.hql.ast.tree.FromElement - FromClause{level=1} : agpm.nogs.gestion.fournisseur.pub.objets.Prestataire (prest) -> prestatair0_
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : prest -> prestatair0_.PK_PRESTATAIRE
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : personne -> org.hibernate.type.ManyToOneType(agpm.nogs.commun.personne.pub.objets.Personne)
DEBUG org.hibernate.hql.ast.tree.DotNode - dereferenceEntityJoin() : generating join for personne in agpm.nogs.gestion.fournisseur.pub.objets.Prestataire (per) parent = [ {null} ]
DEBUG org.hibernate.hql.ast.tree.FromElement - FromClause{level=1} : agpm.nogs.commun.personne.pub.objets.Personne (per) -> personne1_
DEBUG org.hibernate.hql.ast.tree.FromClause - addJoinByPathMap() : prest.personne -> PERSONNE personne1_
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : prest.personne -> prestatair0_.PK_PERSONNE
DEBUG org.hibernate.hql.ast.HqlSqlWalker - createFromJoinElement() : -- join tree --
\-[JOIN_FRAGMENT] FromElement: 'PERSONNE personne1_' FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=per,role=null,tableName=PERSONNE,tableAlias=personne1_,origin=PRESTATAIRE prestatair0_,colums={prestatair0_.PK_PERSONNE ,className=agpm.nogs.commun.personne.pub.objets.Personne}}

DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : prest -> prestatair0_.PK_PRESTATAIRE
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : zonesIntervention -> org.hibernate.type.SetType(agpm.nogs.gestion.fournisseur.pub.objets.Prestataire.zonesIntervention)
DEBUG org.hibernate.hql.ast.tree.FromElement - FromClause{level=1} : null (zone) -> zonesinter2_
DEBUG org.hibernate.hql.ast.tree.FromClause - addCollectionJoinFromElementByPath() : prest.zonesIntervention -> ZONE_INTERVENTION_PRESTATAIRE
DEBUG org.hibernate.hql.ast.tree.DotNode - dereferenceCollection() : Created new FROM element for prest.zonesIntervention : ZONE_INTERVENTION_PRESTATAIRE zonesinter2_
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : prest.zonesIntervention -> .
DEBUG org.hibernate.hql.ast.HqlSqlWalker - createFromJoinElement() : -- join tree --
\-[JOIN_FRAGMENT] FromElement: 'ZONE_INTERVENTION_PRESTATAIRE zonesinter2_' FromElement{explicit,collection join,not a fetch join,fetch non-lazy properties,classAlias=zone,role=agpm.nogs.gestion.fournisseur.pub.objets.Prestataire.zonesIntervention,tableName={none},tableAlias=zonesinter2_,origin=null,colums={,className=null}}

DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : prest -> prestatair0_.PK_PRESTATAIRE
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : prest -> prestatair0_.PK_PRESTATAIRE
DEBUG org.hibernate.hql.ast.tree.DotNode - getDataType() : type -> org.hibernate.type.StringType@ba175f
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : prest.type -> prestatair0_.TYPE_PRESTATAIRE
DEBUG org.hibernate.hql.ast.tree.FromReferenceNode - Resolved : zone -> zonesinter2_.CODE_ZONE
DEBUG org.hibernate.hql.antlr.HqlSqlBaseWalker - select : finishing up [level=1, statement=select]
DEBUG org.hibernate.hql.ast.HqlSqlWalker - processQuery() : ( SELECT ( {select clause} distinct prestatair0_.PK_PRESTATAIRE ) ( FromClause{level=1} ( PERSONNE personne1_ ZONE_INTERVENTION_PRESTATAIRE zonesinter2_ ) ) ( where ( and ( = ( prestatair0_.TYPE_PRESTATAIRE prestatair0_.PK_PRESTATAIRE type ) ? ) ( = zonesinter2_.CODE_ZONE ? ) ) ) )


Top
 Profile  
 
 Post subject: Re: NullPointerException while parsing HQL (worked in 3.0)
PostPosted: Tue Dec 27, 2005 10:08 am 
Newbie

Joined: Tue Dec 27, 2005 9:21 am
Posts: 4
Location: Le Lavandou (France)
I forgot to tell that the problem occurs only when the part regarding
the zones is added ('left join aux.zonesIntervention zone' and 'and zone = ?')


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 1:50 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
try this

select distinct(aux) from agpm.nogs.gestion.fournisseur.pub.objets.ExpertVTM aux left join fetch aux.personne per where aux.type = ? and aux.zonesIntervention= ?


Top
 Profile  
 
 Post subject: Still unresolved
PostPosted: Wed Dec 28, 2005 4:36 am 
Newbie

Joined: Tue Dec 27, 2005 9:21 am
Posts: 4
Location: Le Lavandou (France)
Thank you for your suggestion abg1979, I had already tried it
thinking that a set of value might have not supported join
(what is finally surprising because the SQL query needs a join)

The problem then is still alive.

Actually, I've found the following bug in JIRA :

HHH-1306 HQL parsing problem with "select" and "fetch" for associated arrays or collections of components

http://opensource2.atlassian.com/projects/hibernate/browse/HHH-1306

which is still open and is absolutely similar to my issue.

I'm waiting now for a fix, because the suggested workaround
doesn't work in every case.

Bye ![/url]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 4:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There is also no function called distinct in either HQL or any dialect of SQL.

It is "select distinct aux ...."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 5:09 am 
Newbie

Joined: Tue Dec 27, 2005 9:21 am
Posts: 4
Location: Le Lavandou (France)
Hello gavin,

You're right,
how is it possible that some of my queries works with distinct() !
I guess Hibernate ignores it...
I'm gonna correct this error right now, but it is however not linked
to my problem.

Thank you for your help,
P.O.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.