Status/Resolution/Reason: Closed/Withdrawn/Duplicate
Reporter/Name(from Bugbase): Andrew Scott / Andrew Scott (Andrew Scott)
Created: 03/26/2012
Components: ORM Support
Versions: 10.0
Failure Type:
Found In Build/Fixed In Build: Public Beta /
Priority/Frequency: Major / Most users will encounter
Locale/System: English / Windows 7
Vote Count: 1
Duplicate ID: CF-3138032
Problem Description:
As per the notes by Rupesh this is not a problem with a 3rd Party, Grails has been able to do this for 6 years and Java is very capable of also doing this, by creating a new session and saving it.
ColdFusion can't so this is a problem with ColdFusion and the way Hibernate has been implemented.
Please see https://mail.google.com/mail/u/0/?ui=2&shva=1#inbox/135f3f8b37133558 for further problems that opening a session that one can do in Java.
In other words in Java I can write something like this
Session session = sessionFactory.openSession();
session.beginTransaction();
Message message = new Message();
message.setText(text);
message.setDate(date);
session.save(message);
session.getTransaction().commit();
In an Event Handler and it will work, ColdFusion it will not work and is a bug. Please don't dismiss this as a bug when we can;t even do other workarounds like opening / creating a session all which are very valid in Java, but not with ColdFusion.
I wanted to try this again and get you to understand how important this error is.
Currently I am trying to find a way to write audit logs for my entities, and have been trying to find a way for this using entities for now 4 years.
I will give you the basic code, but rest assured that this is also being checked to see if that entity has called the event if so then don't run the code. But for now I just want to give you a basic concept of the problem.
So lets say we have an event handler.
public void function postInsert(any entity) {
var domain = new domains.audit(auditDateTime: now(), template: #getMetaData( entity ).fullname#, detail: 'This is a test of strength', ipAddress: cgi.http_host);
entitySave(domain);
}
Now remember that this is an example, the actual code will check to see if the even being run is the audit so we don't end up in some serious loop.
As it stands now there is no way to be able to do this, and it will throw a session closed error. All the standard Java techniques don't seem to work because there is no way to open a new session for that entity to be created and saved.
This is also a major issue that as annoyed me for 4 years and I am at a loss, a big loss as how to implement something like this. When you code for anyone who has ISO certifications this is a must that audit logs take place on data that has changed.
So I am in need of a solution here, but I am not sure the client will even pay for an upgrade to ColdFusion 10. So I may just have to go and right this in Grails where I am able to achieve this with no issues.
Steps to Reproduce:
Actual Result:
Expected Result:
Any Workarounds:
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3149408
External Customer Info:
External Company:
External Customer Name: ascott67
External Customer Email:
External Test Config: My Hardware and Environment details:
Attachments:
Comments: