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 <[email protected]>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 > >
