-->
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: Mapping Serveral Classes to Table
PostPosted: Mon Dec 02, 2013 9:58 pm 
Newbie

Joined: Sun Dec 01, 2013 4:38 pm
Posts: 2
I am new to Hibernate and trying to connect to a legacy database that I have not control over.

I have a database table that holds all of the statuses for the system. It has a composite key of (Table Name, Code). Eg...

Code:
Table Name   Code       Description
----------   -----      -----------
INV_STS      ACTIVE      Invoice has been issued
INV_STS      PENDING      Invoice is pending
INV_STS      CANCEL      Invoice is cancelled
JOB_STS      ACTIVE      Job is Active
JOB_STS      FINISH      Job is Finished


So what I am attempting to do is have an Many-to-One relationship to the Invoice Status on the Invoice class and a Many-to-One relationship to the Job Status on the Job class. But have not been able to do it.

I have attempted to use inheritance, but the discriminator field also part of the composite key. If I map it I get ....
Quote:
org.hibernate.MappingException: Repeated column in mapping for entity: nz.co.xxxxx.bo.entity.status.Hib_JobStatus column: TBTABL (should be mapped with insert="false" update="false").

Obviously, if the discriminator column is not part of the Id then hibernate retrieves return multiple rows when it should only return 1 (eg. "ACTIVE" is a valid code for Invoice Status as well as Job Status). I have tried many combinations to try and get it to work without success.

I read about Filtering but it didn't seem appropriate, the Table name is not really dynamic and seems a real overkill.

So, please tell me what would be the best approach. I could have included my latest experiment but was not sure it would add much value, my question is really what is the best approach. However, if you answer, an example (using annotations if possible) would be very much appreciated.

Thank you :)


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.