Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Suggestion: commit() method returning the number of committed.(Suggestion: commit() method returning the number of committed.)
Suggestion: commit() method returning the number of committed. [message #908540] Wed, 05 September 2012 14:44 Go to next message
Marvin Toll is currently offline Marvin TollFriend
Messages: 34
Registered: July 2009
Member
It would be helpful to me... so I'm presuming others... to have a version of the commit() method similar to the following using the EntityTransaction interface as a model:

/**
* Commit the current resource transaction, writing any
* unflushed changes to the database. This version of the
* commit() method returns the number of SQL modification-
* related statements executed.
*
* @throws IllegalStateException if <code>isActive()</code> is false
* @throws RollbackException if the commit fails
*/
public int commits();


Perhaps obviously, this method would have immediate benefit in a (JUnit style) testing context - where it is difficult to assert if an "update" actually was persisted to the database.

_Marvin
PatternEnabled.com
Re: Suggestion: commit() method returning the number of committed. [message #909060 is a reply to message #908540] Thu, 06 September 2012 13:16 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

For our own testing we generally accomplish this by setting a custom logger into the Session that monitors SQL logging.

The class is org.eclipse.persistence.testing.framework.QuerySQLTracker, available from our Git repository under testing.


James : Wiki : Book : Blog : Twitter
Re: Suggestion: commit() method returning the number of committed. [message #909098 is a reply to message #909060] Thu, 06 September 2012 14:24 Go to previous messageGo to next message
Marvin Toll is currently offline Marvin TollFriend
Messages: 34
Registered: July 2009
Member
Can you include a copy of the "assert" method you are using to ensure updates actually were persisted during unit testing?

_Marvin
PatternEnabled.com


Marvin Toll
CTO, Pattern Enabled Development
http://pedCentral.com
Re: Suggestion: commit() method returning the number of committed. [message #909248 is a reply to message #909060] Thu, 06 September 2012 20:06 Go to previous message
Marvin Toll is currently offline Marvin TollFriend
Messages: 34
Registered: July 2009
Member
James Sutherland wrote on Thu, 06 September 2012 09:16
For our own testing we generally accomplish this by setting a custom logger into the Session that monitors SQL logging.

The class is org.eclipse.persistence.testing.framework.QuerySQLTracker, available from our Git repository under testing.


Elaboration: foundation/eclipselink.core.test/src/org...


Marvin Toll
CTO, Pattern Enabled Development
http://pedCentral.com
Previous Topic:Eclipselink 2.3.2 + composite persistence units + bean validation (jsr303)
Next Topic:Why is EclipseLink querying twice for the same entity?
Goto Forum:
  


Current Time: Wed Apr 24 23:47:43 GMT 2024

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

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

Back to the top