Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Transaction logging
Transaction logging [message #780780] Thu, 19 January 2012 11:03 Go to next message
Thomas Friend
Messages: 9
Registered: December 2011
Junior Member
Hi,

I want to log each transaction in the following way:

For each entity inserted/deleted/updated between transaction.begin() and transaction.commit() a transaction-id should be written both into the history table corresponding to the changed entity and into a "transaction-log-table". An entry in the transaction-log-table should also include e.g. a list (as string) of the tables/entities involved in the transaction.

I have already created a history customizer but have no idea how to handle the transaction (not entity) specific logging.

Any help would be very appreciated!

Thomas

Re: Transaction logging [message #780841 is a reply to message #780780] Thu, 19 January 2012 15:06 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It might be easiest to create an Entity that maps to your transaction log table and persist a log object with each transaction.


James : Wiki : Book : Blog : Twitter
Re: Transaction logging [message #780847 is a reply to message #780841] Thu, 19 January 2012 15:47 Go to previous messageGo to next message
Thomas Friend
Messages: 9
Registered: December 2011
Junior Member
Hi James,

thanks for your answer. I thought of this too but the following questions arise:

How to ensure a "transaction-log entity" is created and persisted with every transaction? Is it possible to listen to transaction "events" (something like @PreCommit) or do I have to write something like for example a transaction decorator which handles the additional steps on commit (and furthermore an entitymanager which delivers such a decorated transaction on getTransaction())? My goal is to hide the details of this transaction logging from a user of the entitymanager.

How to determine the entities/tables affected by the actual transaction so this information can be stored within the transaction-log entity?

How to write the transaction id into the (from history policy) newly created row within the particular history table of each other entity changed in the actual transaction?

Best regards

Thomas
Re: Transaction logging [message #781002 is a reply to message #780780] Thu, 19 January 2012 15:06 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It might be easiest to create an Entity that maps to your transaction log table and persist a log object with each transaction.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/


James : Wiki : Book : Blog : Twitter
Re: Transaction logging [message #781003 is a reply to message #781002] Thu, 19 January 2012 15:47 Go to previous message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
Hi James,

thanks for your answer. I thought of this too but the following questions arise:

How to ensure a "transaction-log entity" is created and persisted with every transaction? Is it possible to listen to transaction "events" (something like @PreCommit) or do I have to write something like for example a transaction decorator which handles the additional steps on commit (and furthermore an entitymanager which delivers such a decorated transaction on getTransaction())? My goal is to hide the details of this transaction logging from a user of the entitymanager.

How to determine the entities/tables affected by the actual transaction so this information can be stored within the transaction-log entity?

How to write the transaction id into the (from history policy) newly created row within the particular history table of each other entity changed in the actual transaction?

Best regards

Thomas
Re: Transaction logging [message #781019 is a reply to message #780780] Thu, 19 January 2012 15:06 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It might be easiest to create an Entity that maps to your transaction log table and persist a log object with each transaction.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/


James : Wiki : Book : Blog : Twitter
Re: Transaction logging [message #781020 is a reply to message #781002] Thu, 19 January 2012 15:47 Go to previous message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
Hi James,

thanks for your answer. I thought of this too but the following questions arise:

How to ensure a "transaction-log entity" is created and persisted with every transaction? Is it possible to listen to transaction "events" (something like @PreCommit) or do I have to write something like for example a transaction decorator which handles the additional steps on commit (and furthermore an entitymanager which delivers such a decorated transaction on getTransaction())? My goal is to hide the details of this transaction logging from a user of the entitymanager.

How to determine the entities/tables affected by the actual transaction so this information can be stored within the transaction-log entity?

How to write the transaction id into the (from history policy) newly created row within the particular history table of each other entity changed in the actual transaction?

Best regards

Thomas
Re: Transaction logging [message #781036 is a reply to message #780780] Thu, 19 January 2012 15:06 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It might be easiest to create an Entity that maps to your transaction log table and persist a log object with each transaction.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/


James : Wiki : Book : Blog : Twitter
Re: Transaction logging [message #781037 is a reply to message #781002] Thu, 19 January 2012 15:47 Go to previous message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
Hi James,

thanks for your answer. I thought of this too but the following questions arise:

How to ensure a "transaction-log entity" is created and persisted with every transaction? Is it possible to listen to transaction "events" (something like @PreCommit) or do I have to write something like for example a transaction decorator which handles the additional steps on commit (and furthermore an entitymanager which delivers such a decorated transaction on getTransaction())? My goal is to hide the details of this transaction logging from a user of the entitymanager.

How to determine the entities/tables affected by the actual transaction so this information can be stored within the transaction-log entity?

How to write the transaction id into the (from history policy) newly created row within the particular history table of each other entity changed in the actual transaction?

Best regards

Thomas
Previous Topic:Native ORM vs JPA
Next Topic:Shared cache on multi base using same classes
Goto Forum:
  


Current Time: Tue Apr 16 19:28:37 GMT 2024

Powered by FUDForum. Page generated in 0.43167 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top