-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Inheritance Problem....
PostPosted: Tue Dec 19, 2006 10:32 pm 
Newbie

Joined: Tue Dec 19, 2006 9:57 pm
Posts: 2
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.


Top
 Profile  
 
 Post subject: Don't think so
PostPosted: Wed Dec 20, 2006 12:12 pm 
Regular
Regular

Joined: Wed Aug 24, 2005 11:49 am
Posts: 63
I don't think you can change the class of an object like this.
It probably works if you do it directly in the database (without JPA or Hibernate)

_________________
Edwin van der Elst
Finalist IT Group


Top
 Profile  
 
 Post subject: Re: Don't think so
PostPosted: Wed Dec 20, 2006 1:22 pm 
Newbie

Joined: Tue Dec 19, 2006 9:57 pm
Posts: 2
Hi Edwin,
Thanks for your reply....
That was the solution i was thinking about.... i was just wondering if there's a more elegant solution.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.