Hi everyone,
I've got the following mapped table:
Code:
<hibernate-mapping>
<class name="org.xx.dossieradherent.model.ArchiveDossier" table="ARCHIVE_DOSSIER" lazy="true">
<id name="id" column="ARCHIVE_DOSSIER_ID" type="java.lang.Long">
<generator class="identity"/>
</id>
<property name="archiveDossierStatut" column="ARCHIVE_DOSSIER_STATUT" type="java.lang.String" not-null="true"/>
<property name="archiveDossierNumero" column="ARCHIVE_DOSSIER_NUMERO" type="java.lang.Short" not-null="true" unique="true"/>
<property name="archiveDossierCompteur" column="ARCHIVE_DOSSIER_COMPTEUR" type="java.lang.Integer" not-null="true"/>
<property name="archiveDossierDateCreation" column="ARCHIVE_DOSSIER_DATE_CREATION" type="java.util.Date" not-null="true"/>
<property name="archiveDossierDateMaj" column="ARCHIVE_DOSSIER_DATE_MAJ" type="java.util.Date" not-null="true"/>
<many-to-one name="archiveDossierUserCodeFk" column="ARCHIVE_DOSSIER_UTILISATEUR_CODE_FK" class="org.xx.user.model.User" not-null="true"/>
<joined-subclass name="org.xx.dossieradherent.model.ArchiveDossierAdherent" table="ARCHIVE_DOSSIER_ADHERENT" lazy="true">
<key column="ARCHIVE_DOSSIER_ADHERENT_ARCHIVE_DOSSIER_ID_FK"/>
<many-to-one name="dossierAdherent" class="org.xx.dossieradherent.model.DossierAdherent" not-null="true" unique="true">
<column name="ARCHIVE_DOSSIER_ADHERENT_DOSSIER_ADHERENT_ID_FK"/>
</many-to-one>
</joined-subclass>
<joined-subclass name="org.xx.dossieradherent.model.ArchiveDossierFormation" table="ARCHIVE_DOSSIER_FORMATION" lazy="true">
<key column="ARCHIVE_DOSSIER_FORMATION_ARCHIVE_DOSSIER_ID_FK"/>
<many-to-one name="dossierFormation" class="org.xx.dossierformation.model.DossierFormation" not-null="true" unique="true">
<column name="ARCHIVE_DOSSIER_FORMATION_DOSSIER_FORMATION_ID_FK"/>
</many-to-one>
</joined-subclass>
</class>
</hibernate-mapping>
and want to query for the ArchiveDossierFormation object that have the highest archiveDossierNumero.
Since it's a joined-subclass table, I thought unlike in SQL I wouldn't need to specify the join in the query:
Code:
createQuery("select max(ad.ArchiveDossierNumero), ad.ArchiveDossierCompteur from ArchiveDossierFormation adf");
This doesn't work, I receive a
Code:
net.sf.hibernate.QueryException: could not resolve property: ArchiveDossierNumero of: org.xx.dossieradherent.model.ArchiveDossierFormation [select max(adf.ArchiveDossierNumero), adf.ArchiveDossierCompteur from org.xx.dossieradherent.model.ArchiveDossierFormation adf]
And since it's a joined-suclass i have got no field on which to make the "join".
Any idea how to do that? Or more generally, how to get a table row from which a field has the max of the whole column?
nodje