-->
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: How to use formula when mapping a set?
PostPosted: Sat Aug 15, 2009 4:46 am 
Newbie

Joined: Sat Aug 15, 2009 4:26 am
Posts: 1
See my following mapping xml. Say,I have student table ,course table,book table. And use student_link table to handle many to many mapping. Course and book is many to many mapping through course_book_link table as well.
Now I want to add a derived property in Student.java which is defined like:Set<String> bookNames;//which represents all books need for this student

I'm trying on the "formula" with the table join SQL statement. it works fine for single property, but does not work for Set.
As you can see, the family is a derived column retrived through formula.

Any idea about this?

Thanks in advance

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ms.itlnc.dms.workItem.poc.data">
<class name="Student" entity-name="Student" table="Student" >
<id name="sid" type="int">
<column name="sid" />
<generator class="native" />
</id>
<version name="version">
<column name="VERSION" />
</version>
<property name="sname">
<column name="sname" />
</property>
<property name="sage">
<column name="sage" />
</property>


<property name="family" type="string"
formula="(select f.fname from student_family_link l,family f where l.student_id=sid and l.object_id=f.fid)" />


<set name="courses" >
<element type="string"
formula="select b.bname
from student_link l,course c,course_book_link l2,book b
where l.student_id=sid and l.cid=c.cid and c.cid=l2.cid and l2.bid=b.bid" />
</set>


</class>
</hibernate-mapping>


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.