-->
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: Native SQL query and collection many-to-many
PostPosted: Wed May 19, 2004 8:13 am 
Beginner
Beginner

Joined: Mon Mar 29, 2004 12:41 pm
Posts: 26
Hi all !

I have 3 tables :
- VERSIONDECOMPOSANT,
- ENVIRONNEMENT,
- AS_VERCOMP_ENV : The association table between the two above.

I have the following exception when I try to get my data from the DB :

Code:
Alias [as_vercomp_env] does not correspond to any of the supplied return aliases = {[versiondecomposant]} [Select {versiondecomposant.*} from VERSIONDECOMPOSANT {versiondecomposant} where {versiondecomposant}.IDVERCOMP IN(Select {as_vercomp_env}.IDVERCOMP from AS_VERCOMP_ENV {as_vercomp_env} where {as_vercomp_env}.IDENV IN(51,53) Group By {as_vercomp_env}.IDVERCOMP having count({as_vercomp_env}.IDVERCOMP)=2) AND {versiondecomposant}.IDVERCOMP<>0]


I use CreateSQLQuery(). Why the [as_vercomp_env] alias is not found ? What could be wrong in my SQL query ?

Here are my mapping files :

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class name="majpps.beans.VersionDeComposant" table="versiondecomposant" lazy="false">
        <id name="idVerComp" column="IDVERCOMP" unsaved-value="null">
          <generator class="sequence">
              <param name="seq_versiondecomposant">seq_versiondecomposant</param>
          </generator>
        </id>

        <property name="etat">
         <column name="ETAT" sql-type="NUMBER(1)" not-null="true"/>
      </property>
        <property name="numeroOrdre">
         <column name="NUMEROORDRE" sql-type="VARCHAR2(50)" not-null="true"/>
      </property>
        <property name="version">
           <column name="VERSION" sql-type="VARCHAR2(30)" not-null="true"/>
      </property>
      <property name="isDeTest">
         <column name="ISDETEST" sql-type="NUMBER(1)" not-null="true"/>
      </property>
      <property name="fichier">
         <column name="FICHIER" sql-type="VARCHAR2(50)" not-null="true"/>
      </property>
      <property name="repertoireCible">
         <column name="REPERTOIRECIBLE" sql-type="VARCHAR2(255)" not-null="true"/>
      </property>
      <property name="empreinte">
         <column name="EMPREINTE" sql-type="VARCHAR2(100)" not-null="true"/>
      </property>


        <many-to-one name="composant" column="IDCOMP" not-null="true" cascade="none"/>

      <bag name="environnement" lazy="true" table="as_vercomp_env">
         <key column="IDVERCOMP"/>
         <many-to-many class="majpps.beans.Environnement" column="IDENV"/>
       </bag>

       <bag name="verCompMini" lazy="true" table="as_vercomp_vercompmini">
         <key column="IDVERCOMP"/>
         <many-to-many class="majpps.beans.VersionDeComposant" column="IDVERCOMPMINI"/>
       </bag>

    </class>

</hibernate-mapping>
<!-- parsed in 0ms -->

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
   <class name="majpps.beans.Environnement" table="environnement" lazy="false">
        <cache usage="read-write"/>

        <id name="idEnv" column="IDENV" unsaved-value="null">
            <generator class="sequence">
                <param name="seq_environnement">seq_environnement</param>
            </generator>
        </id>

        <discriminator column="TYPE_ENVIR" type="string"/>

        <property name="Nom">
         <column name="NOM" sql-type="VARCHAR2(50)" not-null="true"/>
      </property>

      <subclass name="majpps.beans.SolutionLecteur" lazy="false" discriminator-value="LECTEUR">
               <property name="Nom" insert="false" update="false">
                  <column name="NOM" sql-type="VARCHAR2(50)" not-null="true"/>
               </property>
      </subclass>

      <subclass name="majpps.beans.EnvironnementPoste" lazy="false" discriminator-value="POSTE">
         <property name="Nom" insert="false" update="false">
            <column name="NOM" sql-type="VARCHAR2(50)" not-null="true"/>
         </property>
         <property name="version">
            <column name="VERSION" sql-type="VARCHAR2(50)" not-null="true"/>
         </property>
         <property name="code">
            <column name="CODE" sql-type="VARCHAR2(50)" not-null="true"/>
         </property>
      </subclass>

   </class>

</hibernate-mapping>
<!-- parsed in 0ms -->


Thank you !! =)


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.