-->
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.  [ 7 posts ] 
Author Message
 Post subject: order of save ??
PostPosted: Mon Mar 15, 2004 9:13 am 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
Hellu again,

Ok, we made some progress and now are able to do "some" saving of our order, however appearantly we have some problem in the order we create and fill our persist objects.

Can some please give some insight in the correct order as I can't find it in the doc's neither faq/forums.

What we have:
- An Order object.

- A Ticket object.

- An OrderlineType object

- A Orderline object that has a many-to-one relation with an Order, Ticket
and OrderlineType.

- Ticket status object.

- An Ticket Status History table that has a many-to-one relation with the Ticket status object and a many-to-one relation with a Ticket object.

- The Orderline also has a Orderline Status and Orderline Status history object with the same relations as the Ticket history.

The Ticket and Orderline status objects, and the OrderlineType objects are stored in the database.

What we do:
1) Create a new order.

2) Create a new orderline and fill it. This means that the orderline also get connected to a new orderline history status object that is connected to a orderline status object that is retrieved from the datasource. It is also connected to the new Order.

3) Create ticket and fill it. idem as before concering the status objects. The ticket is connected to the new orderline.

4) Link the new Orderline to an existing OrderlineType that is retrieved from the data source.

5) Save the order.

Above doesn't work. I generates the errors that are listed above (previous mails in this thread). The errors take place when the order is saved in step 5. The error that hibernate give: it tries to insert the new orderline before inserting the new ticket.
Butttt what does work: in case that step 4) takes place after step 2).

I really have no idea why this makes any difference.

It thought: just create your objects, connect them and save the parent.... what am I missing here ??

Above also occurred in some other place. The Ticket is connected to a delivery channel object that is retrieved from the data source. This also has to be placed in the correct line in the code, otherwise we got the same error. We noticed that hibernate didn't give this error in case we changed the flushmode to COMMIT_ONLY, but I don't want that as (what I read from the doc) it means that you can retrieve stale data in that case.

Some other thing, which I think can explain if I have some more insight in the above:
The orderline is connected to the order through:
a) newOrderline.setOrder(newOrder);
b) newOrder.getOrderlines().add(newOrderline);

and that doesn't work, it generates the same error.
What does work: removing b).... but that is really strange to meeee... :(
We now are able to save the order and all his childs and are checking the stored data at this moment.

Buttt stilll, can someone please give some insight in above and where to look for ??

Regards,
Ed Bras
PS: we use hibernate 2.1.2


Top
 Profile  
 
 Post subject: order of save ??
PostPosted: Mon Mar 15, 2004 9:20 am 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
Oepsss, just noticed that I have started a new thread. The above belongs to this thread:
http://forum.hibernate.org/viewtopic.php?t=928787

Sorry,
Ed


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 11:14 am 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
Hellu,

I did some more research and found out that the order in which you create and fill your persist objects are really important if you have: FlushMode=AUTO (default behavior, which most of the time you want like me).
Hibernate will synchronize sometimes when you fill/create persist (hibernate) objects, and complains if you have persist objects that are not "correctly" (non-null value's in db don't have a corresponding member value) filled yet, and are connected to persist object retrieved from the database.

I my case it's quite difficult to find the correct position where it goes wrong as I have a "lotttt" of related objects when saving one which many (in)direct relations.

You can control this synchronization by setting the correct flushmode but most of the time, like in my case, you just want hibernate to control this: flush mode auto.

Can someone verify this and might it be an idea to put this in a faq or wiki site ??? At least, I can't imagine that their more people that don't wanne know this, and I can't find it in the doc and faq's.

Ed


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 11:18 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/hib_docs/refer ... g-data-s12

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: true not true
PostPosted: Mon Mar 15, 2004 11:44 am 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
True, but than why don't you just remove all the faq's ??

As they are also contained in the documentation!

Sorry, It's just too general and the faq's are great to put just these specific situations.

Ed


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 15, 2004 11:49 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
So far, only you asked, so its not frequently. We have hundreds of FAQs already, have to take care of bloat.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: true not true
PostPosted: Mon Mar 15, 2004 1:28 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
True, that's someting I asked myself as well, as I was suprised about the issues in the faq and forum about this.

Probably it's because we are using Hibernate now a days for about 200% in quite some complex situations.

That is: we are using hibernate for quite some time now, and are really happy with it. In the previous version we performed the crud actions less cascading and did more things ourself (like most people do I noticed in the forum which isn't suprisinly as you really have to "switch" in how you perform your db interactions). So everyting works just fine.
Now we make use of the full-blown functionality of Hibernate (like everyone should as this is verrrrry powerful), so you really get realy in to the small details of Hibernate.

Afterwards it's always easy to see what it was, especially for some one like from the Hibernate team, as you see it every day.

But believe me, if you have hibernate integrated in your systeem is a lot of places and you get an error, it can be somethings quite difficult to track down the exact cause.

BTW: if I read the answers from the Hibernate "juru's", sometimes it might not be such a bad idea to put them self more in the users position.
Don't forget that you passes "that" phase and it's someting difficult to understand the problem people have (even irritating). Me myself have that already a little bit when I read forum issues so imagine how a Hibernate "juru" feels.

Just my 20 cent.

Ed


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.