-->
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: Surrogate key for value type?
PostPosted: Tue Dec 23, 2008 5:08 am 
Newbie

Joined: Tue Aug 19, 2008 9:30 am
Posts: 10
I know, value types have no database identity but does that mean Hibernate cann't create an id for them?

I'm modelling a martial art teacher class. A Teacher has 0..n Graduations.

Code:
class Graduation{
  //e.g. "Aikido","Aikikai","2.Dan"
  String martialArt,organisation,graduation;
}


Because Graduation is totally dependent on Teacher, it should be a value type. But i have a webpage where a teacher can update his graduation if he got promoted. The natural key for this page would be the teacherID, the martialArt and the organisation, but i wonder if i could give an surrogate id to Graduation just as if it would be an entity?

Code:
@Embeddable
class Graduation{
  @ID @GeneratedValue
  private Long id;
  ...
}


I guess session.get( Graduation.class,id) won't be possible because it's no entity but session.createQuerry("from Graduation g where g.id=:id") should work, shouldn't it?

/Stephan


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.