开发者

spring jpa hibernate unknown entity exception

I have a rather weird thing happening.

If I clean my target folder and run my tests they work fine. if I run it again without cleaning i get the following error

java.lang.IllegalArgumentException: Unknown entity: com.merc.domain.EventLog
        at org.hib开发者_Go百科ernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:675)
        at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)

Any ideas as to why this might happen when the target folder has just the compiled classes. I am using maven to build


For netbeans users this is an eye opener.

I have a maven project in netbeans. If i delete the files in target folder, and right click my test.java file in Netbeans and select "test file". Netbeans runs the maven commands to build the file and the classpath and then executes the test using files in test-resources which works fine. But if the java classes are already compiled then Netbeans runs the tests with the resources from the classes folder instead of the test-classes folder. In my case, persistence.xml in classes-folder was missing a few details, which i didn't care, because i was more focused on the unit tests.


Same thing in eclipse, you have to configure build-path so eclipse notices that it have to look for files in the correct output directory.

You can also configure your maven build to make it match to where JUnit is looking for your files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜