Hi,
I´ve got two objects, that are extended from each other. For example they look
like this:
| @Entity
| @Table(name = "users")
| @Name("user")
| @Scope(ScopeType.SESSION)
| public class User implements Serializable {
|
| @Column(name = "create_date", nullable = false)
| @Temporal(TemporalType.TIMESTAMP)
| private Date createDate;
|
| @Length(min=6)
| @Column(name = "password", nullable = false)
| private String password;
|
| @Column(name = "name", nullable = false)
| private String name;
|
| ....
| }
|
| @Entity
| @Table(name = "extendedUser")
| @Name("publisher")
| @Scope(ScopeType.SESSION)
| public class ExtendedUser extends User implements Serializable {
|
| @Column(name = "upgrade_date", nullable = false)
| @Temporal(TemporalType.TIMESTAMP)
| private Date upgradeDate;
|
| ....
| }
|
I´ve also got 2 tables. One holds all the attributes for the user and the other
one holds only the additional attributes of the extendedUser all with the same
primaryKey. What I would like to do now is to upcast my User to an
ExtendedUser, so that it keeps all the values in the user-table and creates an
entry in my extended-users table with all additional values of the extended
object.
When I simply upcast my object and try to persist it with an
em.merge(extendedUser) I get an Exception because it tries to persist a
completely new extendedUser, which is absolutely correct, because it should
only add the additional values and not create a new entry.
Is there a way to do an upcast/downcast and adding/deleting only the additional
attributes of the inherited objects?
Thanks for your help
Thomas
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4005398#4005398
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4005398
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user