Hi everyone,
I've got a JDBC exception from a SQL request triggered by the lazy loading of an object that has a set of joined-subclass component, when setting outer-join="true" for this set. (I know it's not very clear but it's tough to explain.)
The SQL request is simply false. (I checked it with SQL tool)
It becomes ok when I set outer-join="false"
Here's the request when trying to lazy load a DOSSIER_STAGIAIRE
Code:
Hibernate: select dossiersta0_.DOSSIER_STAGIAIRE_ID as DOSSIER_1_6_, dossiersta0_.DOSSIER_STAGIAIRE_NOM as DOSSIER_2_6_, dossiersta0_.DOSSIER_STAGIAIRE_PRENOM as DOSSIER_3_6_, dossiersta0_.DOSSIER_STAGIAIRE_NUMERO_SECU_SEXE_1 as DOSSIER_4_6_, dossiersta0_.DOSSIER_STAGIAIRE_NUMERO_SECU_AGE_2 as DOSSIER_5_6_, dossiersta0_.DOSSIER_STAGIAIRE_NUMERO_SECU_MOIS_3 as DOSSIER_6_6_, dossiersta0_.DOSSIER_STAGIAIRE_NUMERO_SECU_DEPT_4 as DOSSIER_7_6_, dossiersta0_.DOSSIER_STAGIAIRE_NUMERO_SECU_INSEE_5 as DOSSIER_8_6_, dossiersta0_.DOSSIER_STAGIAIRE_NUMERO_SECU_CPT_6 as DOSSIER_9_6_, dossiersta0_.DOSSIER_STAGIAIRE_INITIATIVE_STAGE as DOSSIER10_6_, dossiersta0_.DOSSIER_STAGIAIRE_ADRESSE1 as DOSSIER11_6_, dossiersta0_.DOSSIER_STAGIAIRE_ADRESSE2 as DOSSIER12_6_, dossiersta0_.DOSSIER_STAGIAIRE_CP as DOSSIER13_6_, dossiersta0_.DOSSIER_STAGIAIRE_VILLE as DOSSIER14_6_, dossiersta0_.DOSSIER_STAGIAIRE_TELEPHONE as DOSSIER15_6_, dossiersta0_.DOSSIER_STAGIAIRE_SALAIRE_MENSUEL as DOSSIER16_6_, dossiersta0_.DOSSIER_STAGIAIRE_NBRE_HEURE_TRAVAILLE_MOIS as DOSSIER17_6_, dossiersta0_.DOSSIER_STAGIAIRE_ETAT_HTT as DOSSIER18_6_, dossiersta0_.DOSSIER_STAGIAIRE_NBRE_HEURE_HTT as DOSSIER19_6_, dossiersta0_.DOSSIER_STAGIAIRE_ETAT_DIF as DOSSIER20_6_, dossiersta0_.DOSSIER_STAGIAIRE_TYPE_CONTRAT as DOSSIER21_6_, dossiersta0_.DOSSIER_STAGIAIRE_DATE_FIN_CONTRAT as DOSSIER22_6_, dossiersta0_.DOSSIER_STAGIAIRE_NBRE_HEURE_PREVU as DOSSIER23_6_, dossiersta0_.DOSSIER_STAGIAIRE_DATE_DEBUT_CONTRAT as DOSSIER24_6_, dossiersta0_.DOSSIER_STAGIAIRE_ETAT_FSE_ANNEE1 as DOSSIER25_6_, dossiersta0_.DOSSIER_STAGIAIRE_ETAT_FSE_ANNEE2 as DOSSIER26_6_, dossiersta0_.DOSSIER_STAGIAIRE_ETAT_FSE_ANNEE3 as DOSSIER27_6_, dossiersta0_.DOSSIER_STAGIAIRE_SANCTION_DIPLOME as DOSSIER28_6_, dossiersta0_.DOSSIER_STAGIAIRE_COMMENTAIRE as DOSSIER29_6_, dossiersta0_.DOSSIER_STAGIAIRE_STATUT as DOSSIER30_6_, dossiersta0_.DOSSIER_STAGIAIRE_DATE_CREATION as DOSSIER31_6_, dossiersta0_.DOSSIER_STAGIAIRE_DATE_MAJ as DOSSIER32_6_, dossiersta0_.DOSSIER_STAGIAIRE_SITUATION_PROFESSIONNELLE_ID_FK as DOSSIER33_6_, dossiersta0_.DOSSIER_STAGIAIRE_ISSUE_CONTRAT_ID_FK as DOSSIER34_6_, dossiersta0_.DOSSIER_STAGIAIRE_DIPLOME_ID_FK as DOSSIER35_6_, dossiersta0_.DOSSIER_STAGIAIRE_EMPLOI_CODE_FK as DOSSIER36_6_, dossiersta0_.DOSSIER_STAGIAIRE_DOSSIER_ADHERENT_ID_FK as DOSSIER37_6_, dossiersta0_.DOSSIER_STAGIAIRE_UTILISATEUR_CODE_FK as DOSSIER38_6_, attestatio1_.ATTESTATION_PRESENCE_STAGIAIRE_ID_FK as ATTESTAT1___, attestatio1_.ATTESTATION_PRESENCE_STAGIAIRE_DOSSIER_STAGIAIRE_ID_FK as ATTESTAT2___, attestatio1_.ATTESTATION_PRESENCE_STAGIAIRE_ID_FK as ATTESTAT1_0_, attestatio1_.ATTESTATION_PRESENCE_STAGIAIRE_DOSSIER_STAGIAIRE_ID_FK as ATTESTAT2_60_0_, attestatio1__1_.ATTESTATION_PRESENCE_DATE_DEBUT as ATTESTAT2_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_DATE_FIN as ATTESTAT3_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_ETAT_INTERRUPTION as ATTESTAT4_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_DUREE_HEURE_PRESENCE as ATTESTAT5_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_DUREE_HEURE_ABSENCE as ATTESTAT6_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_DUREE_HEURE_TOTAL as ATTESTAT7_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_HEURE_NON_ATTESTEE as ATTESTAT8_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_COMMENTAIRE as ATTESTAT9_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_DATE_CREATION as ATTESTA10_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_DATE_MAJ as ATTESTA11_59_0_, attestatio1__1_.ATTESTATION_PRESENCE_UTILISATEUR_CODE_FK as ATTESTA12_59_0_, situationp2_.SITUATION_PROFESSIONNELLE_ID as SITUATIO1_1_, situationp2_.SITUATION_PROFESSIONNELLE_LIBELLE as SITUATIO2_1_, situationp2_.SITUATION_PROFESSIONNELLE_ETAT_ACTIVATION as SITUATIO3_1_, issuecontr3_.ISSUE_CONTRAT_ID as ISSUE_CO1_2_, issuecontr3_.ISSUE_CONTRAT_LIBELLE as ISSUE_CO2_2_, issuecontr3_.ISSUE_CONTRAT_ETAT_ACTIVATION as ISSUE_CO3_2_, diplome4_.DIPLOME_ID as DIPLOME_ID3_, diplome4_.DIPLOME_LIBELLE as DIPLOME_2_3_, diplome4_.DIPLOME_ETAT_ACTIVATION as DIPLOME_3_3_, emploi5_.EMPLOI_CODE as EMPLOI_C1_4_, emploi5_.EMPLOI_LIBELLE as EMPLOI_L2_4_, emploi5_.EMPLOI_ETAT_ACTIVATION as EMPLOI_E3_4_, emploi5_.EMPLOI_CATEGORIES_SOCIAUX_PROFESSIONNELLES_CODE_FK as EMPLOI_C4_4_, categories6_.CATEGORIES_SOCIAUX_PROFESSIONNELLES_CODE as CATEGORI1_5_, categories6_.CATEGORIES_SOCIAUX_PROFESSIONNELLES_LIBELLE as CATEGORI2_5_, categories6_.CATEGORIES_SOCIAUX_PROFESSIONNELLES_ETAT_ACTIVATION as CATEGORI3_5_ from DOSSIER_STAGIAIRE dossiersta0_ left outer join ATTESTATION_PRESENCE_STAGIAIRE attestatio1_ on dossiersta0_.DOSSIER_STAGIAIRE_ID=attestatio1_.ATTESTATION_PRESENCE_STAGIAIRE_DOSSIER_STAGIAIRE_ID_FK left outer join SITUATION_PROFESSIONNELLE situationp2_ on dossiersta0_.DOSSIER_STAGIAIRE_SITUATION_PROFESSIONNELLE_ID_FK=situationp2_.SITUATION_PROFESSIONNELLE_ID left outer join ISSUE_CONTRAT issuecontr3_ on dossiersta0_.DOSSIER_STAGIAIRE_ISSUE_CONTRAT_ID_FK=issuecontr3_.ISSUE_CONTRAT_ID left outer join DIPLOME diplome4_ on dossiersta0_.DOSSIER_STAGIAIRE_DIPLOME_ID_FK=diplome4_.DIPLOME_ID left outer join EMPLOI emploi5_ on dossiersta0_.DOSSIER_STAGIAIRE_EMPLOI_CODE_FK=emploi5_.EMPLOI_CODE left outer join CATEGORIES_SOCIAUX_PROFESSIONNELLES categories6_ on emploi5_.EMPLOI_CATEGORIES_SOCIAUX_PROFESSIONNELLES_CODE_FK=categories6_.CATEGORIES_SOCIAUX_PROFESSIONNELLES_CODE where dossiersta0_.DOSSIER_STAGIAIRE_ID=?
Not easy to read, but obviously wrong
Here's the SQL Exception (manually re-translated though):
com.jnetdirect.jsql.v: column prefix 'attestatio1__1_' doesn't correspond neither to table name nor to alias used in the request
Here're the mappings:
Code:
<hibernate-mapping>
<class name="org.xx.dossierstagiaire.model.AttestationPresence" table="ATTESTATION_PRESENCE" lazy="true">
<meta attribute="extends" inherit="false">org.xx.persistence.BusinessObject</meta>
<cache usage="read-write"/>
<id name="attestationPresenceId" type="java.lang.Long" column="ATTESTATION_PRESENCE_ID">
<generator class="identity"/>
</id>
<property name="attestationPresenceDateDebut" type="java.util.Date" column="ATTESTATION_PRESENCE_DATE_DEBUT" not-null="true"/>
<property name="attestationPresenceDateFin" type="java.util.Date" column="ATTESTATION_PRESENCE_DATE_FIN" not-null="true"/>
<property name="attestationPresenceEtatInterruption" type="java.lang.Byte" column="ATTESTATION_PRESENCE_ETAT_INTERRUPTION" not-null="true"/>
<property name="attestationPresenceDureeHeurePresence" type="java.lang.Double" column="ATTESTATION_PRESENCE_DUREE_HEURE_PRESENCE" not-null="true"/>
<property name="attestationPresenceDureeHeureAbsence" type="java.lang.Double" column="ATTESTATION_PRESENCE_DUREE_HEURE_ABSENCE" not-null="true"/>
<property name="attestationPresenceDureeHeureTotal" type="java.lang.Double" column="ATTESTATION_PRESENCE_DUREE_HEURE_TOTAL" not-null="true"/>
<property name="attestationPresenceHeureNonAttestee" type="java.lang.Double" column="ATTESTATION_PRESENCE_HEURE_NON_ATTESTEE"/>
<property name="attestationPresenceCommentaire" type="java.lang.String" column="ATTESTATION_PRESENCE_COMMENTAIRE"/>
<property name="attestationPresenceDateCreation" type="java.util.Date" column="ATTESTATION_PRESENCE_DATE_CREATION" not-null="true"/>
<property name="attestationPresenceDateMaj" type="java.util.Date" column="ATTESTATION_PRESENCE_DATE_MAJ" not-null="true"/>
<many-to-one name="attestationPresenceUserCodeFk" column="ATTESTATION_PRESENCE_UTILISATEUR_CODE_FK" class="org.xx.user.model.User" not-null="true"/>
<joined-subclass name="org.xx.dossierstagiaire.model.AttestationPresenceStagiaire" table="ATTESTATION_PRESENCE_STAGIAIRE" lazy="true">
<key column="ATTESTATION_PRESENCE_STAGIAIRE_ID_FK"/>
<many-to-one name="dossierStagiaire" class="org.xx.dossierstagiaire.model.DossierStagiaire" not-null="true">
<column name="ATTESTATION_PRESENCE_STAGIAIRE_DOSSIER_STAGIAIRE_ID_FK"/>
</many-to-one>
</joined-subclass>
<joined-subclass name="org.xx.dossierstagiaire.model.AttestationPresenceMasse" table="ATTESTATION_PRESENCE_MASSE" lazy="true">
<key column="ATTESTATION_PRESENCE_MASSE_ID_FK"/>
<many-to-one name="dossierFormationStd" class="org.xx.dossierformation.model.DossierFormationStd" not-null="true">
<column name="ATTESTATION_PRESENCE_MASSE_DOSSIER_FORMATION_STD_ID_FK"/>
</many-to-one>
</joined-subclass>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping>
<class name="org.xx.dossierstagiaire.model.DossierStagiaire" table="DOSSIER_STAGIAIRE" lazy="true">
<meta attribute="extends" inherit="false">org.xx.persistence.BusinessObject</meta>
<cache usage="read-write"/>
<id name="dossierStagiaireId" type="java.lang.Long" column="DOSSIER_STAGIAIRE_ID">
<generator class="identity"/>
</id>
<property name="dossierStagiaireNom" type="java.lang.String" column="DOSSIER_STAGIAIRE_NOM" not-null="true"/>
<property name="dossierStagiairePrenom" type="java.lang.String" column="DOSSIER_STAGIAIRE_PRENOM"/>
<property name="dossierStagiaireNumeroSecuSexe1" type="java.lang.Integer" column="DOSSIER_STAGIAIRE_NUMERO_SECU_SEXE_1" not-null="true"/>
<property name="dossierStagiaireNumeroSecuAge2" type="java.lang.String" column="DOSSIER_STAGIAIRE_NUMERO_SECU_AGE_2" not-null="true"/>
<property name="dossierStagiaireNumeroSecuMois3" type="java.lang.String" column="DOSSIER_STAGIAIRE_NUMERO_SECU_MOIS_3"/>
<property name="dossierStagiaireNumeroSecuDept4" type="java.lang.String" column="DOSSIER_STAGIAIRE_NUMERO_SECU_DEPT_4"/>
<property name="dossierStagiaireNumeroSecuInsee5" type="java.lang.String" column="DOSSIER_STAGIAIRE_NUMERO_SECU_INSEE_5"/>
<property name="dossierStagiaireNumeroSecuCpt6" type="java.lang.String" column="DOSSIER_STAGIAIRE_NUMERO_SECU_CPT_6"/>
<property name="dossierStagiaireInitiativeStage" type="java.lang.String" column="DOSSIER_STAGIAIRE_INITIATIVE_STAGE" not-null="true"/>
<property name="dossierStagiaireAdresse1" type="java.lang.String" column="DOSSIER_STAGIAIRE_ADRESSE1"/>
<property name="dossierStagiaireAdresse2" type="java.lang.String" column="DOSSIER_STAGIAIRE_ADRESSE2"/>
<property name="dossierStagiaireCp" type="java.lang.String" column="DOSSIER_STAGIAIRE_CP"/>
<property name="dossierStagiaireVille" type="java.lang.String" column="DOSSIER_STAGIAIRE_VILLE"/>
<property name="dossierStagiaireTelephone" type="java.lang.String" column="DOSSIER_STAGIAIRE_TELEPHONE"/>
<property name="dossierStagiaireSalaireMensuel" type="java.lang.Double" column="DOSSIER_STAGIAIRE_SALAIRE_MENSUEL"/>
<property name="dossierStagiaireNbreHeureTravailleMois" type="java.lang.Integer" column="DOSSIER_STAGIAIRE_NBRE_HEURE_TRAVAILLE_MOIS"/>
<property name="dossierStagiaireEtatHtt" type="java.lang.Byte" column="DOSSIER_STAGIAIRE_ETAT_HTT" not-null="true"/>
<property name="dossierStagiaireNbreHeureHtt" type="java.lang.Short" column="DOSSIER_STAGIAIRE_NBRE_HEURE_HTT"/>
<property name="dossierStagiaireEtatDif" type="java.lang.Byte" column="DOSSIER_STAGIAIRE_ETAT_DIF" not-null="true"/>
<property name="dossierStagiaireTypeContrat" type="java.lang.String" column="DOSSIER_STAGIAIRE_TYPE_CONTRAT"/>
<property name="dossierStagiaireDateFinContrat" type="java.util.Date" column="DOSSIER_STAGIAIRE_DATE_FIN_CONTRAT"/>
<property name="dossierStagiaireNbreHeurePrevu" type="java.lang.Short" column="DOSSIER_STAGIAIRE_NBRE_HEURE_PREVU"/>
<property name="dossierStagiaireDateDebutContrat" type="java.util.Date" column="DOSSIER_STAGIAIRE_DATE_DEBUT_CONTRAT"/>
<property name="dossierStagiaireEtatFseAnnee1" type="java.lang.Byte" column="DOSSIER_STAGIAIRE_ETAT_FSE_ANNEE1"/>
<property name="dossierStagiaireEtatFseAnnee2" type="java.lang.Byte" column="DOSSIER_STAGIAIRE_ETAT_FSE_ANNEE2"/>
<property name="dossierStagiaireEtatFseAnnee3" type="java.lang.Byte" column="DOSSIER_STAGIAIRE_ETAT_FSE_ANNEE3"/>
<property name="dossierStagiaireSanctionDiplome" type="java.lang.String" column="DOSSIER_STAGIAIRE_SANCTION_DIPLOME"/>
<property name="dossierStagiaireCommentaire" type="java.lang.String" column="DOSSIER_STAGIAIRE_COMMENTAIRE"/>
<property name="dossierStagiaireStatut" type="java.lang.String" column="DOSSIER_STAGIAIRE_STATUT" not-null="true"/>
<property name="dossierStagiaireDateCreation" type="java.util.Date" column="DOSSIER_STAGIAIRE_DATE_CREATION" not-null="true"/>
<property name="dossierStagiaireDateMaj" type="java.util.Date" column="DOSSIER_STAGIAIRE_DATE_MAJ" not-null="true"/>
<!-- associations -->
<!-- bi-directional one-to-many association to AttestationPresence -->
<!-- WARNING: the outer-join MUST be set to FALSE, might be a Hibernate Bug -->
<set name="attestationsPresences" lazy="true" inverse="true" sort="org.xx.dossierstagiaire.service.AttestationPresenceComparator" cascade="all-delete-orphan" outer-join="true">
<key column="ATTESTATION_PRESENCE_STAGIAIRE_DOSSIER_STAGIAIRE_ID_FK"/>
<one-to-many class="org.xx.dossierstagiaire.model.AttestationPresenceStagiaire"/>
</set>
<set name="engagements" inverse="false" lazy="true" order-by="ENGAGEMENT_ID asc" cascade="all-delete-orphan" outer-join="true">
<key column="ENGAGEMENT_DOSSIER_STAGIAIRE_ID_FK"/>
<one-to-many class="org.xx.engagementremboursement.model.Engagement"/>
</set>
<set name="remboursements" inverse="false" lazy="true" order-by="REMBOURSEMENT_ID asc" cascade="delete-orphan" outer-join="true">
<key column="REMBOURSEMENT_DOSSIER_STAGIAIRE_ID_FK"/>
<one-to-many class="org.xx.engagementremboursement.model.Remboursement"/>
</set>
<!-- bi-directional many-to-one association to SituationProfessionnelle -->
<many-to-one name="situationProfessionnelle" class="org.xx.dossierstagiaire.model.SituationProfessionnelle" not-null="true">
<column name="DOSSIER_STAGIAIRE_SITUATION_PROFESSIONNELLE_ID_FK"/>
</many-to-one>
<!-- bi-directional many-to-one association to IssueContrat -->
<many-to-one name="issueContrat" class="org.xx.dossierstagiaire.model.IssueContrat">
<column name="DOSSIER_STAGIAIRE_ISSUE_CONTRAT_ID_FK"/>
</many-to-one>
<!-- bi-directional many-to-one association to Diplome -->
<many-to-one name="diplome" class="org.xx.dossierstagiaire.model.Diplome">
<column name="DOSSIER_STAGIAIRE_DIPLOME_ID_FK"/>
</many-to-one>
<!-- bi-directional many-to-one association to Emploi -->
<many-to-one name="emploi" class="org.xx.dossierstagiaire.model.Emploi" not-null="true">
<column name="DOSSIER_STAGIAIRE_EMPLOI_CODE_FK"/>
</many-to-one>
<!-- bi-directional many-to-one association to DossierAdherent -->
<many-to-one name="dossierStagiaireDossierAdherentIdFk" class="org.xx.dossieradherent.model.DossierAdherent">
<column name="DOSSIER_STAGIAIRE_DOSSIER_ADHERENT_ID_FK" not-null="true"/>
</many-to-one>
<many-to-one name="dossierStagiaireUserCodeFk" class="org.xx.user.model.User" cascade="none" not-null="true">
<column name="DOSSIER_STAGIAIRE_UTILISATEUR_CODE_FK"/>
</many-to-one>
</class>
</hibernate-mapping>
The exception doesn't occur any more when setting outer-join to false or auto. Note that It also doesn't occur when I instanciate myself the DOSSIER_STAGIAIRE.
Regards,
nodje