Re: [Play 2.0.4] running JUnit tests in Eclipse with JPA (hibernate)

324 views
Skip to first unread message

Nicolas Forney

unread,
Oct 19, 2012, 3:10:11 AM10/19/12
to play-fr...@googlegroups.com
Really useful information!

Thx ;)

On Thursday, October 18, 2012 9:18:52 AM UTC+2, Laurent Opprecht wrote:
I finally got Eclipse to work with my junit test and JPA - i.e. Hibernate. I did the following
  • Add the conf folder as source folder - in order to capture persistence xml - right click project -> properties -> Java Build Path -> add folder
  • Unchecked Build > Build automaticaly
  • Added ALL my entity models to persistence.xml
    • <class>models.User</class>
    • ...
  • Compiled everything
  • Added a fake application with entity manager attached to the thread:
app = Helpers.fakeApplication(); 
Helpers.start(app);
em = JPA.em("default");
JPA.bindForCurrentThread(em);
em.getTransaction().begin();
 
Note that eclipsify do not add conf as a source folder. As a consequence it is likely that re-running eclipsify will erase the above configuration.

Hope this will benefit others.

 
Reply all
Reply to author
Forward
0 new messages