-->
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: Complicated mapping problem
PostPosted: Fri Sep 07, 2007 6:13 am 
Newbie

Joined: Thu Aug 30, 2007 4:39 am
Posts: 2
Location: Roma, Italy
Hello,

I have a complicated mapping problem:
Consider the following db schema: Image

I need to map this to the following beans, and unfortunately I can't change nor the bean structure neither the db schema.

Code:
public class EOActivity extends BaseBean implements Serializable {
    private String activityName;
    private Set<EOUser> eoUser;
...

public class EOUser extends BaseBean implements Serializable {
    private String eoUserId;
    private EOUserAddress eoUserAddress;
...


public class EOUserAddress extends BaseBean implements Serializable {
    private Recipient recipient;
    private String email;
    private String telephone;
    private String fax;
    private String addressType;
    private PostalAddressInfo postalAddress;
    private FtpAccount ftpAccount;
    private String organisationName;
....


So far I have tried the following mappings:

Code:
<class name="EOActivity" table="cdb_eo_activities">
        <id name="activityName" column="activity"/>
        <set name="eoUser" lazy="false" fetch="join" cascade="all">
             <key foreign-key="none">
                 <column name="customerId"/> 
                 <column name="activity"/>
             </key>
             <one-to-many class="EOUser"/>
         </set>
    </class>

    <class name="EOUser" table="cdb_eo_activity_address">
        <id name="eoUserId" column="eoUserId"/>
        <set name="eOUserAddress" lazy="false" fetch="join" cascade="all">
             <key foreign-key="none">
                 <column name="customerId"/>
                 <column name="activity"/>
                 <column name="eoUserId"/>
             </key>
             <one-to-many class="EOUserAddress"/>
         </set>
    </class>

    <class name="EOUserAddress" table="cdb_eo_activity_address">
        <id name="addressType"/>
        <component name="recipient">
            <property name="title"/>
            <property name="firstName"/>
            <property name="surName"/>
        </component>
        <property name="telephone"/>
        <property name="fax"/>
        <property name="email"/>
        <property name="organisationName"/>
        <many-to-one name="ftpAccount" class="FtpAccount" lazy="false" fetch="join"/>            <!-- no cascade -->
        <many-to-one name="postalAddress" class="PostalAddressInfo" lazy="false" fetch="join"/>  <!-- no cascade -->
    </class>


This doesn't work: "collection foreign key mapping has wrong number of columns", due to the non-declaration of the composite primary key in EOUser (which I can't declare there, because I can only have 'eoUserId' in the EOUser bean). I know the db schema is sh*t (no direct PK's, only foreign keys which form a PK), but I'd like to know if it is possible to map this with Hibernate.
Thanks in advance.

Joris


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.