openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: Multiple Identity for a class
Date Wed, 16 Feb 2011 19:23:42 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message