This week's book giveaway is in the
We're giving away four copies of
Node.js in Action
and have Mike Cantelon, Marc Harter, T.J. Holowaychuk and Nathan Rajlich on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Node.js in Action
this week in the
Object Relational Mapping
hibernate, mapping using discriminator - need idea
Joined: May 05, 2011
Mar 07, 2012 11:49:14
I Have a table(student) with columns stu_id, stu_name, favourite_subject, subject_id
favourite_subject will have predefined values like maths,english etc. if the value is maths, subject_id will have table: maths_subject's id.
meaning, based on favourite_subject value, subject_id will be pointing to the corresponding subject's id.
How can i implement in Hibernate ORM Framework.
<hibernate-mapping package="com.sample.project"> <class name="StudentDTO" table="student"> <meta attribute="class-description">class to hold student data</meta> <id name="id" type="long" column="stu_id"> <generator class="increment"/> </id> <discriminator column="favourite_subject" type="string"/> <property name="studentName" column="stu_name" not-null="true"/> <!--?? here i don't know how to proceed. ??--> <subclass name="??????" discriminator-value="Maths"> ???? </subclass> </class> </hibernate-mapping>
all subjects will have their own tables & own corresponding entity classes.
Joined: Mar 24, 2008
Mar 10, 2012 00:51:56
Look at the example for discriminator strategy provided for Hibernate
SCJP 5 | SCWCD 5
How to ask questions
I agree. Here's the link:
subject: hibernate, mapping using discriminator - need idea
mapping question (hashmap and subclasses)
Hibernate - Using subclass and joined-subclass element
Simple mapping issue for Hibernate newbie
Querying from inheritance hierarchy
Problem with one-to-one mapping using discriminator
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014