Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to clear the sequence preallocation pool?
How to clear the sequence preallocation pool? [message #1702545] Thu, 23 July 2015 06:34 Go to next message
Ward V is currently offline Ward VFriend
Messages: 2
Registered: July 2015
Junior Member
Is there a way in EclipseLink to clear the sequence preallocation pool?

In some automated tests we drop and create our database schema while the application is running. After that we clear the cache:
javax.persistence.Cache.evictAll()
org.eclipse.persistence.jpa.JpaCache.clear()

Everything works fine after that, except that the sequence preallocation pool is not cleared, so we get into problems when a lot of rows are created after that, resulting in primary key constraint errors.

Is there a way to clear this cache? Internally in EclipseLink there is org.eclipse.persistence.internal.sequencing.SequencingManager.resetSequencing() but this is for internal use only.

Or is this a bug and should this have been cleared by clearing the JpaCache?

Re: How to clear the sequence preallocation pool? [message #1702647 is a reply to message #1702545] Thu, 23 July 2015 17:37 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
The JpaCache.clear() and Cache.evictAll() intended for situations where you have other outside applications making changes, and to save the performance costs of issuing refresh queries, you want to dump the Entity data. This is meant for production environments, so clearing sequence preallocated values because all the database might have been wiped was likely not a considered use case.

Closing all EntityManagerFactories so that they will get garbage collected and then recreated when needed. Another way would be to use the refreshMetadata api to effectively do the same thing but without having to close your EMFs and reobtain them, as the api does it for you. Something like JpaHelper.getEntityManagerFactory(em).refreshMetadata(properties); but you can See http://wiki.eclipse.org/EclipseLink/DesignDocs/340192 and http://gotoanswer.com/?q=create-or-extend-tables+with+Eclipselink+does+not+work for details.

These are the safer, easier options I can think of. Otherwise you will need to get down to the internal details of EclipseLink's to reset the sequence values
Re: How to clear the sequence preallocation pool? [message #1702918 is a reply to message #1702647] Mon, 27 July 2015 11:44 Go to previous message
Ward V is currently offline Ward VFriend
Messages: 2
Registered: July 2015
Junior Member
Thanks Chris, it works!
Previous Topic:Descriptor customizers not invoked
Next Topic:git repository for docs?
Goto Forum:
  


Current Time: Thu Mar 28 15:26:18 GMT 2024

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

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

Back to the top