aspose file tools*
The moose likes Object Relational Mapping and the fly likes hbm.xml file does an update instead of an insert- Helppppp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hbm.xml file does an update instead of an insert- Helppppp" Watch "hbm.xml file does an update instead of an insert- Helppppp" New topic
Author

hbm.xml file does an update instead of an insert- Helppppp

Rui Felix
Greenhorn

Joined: Jun 13, 2006
Posts: 8
Greetings,

I really need help on this. I am trying to use Hibernate to insert on two table on the database. The relation is of type Parent/Child. The problem is that it inserts well on the Parent table but on the Child table it doesn't insert.

Debuging through the project I've found out that he makes an INSERT for the first table but for the second table it makes an UPDATE.

The hbm.xml files that I've built are bellow, the first file has lot of thing but what is used for these tables is at the end:



The precious hbm.xml file has a joined-class that works fine and has a set for a collection that is doing an update instead of an INSERT.

The class that is used in the set implements the following hbm.xml file.



Here is the SQL statements that are produced by the hbm.xml files



I really need answers for:

How can I force the hbm.xml file to do an INSERT instead of an UPDATE?

Thanks for any reply

Many Thanks,
Rui F�lix
Rui Felix
Greenhorn

Joined: Jun 13, 2006
Posts: 8
Hello,

I already got the answer for my question. I had to make some changes to the TslMultiBuyListImpl.hbm.xml file. Here are the two hbm files:





I also had to set the class from the second hbm file implementing Serializable.

Many Thanks
Rui Felix
[ October 30, 2007: Message edited by: Texugo ]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

"Texugo",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hbm.xml file does an update instead of an insert- Helppppp