Is this with using ORMService.save()?
I to have brought this up many times in here if that is the case, and the
one thing that has continually annoyed me is the fact this code has its own
transaction wrapped around the actual save.
This causes issues like a connection closed error, especially when you have
a transaction around a block of code that fails. The final save will then
fail because of this.
I have also found that the following block of code will also throw an error,
with this problem when you do something that mixes all this.
Obj = new ORMService.new('entity');
Now in an ORMEvent on preInsert() I have about 4 HQL queries that run
outside of the ORMService.save() which again throws, session closed error.
And the only way to fix this under all circumstances is to remove the
transaction code from around the EntitySave. I am sorry but in my opinion if
you are going to managing the saving of the data like this, then you should
be managing inside the application and not the Save like this.
I have come to the conclusion that ORMService can be used some very basic
stuff, but when you start building a very large scaled application this
Service is not up to the task, and that is because it assumes that you will
not take responsibility for the session management of the ORM Session.
So now I have my own service, that does the same thing saves the object but
doesn't have the problems that the core service has.
From: firstname.lastname@example.org [mailto:email@example.com] On
Behalf Of Brett
Sent: Saturday, 9 April 2011 3:39 AM
To: ColdBox Platform
Subject: [coldbox:9316] Re: Question/Issue with ORM transaction
It's not supposed to be saved. I purposely don't save C so that we can't
db constraint error so that we'll the issue with rollback not executing.
The commit will fail. We will have a partical commit to the db.
table A will have a record
table B will have a record
but A_B will NOT have the relationship recorded
The error dump will show that there was a constraint violation updating
B with the relationship to C.
> For some reason, C is never persisted for me from the B releationship
> Luis F. Majano
> Ortus Solutions, Corp
> ColdBox Platform:http://www.coldbox.org Linked
> IECFUG Manager:http://www.iecfug.com
> > I think the problem you are getting is that you are expecting for
> > hibernate to save C from the A relationships in a cascade manner,
> > but I do not think this will work, I think you need C to be persisted