Hi!
(First tenwit, I'd like to thank you for taking the time to answer all my questions... and here are some more ;) )
Quote:
You mean that you're creating an object in a transaction, saving it, not committing, and then forwarding to a new web page? And waiting for more user input before committing the transaction? That's a really bad idea, I presume that you're not doing that. If you need to visit two or more web pages in order to create and save an object, then I'd imagine that the correct thing to do is to pass all the values from the first page to the second (and subsequent) pages (as hidden fields), then create and save the object(s) all in one go, at the end.
That is the way I used to do it with Enteprise Object Framework (from NextStep now Apple), and I have done it with datasets... why should I "repeat my self" by having two objects (one to pass between web-requests, and one to finally save) I dont see any advantages in doing that (but it seems to be common practice in Hibernate world... so I do it the way you say it... but that doesnt mean I like it, it is a lot of extra work (specially with a complex UI) and i can not see the advantage.
Imagine for example, the typical shopping cart application, why should I need to save the products in the cart into the database if the user hasn't checked out (of course, a requirement of the system could be to remember those, but what if the customer requirment is to forget them?)
Quote:
Heh. Not quite.. logical programming (as he defined it) means using a parameter or property to change how a method or action works. For example, putting a special value in an ID, a value that isn't an ID but means "ID will be generated" ... either a method works or it throws an exception, you shouldn't return false on failure.
On this, I completly agree with you,
if a method gets the wrong input parameters, the answer should be exception, you shouldn't return false on failure. But... in webapps, the UI is unable to tell the difference between one object an the other without an ID (we only use IDs because the database needs them, a pure object model certainly doesn't need them) but, if our web based presentation layer needs them? I can't select an unsaved object in the gridview if it doesn't have some kind of id... shouldn't it be easier? why the database gets the benefit of ids but the UI doesn't?
When you build your User Interfaces... do you really follow the principle of "provide a safe environment: the data is saved if an only if the "save" button is clicked, and if it doesnt, or the cancel button is clicked everything is rollbacked?" (providing a safe environment for the user to experiment makes it easier for him to learn how to use it... and it shouldn't be that hard to build.. don't you think? (
http://luxspes.blogspot.com/2006/05/ui- ... -save.html )
Quote:
I hope that you'll find that there is another call to flush made, presumably deep in some hibernate code, that's causing that. If there isn't, then I think that there is a real problem there
You are right... it sounds
ilogical ;)... I am going to take a look at the inner workings of autoincrement based ids, and find out exactly what instruction is triggering the flush, so that I can disscuss it with more information in my hands.