Not exactly familiar with Spring Data JPA but I am with JPA with container 
managed transactions.   Assuming you have a handle on the EntityManager, invoke 
the 'flush' method on it which will cause the entity manager to perform the 
database operations before the commit.   You can then wrap your code with a 
try/catch block if needed to catch the exception that occurs.

-----Original Message-----
From: Matthew Adams [mailto:[email protected]] 
Sent: Tuesday, January 08, 2013 1:46 PM
To: [email protected]
Subject: Force unique constraint to be enforced at statement execution?

Hi all,

How do I force a unique constraint to be enforced upon statement execution 
instead of at transaction commit?

I'm using Spring Data JPA over DataNucleus & Derby (embedded), and Spring's 
persistence exception translation proxy is not translating the unique 
constraint exception because it's happening at transaction commit instead of 
when the statement is executed.

Thanks,
Matthew




--
View this message in context: 
http://apache-database.10148.n7.nabble.com/Force-unique-constraint-to-be-enforced-at-statement-execution-tp126304.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Reply via email to