Hi,
I have the 'Customer' entity in my application that's a subclass the 'Person' entity (using the Joined strategy). I have one instance of 'Person', and i would like to append only the data from the 'Customer', without changing the id of 'Person'. It's like 'transforming' one Person to a Customer.
I have the person data in the table like this:
PERSON
--------------------------
|PERSON_ID | NAME |
--------------------------
|1 | John |
--------------------------
And i would like only to append the Customer data, inserting the following row:
CUSTOMER
-------------------------------
|CUST_ID | CUST_RANK |
-------------------------------
|1 | A |
-------------------------------
Is there a way of doing such thing???
The mapping's for the entities are:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="PERSON_ID")
private Integer id;
private String name;
//getter's and setter's ommited
}
@Entity
@PrimaryKeyJoinColumn(name="CUST_ID")
public class Customer extends Person {
@Column(name="CUST_RANK")
private String rank;
//getter's and setter's ommited
}
Thanks a lot,
Elton.
|