5

I'm using Eclipse Juno, Hibernate 4.0 and MSSQL 2008. I've created a database and have just gone through the process "JPA Entities from Tables" in Eclipse. About half of the tables did not get created (even though I selected those table), but the classes were added to persistence.xml.

Has anyone else experienced this problem? Do you have a solution?

4
  • I already had this problem, but I just completed the mapping manually (not too much work in my case) Commented Apr 19, 2013 at 8:51
  • Are there any exceptions in your Eclipse workspace log (.metadata/.log)? Commented Apr 19, 2013 at 15:12
  • I'm getting the exception org.eclipse.core.runtime.CoreException: Unable to find JPA entities generation templates in pluginorg.eclipse.jpt.jpa.gen in the eclipse log Commented Apr 21, 2013 at 23:21
  • Also getting the exception org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getImportStatements' in class org.eclipse.jpt.jpa.gen.internal.ORMGenTable threw exception java.lang.IllegalStateException: cms_page.cms_page_cms_page_FK - mismatched sizes: 0 vs. 1 @ main.java.vm[7,9] Commented Apr 21, 2013 at 23:24

4 Answers 4

4

In my case the database was Oracle XE. So mine is a bit different case but may be helpful to someone.

The best way to find the problem with this is to check the logs of workspace present at $workspace_location/.metadata/.log file. In my case I found that there were 3 problems:

1) Caused by: java.io.FileNotFoundException: $MiddlewarePath\oracle_common\modules\oracle.adf.share_11.1.1\adfsharembean.jar (Access is denied)

2) Caused by: java.io.FileNotFoundException: $MiddlewarePath\oracle_common\modules\oracle.ldap_11.1.1\jremtool.jar (Access is denied)

3) !MESSAGE Unable to find JPA entities generation templates in pluginorg.eclipse.jpt.jpa.gen !STACK 1 Java Model Exception: Core Exception [code 275] A resource exists with a different case: '/TestJPAProjectFacetsEJB/src/main/java/com/domainname/ejb/TestJPAProjectFacets'.

Hence I did the following:

1) Provided access permission for the jar files 2) While I was generating entities I was giving the package name as com/domainname/ejb/testjpaprojectfacets/model. But I was already having a package com/domainname/ejb/TestJPAProjectFacets hence the error. I then renamed my existing package to all lowercase (com/domainname/ejb/testjpaprojectfacets) and it worked.

Thanks, Sanjay

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

1 Comment

Thanks for the log debugging. In my case the user did not have sufficient permission to access the schema list from syscat
3

My workaround was to use the JTDS JDBC Driver to connect to SQL Server database instead of the Microsoft SQL Server JDBC Driver

1 Comment

Which version of the JTDS JDBC Driver you are using ?
0

This sounds like Eclipse DTP bug 282206. Dali (the Eclipse project that supplies the Entity Generation wizard you are using) depends on the Eclipse DTP project for retrieving from various database servers the necessary meta-data to generate entities. The MS SQL Server "driver" you are using (i.e. the plug-in used by DTP to adapt the MS SQL JDBC driver to the DTP SPI interfaces - by default this plug-in is org.eclipse.datatools.enablement.msft.sqlserver... - it is a bit confusing that the DTP developers like to call these plug-ins "drivers"....) has a bug in the meta-data it returns to Dali, preventing Dali from generating entities.

3 Comments

I'm using the MS SQL driver from the Microsoft website. Can you suggest a driver to try? I was able to generate the entities in Netbeans using the same driver. I can't believe more people haven't experienced this issue.
Is there any other way to generate the entities in Eclipse? I don't want to have to manually type everything.
I'm sorry about the confusion: The "driver" I am talking about is an Eclipse plug-in that adapts a JDBC driver to the Java interfaces defined by DTP. DTP ships with a number of "drivers" for various databases (Sybase, Derby, MySQL, etc.) along with a generic "driver" that attempts to adapt any standard JDBC driver. So this problem is an Eclipse problem. Some of these drivers are in much better shape than others, depending on who worked on them over the years. As you can see, the MS SQL bug I referenced is almost 4 years old.... You could comment on the bug and/or contribute a patch....
0

I faced this issue too.

My workaround - Created the database in MySQL and generated entities from there. The generated entity classes work with SQL Server as well. Not faced any other side-effects (so far)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.