openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Beer <david.m.b...@googlemail.com>
Subject Re: Multiple Identity for a class
Date Wed, 16 Feb 2011 23:31:19 GMT
Hi Mike

Thanks for your reply I have since looked again at this and have decided
to make the separate classes and to ignore the inheritance route to many
constraints. I also had redesign of the base app and the relationship
between the objects and real world. Thinking more along the lines of
separation as well. As the authentication part should have nothing to do
with the rest of the data.

Thanks again.

David

On Wed, 2011-02-16 at 13:23 -0600, Michael Dick wrote:
> Hi David,
> 
> I think you're going to need to use a composite ID, or an embedded ID
> in your subclass, and that's going to get messy. At least in the
> composite ID case the subclass ID needs to extend its parent's ID.
> OpenJPA's default IDs are final - so you'll need one for Person, even
> though it has only one ID field. 
> 
> I'm not sure I understand the need to modify the ID in your hierarchy.
> What are you using for your inheritance strategy? My initial advice
> would be to avoid this path, unless there's a compelling reason. 
> 
> -mike
> 
> On Sun, Feb 13, 2011 at 12:27 PM, David Beer
> <david.m.beer@googlemail.com> wrote:
>         Hi All
>         
>         I have a class that extends a entity with a standard ID in. In
>         the
>         extended class I want to add another id field say userID. What
>         would be
>         the best way of doing this.
>         
>         My classes are structured as follows:
>         
>         @Entity
>         public class Person implements Serializable {
>         
>            private static final long serialVersionUID = 1L;
>            @Id
>            @GeneratedValue(strategy = GenerationType.AUTO)
>            private Long id;
>         
>            //other fields and methods omitted
>         
>         }
>         
>         @Entity
>         public class Userbase extends Person {
>         
>            private Long userID; //other identity field
>         
>            // other values omitted
>         }
>         
>         What would be the best way of achieving this. Would an
>         Identity class be
>         sensible. If so are the any examples that use this method.
>         
>         Thanks
>         
>         David
>         
> 



Mime
View raw message