tracker issue : CF-3138032

select a category, or use search below
(searches all categories and all time range)
Title:

I reported this once before and it was marked user error

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/LowImpact

Reporter/Name(from Bugbase): Andrew Scott / Andrew Scott (Andrew Scott)

Created: 03/14/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: 0

Problem Description:

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:	3138032

External Customer Info:
External Company:  
External Customer Name: ascott67
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

For Andrew : Auditing is definitely possible and lot of folks have been doing it in their application. I don't understand why it does not work for you. I would recommend you to look into the correct usage.
Comment by Rupesh K.
20081 | March 16, 2012 12:30:08 AM GMT
There is no correct usage here Rupesh, if there was then why hasn't anybody responded on CF-ORM dev mailing list about this? If it is possible then how is it possible? This is how auditing is done in hibernate and java so that the before and after changes are recorded. The only way to record before and after changes is via an event, the problem with this as shown by the code sample throws an error that the session is closed. That is a bug, no ifs no butts. So if you say there is a way point me in the direction, where it is done in the event handling because I have searched high and low ever since ColdFusion 9 was released, I have also tried every know trick to get this to work. So please tell me how inside an event handler?
Comment by External U.
20082 | March 20, 2012 07:19:44 AM GMT
btw here is the thread https://mail.google.com/mail/u/0/?ui=2&shva=1#sent/135f3f8b37133558
Comment by External U.
20083 | March 20, 2012 07:22:42 AM GMT
And as I also won't this on a global level, the event handler is the best place to do it. So I am not sure how you can claim that it can be done and provide no real example of it either.
Comment by External U.
20084 | March 20, 2012 07:24:47 AM GMT
And I am also guessing you haven't tried it either...
Comment by External U.
20085 | March 20, 2012 07:29:05 AM GMT
Andrew: Are you referring to the bugs CF-3123428 and CF-3128906. If so, we never said it's a user error. Please clarify.
Comment by Himavanth R.
20086 | March 21, 2012 02:50:56 AM GMT
No update from the customer in 5 days. Assuming that this is indeed a duplicate of the bugs CF-3123428,CF-3128906. Those bugs have been deferred which means they will be taken up for fixing in the next release.
Comment by Himavanth R.
20087 | March 26, 2012 03:56:32 AM GMT
I never got any notification on this. And no they are not related at all.
Comment by External U.
20088 | March 26, 2012 04:10:59 AM GMT
Can this be re-opened as the tickets you claim it to be related too, are not the same issue.
Comment by External U.
20089 | March 26, 2012 04:11:28 AM GMT
Again, please be aware that this is an issue and it is highly sort after when dealing with companies that are ISO9001 certified. Because they have a requirement that auditing take place on all and any changes to the database, the global events is the best place to try and do this. Unfortunetly, one is not able to create an entity and save it as the example demonstrates, the error message returned is that the session has closed. Again this is a requirement for anyone who needs to do work with ISO9001 companies, without this working it is impossible to provide an easy way to write this. Sure one can manually make changes to each an every entity, but the problem there is that it is too easy to make mistakes and miss changes. The global events provide a way for it to never be missed.
Comment by External U.
20090 | March 26, 2012 04:36:41 AM GMT
Inserting audit entity in post insert in the same session does not work and I had logged a bug with Hibernate a long time back for this. https://hibernate.onjira.com/browse/HHH-5127 The only way to do it would be to open a new session and use that. One can use ORMGetSessionFactory().openSession() to get the session and then call save/saveOrUpdate on it. There is nothing much that we can do now. We can revisit this for the next release.
Comment by Rupesh K.
20091 | March 26, 2012 04:37:24 AM GMT
Please see other notes on the CF-ORM mailing list, there is no work around to this problem. Secondly, grails is very capable of doing this. And has been doing this for over 6 years, so why can't ColdFusion?
Comment by External U.
20092 | March 26, 2012 05:26:07 AM GMT
This is not a 3rd party problem Rupesh, Grails can do it. Java is very capable of doing it. So why can't ColdFusion?
Comment by External U.
20093 | March 26, 2012 05:27:22 AM GMT