GWT with JPA

2019-01-17 08:37发布

I'm trying to build database application using GWT 1.5.3. I use JPA annotations with my objects. It seems in hosted mode GWT's RPC works fine. But when I try to compile my app using GWT-compiler I get errors like: "The import javax.persistence cannot be resolved", "Entity cannot be resolved to a type". toplink-essentials.jar is already included in my project path. What settings else do I need to solve this problem?

7条回答
迷人小祖宗
2楼-- · 2019-01-17 08:57

You can use Gilead (http://sourceforge.net/projects/gilead/) library to seamlessly manage JPA entities with GWT.

Regards

查看更多
成全新的幸福
3楼-- · 2019-01-17 08:57

You need to include the source code for the JPA annotations in the build path for your GWT project. See here for more details:

http://code.google.com/p/google-web-toolkit/issues/detail?id=1830&can=1&q=jpa

Specifically this jar file which will fix your problem:

http://google-web-toolkit.googlecode.com/issues/attachment?aid=1475633892125294312&name=jpa-annotations-source.jar

查看更多
一纸荒年 Trace。
4楼-- · 2019-01-17 08:57

Simply, keep another version of your Entities but without the annotations!

查看更多
Melony?
5楼-- · 2019-01-17 09:10

Rebounding on synergetic's comment, you now (from GWT 1.5) only need to add

<source path='javax.persistence'/>

to your Module.gwt.xml

查看更多
乱世女痞
6楼-- · 2019-01-17 09:14

I am also working with JPA <--> GWT data transformation etc.

In an effort to eliminate the DTO layer I used Gilead too.

My objection here is about translating javax.persistence. To avoid this I used XML JPA mapping declarations (orm.xml)

查看更多
▲ chillily
7楼-- · 2019-01-17 09:20

Ok, I've found what I was missing. I needed to include jpa-annotations-source.jar in my GWT-compiler path in myapp-compile.cmd script (or in ant build file). By the way can anyone tell me the origin of this jpa-annotations-source.jar file?

查看更多
登录 后发表回答