-->
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.  [ 5 posts ] 
Author Message
 Post subject: need help with one-to-many
PostPosted: Thu Aug 27, 2009 5:32 am 
Newbie

Joined: Thu Aug 13, 2009 4:52 am
Posts: 12
hi there!

i have to tables:

fads: (contains customer-records ... can have n contacts [1:n])
this two columns identify a customer: ADSKEY, ADSBETNR

kontakt: (contains contacts with a customer ... n contacts belong to 1 customer [n:1])
primary key: koknr
columns to identify the customer, to which the contact is related: kokdnr (=fads.ADSKEY) and korgbt (=fads.ADSBETNR)

there are no foreign keys set up.

i already have mapped the tables (Fads.java, FadsDAO.java, FadsId.java, Fads.hbm.xml, Kontakt.java, KontaktDAO.java, Kontakt.hbm.xml)

now i fail at creating a one-to-many - association ..
and how do i get the contacts by the fads - object?

i already tried to edit the Fads.hbm.xml, but without success

Fads.hbm.xml
Code:
<hibernate-mapping>
    <class name="hibernate.mappings.Fads" table="fads" catalog="">
        <composite-id name="id" class="hibernate.mappings.FadsId">
            <key-property name="adskey" type="java.lang.Integer">
                <column name="ADSKEY" />
            </key-property>
            <key-property name="adsbetnr" type="java.lang.Integer">
                <column name="ADSBETNR" />
            </key-property>
        </composite-id>
        <property name="adsanr" type="java.lang.Short">
            <column name="ADSANR" not-null="true" />
        </property>
      <!-- .. and much more properties .. -->

   <!-- should something like this work? -->
        <map name="kontakte" cascade="all">
           <key not-null="true">
              <column name="ADSKEY"></column>
            <column name="ADSBETNR"></column>
           </key>
           <map-key formula="(select ko.koknr from Kontakt where ko.adskey=Fads.id.adskey and ko.adsbetnr=Fads.id.adsbetnr" type="string"/>
           <one-to-many class="hibernate.mappings.Kontakt"
                   not-found="ignore"  />
        </map>

    </class>
</hibernate-mapping>


thanks in advance


Top
 Profile  
 
 Post subject: Re: need help with one-to-many
PostPosted: Tue Nov 24, 2009 1:41 am 
Newbie

Joined: Tue Nov 24, 2009 1:32 am
Posts: 1
Hi,
You got the solution for this error?

I also got stuck here,
Please reply.
Thanks ,
Gopal Patil
patil.gopal.a@gmail.com


Top
 Profile  
 
 Post subject: Re: need help with one-to-many
PostPosted: Tue Nov 24, 2009 5:32 am 
Newbie

Joined: Thu Aug 13, 2009 4:52 am
Posts: 12
i'm sorry, but i can't offer a solution...

kind regards
lenaz


Top
 Profile  
 
 Post subject: Re: need help with one-to-many
PostPosted: Tue Nov 24, 2009 6:08 am 
Newbie

Joined: Sun Nov 22, 2009 6:42 pm
Posts: 7
what error are you getting?

you seem to be on the right track, but I'm very new to Hibernate, so I'm not sure..


Top
 Profile  
 
 Post subject: Re: need help with one-to-many
PostPosted: Tue Nov 24, 2009 6:50 am 
Newbie

Joined: Thu Aug 13, 2009 4:52 am
Posts: 12
org.hibernate.exception.SQLGrammarException: could not load an entity: [hibernate.mappings.Fads#component[adskey,adsbetnr]{adsbetnr=1, adskey=1}]

Hibernate builds an erroneous sql-statement

edit: sorry for being unaccurate, but i have to do some other stuff just right now..


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

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.