-->
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.  [ 1 post ] 
Author Message
 Post subject: building query on joined-subclass mapping
PostPosted: Thu Jun 03, 2004 11:39 am 
Regular
Regular

Joined: Fri Nov 07, 2003 6:31 am
Posts: 104
Location: Beijing, China
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


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

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.