File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes hibernate, mapping using discriminator - need idea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate, mapping using discriminator - need idea" Watch "hibernate, mapping using discriminator - need idea" New topic

hibernate, mapping using discriminator - need idea

Krishnaa Kumar

Joined: May 05, 2011
Posts: 25
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.

all subjects will have their own tables & own corresponding entity classes.
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3775

Look at the example for discriminator strategy provided for Hibernate here.

[How to ask questions] [Twitter]
I agree. Here's the link:
subject: hibernate, mapping using discriminator - need idea
Similar Threads
Simple mapping issue for Hibernate newbie
Problem with one-to-one mapping using discriminator
Querying from inheritance hierarchy
mapping question (hashmap and subclasses)
Hibernate - Using subclass and joined-subclass element