Hi all

I'm fairly new at the EJB3/JPA stuff, and I'm writing an app that has some 
legacy data that cant be moved around too much.

I have a table and class, Dog (for simplicity) that is populated via another 
application.  This can exist as an instance in its own right.

I also have a class SpottedDog that is an extension of Dog. Because I cant play 
with the Dog table too much, I'm using an additional table for the SpottedDog 
properties and have tried using SecondaryTable and the table per subclass.

The aim is to try and create a SpottedDog from an existing Dog, and keep the 
unique identifier on the Dog record.

I create a new SpottedDog and assign values from the Dog to it in the 
constructor, and then call em.merge(spottedDog);.

However, the Hibernate debugging shows that it tries to search on SpottedDog 
with a inner join on Dog.  Because a SpottedDog record does not exist yet, it 
assumes that the Dog entry doesnt either, and proceeds to try to insert a Dog 
entry.  This ends up causing an identity insert error, because its trying to do 
that Dog insert that doesnt need to be done.

So, any tips for extending an object to a subclass, where it will recognise 
that the superclass already exists?

For this particular case, it would be nice if the original search was a left 
outer join on Dog, so that the Dog record would be recognised and only an 
insert on the SpottedDog would be required.  I guess an additional search on 
Dog instead of the left outer join would do just as well.


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048590#4048590

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048590
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to