File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes JPA JSE and JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA JSE and JUnit " Watch "JPA JSE and JUnit " New topic
Author

JPA JSE and JUnit

Markus Schmider
Ranch Hand

Joined: Feb 25, 2007
Posts: 100
Hello I have a JSE (desktop) application which uses JPA.
When I try to JUnit Test it, I run into a strange problem.
Basically I have two Entities which extend a superclass.


I need to test that the attribute nr is unique for each subclass, but that same values are allowed between subclasses.
I think this works, but my JUnit test behaves strangely:


When run each test in isolation, the tests pass. But when I run the whole class, testUniqueNr() is executed and then the RollbackException somehow causes
@Before
public void cleanUp()
not to be executed and the testSelbeNrInVerschiedenenSchluessellisten() fails.
When I (expected=RollbackException.class) and use a try catch block I get the same behavior.

Many thanks for any input

from my pom.xml:
Markus Schmider
Ranch Hand

Joined: Feb 25, 2007
Posts: 100
I have to correct myself slightly. The debugging with the failed test indication had confused me.
After the execution of



is executed, but there a ConstraintViolation exception is thrown while I try to delete the entities.:
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: ORA-00001: unique constraint (TEST.SYS_C0013343) violated

So the problem occurs when I run cleanUp after testUniqueNr where the exeption is excpected.

relevant code:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA JSE and JUnit
 
Similar Threads
Spring3 + JPA 2 + JBoss 6
"No JTA UserTransaction available" errmsg thrown by Atomikos/JTA standalone app
Big Exception in my Small Project (EJB JPA GlassFish)
Problem with Enums
Incorrect hibernate version or maven ignore and didn't download hibernate jar file.