-->
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.  [ 2 posts ] 
Author Message
 Post subject: Override an attribute and declaring it as @Id
PostPosted: Tue Jan 20, 2009 12:07 am 
Newbie

Joined: Mon Jan 19, 2009 11:56 pm
Posts: 1
Hi, I'm new to JPA/Hibernate and recently purchased "Java Persistence With Hibernate", so please bear with me.

Consider the following. My question is inline.
Thank you so much for any help!

Marcos

Code:
@MappedSuperclass
class User {
    private String username;
    // setters/getters...
}

@Entity
class SubUser extends User {

   // How can I specify that I want the
   // inherited username to be the PK of this entity (@Id)
   // without changing the definition of User???

}



Hibernate version: 3


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2009 5:12 am 
Beginner
Beginner

Joined: Wed Nov 26, 2008 1:02 am
Posts: 22
hi,

In subclasses, you don’t need to specify the join column if the primary key column of the subclass table has (or is supposed to have) the same name as the primary key column of the superclass table.


Hibernate will automatically do this for us.

hope this solves,

_________________
if it solves,rate me


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.