File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
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:
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: hibernate, mapping using discriminator - need idea
mapping question (hashmap and subclasses)
Querying from inheritance hierarchy
Hibernate - Using subclass and joined-subclass element
Simple mapping issue for Hibernate newbie
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-2013