-->
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: Unique property declared in superclass but used in child?
PostPosted: Fri Dec 22, 2006 3:14 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 1:52 pm
Posts: 40
I have a parent class that has a field that I want to use in the unique constraing of many of the child classes. Is this possible, or do I need to simply move this field to the child class?


Code:
class Parent {
   String name;
}
class ChildOne extends Parent {
}
class ChildTwo extends Parent {
}


What I want is that each ChildOne will have a unique name with respect to other ChildOne instances. Each ChildTwo will have a unique name with respect to other ChildTwo instances. It does not matter if ChildOne and ChildTwo share the same name.

Possible, without moving name to child? I am using joined-subclass. Obviously Hibernate is going to have to put the 'name' property in the child table to accomplish this.

Having name on the parent class is the more OO way, but its not a big deal to move it.


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.