BaseORMService function init(string queryCacheRegion=“ORMService.defaultCache”,
boolean useQueryCaching=false,
boolean eventHandling=true,
boolean useTransactions=true){
should be
BaseORMService function init(string queryCacheRegion=“ORMService.defaultCache”,
boolean useQueryCaching=false,
boolean eventHandling=true,
boolean useTransactions=false){
I can give you an example where useTransactions=true, when ColdFusion is managing the session will fail. This is why I said that the use of transactions should be false if one is getting ColdFusion to manage the sessions, as this is the common way 99% of developers are going to program their apps, then this will continue to fail and cause issues.
And is why I am constantly changing this code to false so ColdBox works in my current applications. True that I would only have to do this once now, but the problem here is that I have something like this in my code at the moment.
Read in a cfquery from another database source called query 1
Loop over query1
Create a transient Object1
Populate transient object1
Read in a cfquery from another database source called query 2
Loop over query2
Create a new transient object2
Populate transient object
Save transient object2 or make it persistent
Loop end
Save transient object1
Loop end
Now here is the problem that I have with transient default to true, when ColdFusion is managing sessions. If the loop over query2 fails when saving the transient object, it will do a transaction, then commit or rollback depending on what is required. This when ColdFusion managers sessions throws a hibernate exception, basically saying that the session is closed when it eventually gets to the outer save of object1.
Another example of where this will fail, is if you have an ORM Event that does gets the current ORMSession. Then does a HQL update/delete to the DB, this will also throw a session is closed when trying to save the transient object1.
In all my examples I have had to default the use of transaction to false.
Sorry Luis I am still not convinced that I see a use case of defaulting the use of transactions in the ORMService to true, the more I use it in real world I am finding the opposite should be true, and the use of transactions set to false by default. Especially with something I am about to release, it not only has ORMEvents that handle preInsert, and postDelete but it also requires that the use of transaction = false. Which means anyone who needs to use these Events, on this entity will be forced to change their code to use transaction=false.
Regards,
Andrew Scott
http://www.andyscott.id.au/