0

I'm trying to write a Java EE 6 application using JPA but without using Hibernate or Spring. I used Netbeans to generate the JPA classes, and I created the tables in Postgres, but I am not able to run DbUnit tests in those JPA classes.

I have tried to base my test unit on the example described in this site: http://www.roseindia.net/testingtools/DbUnit/gettingstarted.shtml but it does not work. I keep getting a "java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory" even though I added slf4j to the project libraries in the IDE.

One thing that I find rather odd about the roseindia site example is that it does not seem to have a caller object for the test object created. I am not sure if a caller object is even needed (complete n00b in JavaEE programming, and kind of lost still).

2
  • When you use JPA you must use a JPA provider. If you don't want to use Hibernate as your provider, then you should use EclipseLink, OpenJPA or something else. What do you mean by using JPA without Hibernate exactly? Commented Sep 28, 2011 at 23:20
  • Hi, Behrang I expressed myself wrong. I'm using EclipseLink as JPA provider. What I meant to say was that I'm not using the Hibernate Framework per se, just pure JPA access. Commented Oct 3, 2011 at 19:35

1 Answer 1

1

If you choose to use entities (java classes annotated with @Entity, representing database records), you have to use some JPA provider. You are not restricted to Hibernate, though.

If you're frightened by JPA, your other option is to use plain JDBC. It is far easier to understand, if it's your learning-exercise application, it might be a good idea to try and see how it works. JPA is built on top of JDBC, so when you think you're ready for it, you'll have a solid knowledge base.

Sign up to request clarification or add additional context in comments.

2 Comments

Hello, MaDA As I told Behrang, I'm using EclipseLink as JPA provider, and I meant to say that I'm not using the Hibernate Framework, just pure JPA to access data. And, actually, this is both a real-world application and a learning exercise, so I'm kind of in a pickle. I intended to use something a little more high level than JDBC, to fully abstract the database access, and JPA seemed like the better option. By now, I'm considering reimplementing the whole database layer using the Hibernate FW, just to see if it will work better =P
@Rafael Good, sticking to JPA API only makes your application more portable. But the LoggerFactory error is just a missing library in a target environment, so it's not related to JPA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.