-->
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: Calculated Primary Key - possible spec discussion?
PostPosted: Tue Aug 19, 2008 9:30 am 
Regular
Regular

Joined: Fri Jul 30, 2004 4:02 pm
Posts: 50
Hey all,
Here is the base of the conversation:

A table has a primary key. This primary key could be a composite key, and could be a composite key that there is no associated technical key.

An entity/pojo also should/need to have a way for it to be uniquely identified. In JPA spec, that is with the @Id annotation.


So -- what happens when you have many-to-many mapping tables exposed, or mini-FACT tables that are multiple many-to-many mappings and therefore large composite keys?


Let's take for example a security table where a user does work on behalf of other people based on specific roles:

USER_ID
BEHALF_ID
ROLE_ID

triple-key composite entity/pojo (let's assume you are not going to always work with associations).

Since the only fields for this entity/pojo are those three fields, by convention you create an SecurityId class that is embedded as the ID of the entity/dto....but that's the only thing in it!

Is there a practice to have the three fields just directly visible in the entity/dto, but have a 'calculated' field (like the hashCode) be the @Id annotation even though it would be transient when trying to save back to the database?


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.