Let's say I have the following three entities:
Code:
@Entity (access = AccessType.FIELD)
@Inheritance (strategy = InheritanceType.JOINED)
public class Account
implements java.io.Serializable
{
@Basic
private String userName ;
@Basic
private String password ;
// etc...
}
@Entity (access = AccessType.FIELD)
public class Customer
extends Account
implements java.io.Serializable
{
@ManyToOne
private Address address
// etc...
}
@Entity (access = AccessType.FIELD)
public class Admin
extends Account
implements java.io.Serializable
{
@OneToMany
private Set<Permission> permissions ;
// etc..
}
I can create one type of account or another, simply by constructing the object and calling:
Code:
session.saveOrUpdate (new Admin()) ;
session.saveOrUpdate (new Customer ()) ;
Likewise I can query.
However, what if I have an already persisted Admin object, and I would like to make it also a Customer? How can I make it such that there is one entry in the Account table that corresponds to one entry each in the Admin and Customer tables?
Thanks...