Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #713595] Mon, 08 August 2011 16:15 Go to next message
Stefan Palme is currently offline Stefan PalmeFriend
Messages: 8
Registered: August 2011
Junior Member
Hi again,

here I am again with another problem. I use EclipseLink-2.2.0 in a JPA environment, and I have configured EclipseLink to track historical data using dedicated history tables (this has been done by configuring HistoryPolicies in the SessionCustomizer).

Our application creates some very big database transactions ("big" in the sense of a lot of modified data, involving a lot of tables and database records). For most of the modified data we have configured a HistoryPolicy. Since commiting such a big transaction takes a "long" time (sometimes around 2-3 seconds), the resulting row_start/row_end values in the history tables will not be absolutely equal to each other, because EclipseLink by default uses System.currentTimeMillis() to get the timestamp for each newly created history record.

The fact of non-matching row_start/row_end values in the history tables is annoying for us, because so we can not fetch the historical state of a given point in time which reflects the state either exactly BEFORE the transaction or AFTER the transaction.

I already modified the HistoryPolicy to HistoryPolicy.setShouldUseDatabaseTime(true), and now it really calls "SELECT NOW()" every time to calculate the row_start/row_end values for the history tables.

Unfortunately, the SQL standard does not enforce NOW() to return always the same value during one transaction, so in the end all the history records created in one single transaction still have row_start/row_end times which differ slightly (unfortunately we use MySQL - the NOW() function of PostgreSQL really returns always the same value in a single transaction).

So now the question: is there a way to give EclipseLink another "source of time" to be used for the row_start/row_end values? I think about something like the following pseudo-code:

EntityManager em=...;
Date now=new Date();
// ... create and modify a lot of entites resp. database records here
em.setTimestampForHistoryTables(now);
em.commit();

So even if the commit() takes a lot of time and has to create a lot of history records, all the history records will use the SAME timestamp for their row_start/row_end values...

Thanks in advance
-stefan-
(no subject) [message #714828 is a reply to message #713595] Thu, 11 August 2011 14:56 Go to previous message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
I agree that the time should only be computed once per transaction, not once per object. Especially when the database time is used, as multiple queries is not desirable.

Please log an enhancement for this request.

If you wish to investigate it, the fix should not be too difficult, when the HistoryPolicy assigns the time, just store it in the UnitOfWork for the duration of the transaction.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Previous Topic:java.lang.NoSuchMethodError: xxx._persistence_checkFetched(Ljava/lang/String;)V
Next Topic:problems with historical sessions combined with @Version
Goto Forum:
  


Current Time: Sat Apr 27 04:09:40 GMT 2024

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

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

Back to the top