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 ? ) ) ) )