-->
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.  [ 2 posts ] 
Author Message
 Post subject: Need help on a many to one mapping
PostPosted: Mon Sep 03, 2007 7:49 am 
Newbie

Joined: Mon Sep 03, 2007 7:40 am
Posts: 1
Location: India
Ok I Have 2 tables Account and Contact
with the following mappings

<class name="Account" table="account" mutable="false">
<id name="id" type="string" length="11" column="id">
<generator class="increment"></generator>
</id>
<property name="name" type="string" length="120" column="name" />
<set name="contact" table="contact_info" inverse="true">
<key column="id"></key>
<one-to-many class="Contact" />
</set>
</class>


<class name="Contact" table="contact_info" mutable="false">
<id column="contact_info_id" name="id" />
<many-to-one name="id" column="contact_info_id" class="Account" insert="false" update="false"/>
<property name="type" type="string" length="11" column="info_type" />
<property name="info" type="string" length="120" column="contact_info_dtls" />
</class>


Now i have a property in my Account class called defaultEmail whose value is in Contact....i have a field type which may have values 'MAIL','PHONE' as the case may be depending upon which value I have to extract and place it in Account.defaultEmail..

Now i need a mapping which would autopopulate the value of defaultEmail when i call the getHibernateTemplate().find("from Account acc "); from Java DAO


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 03, 2007 9:25 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
This seems to be business logic

Why don't you put code in your getDefaultEmail method that does the job ?

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.