Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink Constraint Violation Issue
EclipseLink Constraint Violation Issue [message #1713533] Wed, 04 November 2015 20:54 Go to next message
Santosh Kantharaj is currently offline Santosh KantharajFriend
Messages: 1
Registered: November 2015
Junior Member
Hello,

So I have an Eclipselink question. I have a two column table, with football team names and their ranking. When I go to update this table, sometimes the ranking of these teams change some teams end up swapping ranks with one another (last week, OSU was #1 and Clemson was #3, and this week Clemson is #1 and OSU is #3).

I've got a uniqueness constraint on the ranking column that means that no two teams have the same ranking on my table. So, in the aforementioned example, if I were to change those rankings, there would be a transition state that would violate that constraint (I update OSU's ranking to #3 before updating Clemson's to #1 there is a moment where both are ranked #3).

This transition state violates the uniqueness constraint, as expected.

Now, instead of having this constraint apply at all times, I've changed it to a "deferred" constraint where the constraint only applies when "commit" is explicitly executed. So, even though I have this uniqueness constraint, I can have that violating transition state without SQL Developer complaining, and the only time that the uniqueness check is run is after a commit.

I've tested this, and it works. Now, I want to run this same logic through Eclipselink, using my deferred constraint. But it seems that Eclipselink inserts a bunch of commits into the server-generated SQL, thus overriding the benefit of my deferred constraint.

Is there a solution to this, where I can tell Eclipselink where and when to commit? Thank you.
Re: EclipseLink Constraint Violation Issue [message #1715890 is a reply to message #1713533] Fri, 27 November 2015 11:14 Go to previous message
Tomas Kraus is currently offline Tomas KrausFriend
Messages: 9
Registered: November 2014
Junior Member
You can handle transaction yourself.

EntityManager em = /* get an entity manager */;
EntityTransaction tx = em.getTransaction();
tx.begin();
// make some changes
tx.commit();

Edit: and some try/catch and tx.rollback() in catch blocks.

Also make sure that autocommit is turned off and transactions are set properly in PU.

[Updated on: Fri, 27 November 2015 11:32]

Report message to a moderator

Previous Topic:Direct self-reference leading to cycle error despite having JsonManagedReference and JsonBackReferen
Next Topic:Specifying bound parms in mixed jpa/native query
Goto Forum:
  


Current Time: Sat Apr 27 01:26:25 GMT 2024

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

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

Back to the top