Eclipse中的JPA Project的问题 - 类注释@Entity中的错误:表“xxx”无法解决 [英] Problem with JPA Project in Eclipse - error in class annotated @Entity: Table "xxx" cannot be resolved

查看:383
本文介绍了Eclipse中的JPA Project的问题 - 类注释@Entity中的错误:表“xxx”无法解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在Eclipse(靛蓝)中创建简单的EJB + JPA项目。我创建了新的EJB项目,其中:




  • 目标:现有的Glassfish Server

  • 配置:EJB Module + GlassFish部署描述符文件+ Java + JPA
    在窗口中JPA方面我声明连接到postgres db(ping成功)



I当我试图定义实体时有问题:表员工无法解决。我添加了具有指定名称参数的@Table注释,但这不起作用。
我的persistence.xml文件:

 < persistence-unit name =pu_name> 
< jta-data-source> jdbc / baza1Postgres< / jta-data-source>
< / persistence-unit>

在glassfish中,我定义了JDBC资源,名称为jdbc / baza1Postgres,
如果我的表存在,eclipse知道还有什么我应该配置?

解决方案

找到这个解决方案到表xxx无法解决错误。



在Eclipse中; goto窗口 - >首选项 - >验证,JPA验证器,关闭构建。



有时您正在开发一个应用程序以及新的数据库模式,但是你得到这个:对于表XXXX,模式null无法解析。



这可能不应该默认,人们最有可能会从头开始构建新的应用程序,而不是构建新的应用程序,以适应旧的数据库;即使它们从旧的构建,Eclipse的JPA Tools具有来自表函数的构建实体。


I'm trying to create simple EJB + JPA project in Eclipse (Indigo). I created new EJB project where:

  • Target: existing Glassfish Server
  • Configuration: EJB Module + GlassFish Deployment Descriptor Files + Java + JPA In window JPA Facet I declare connection to postgres db (ping successful)

I have problem when I'm trying to define entity: Table "Employee" cannot be resolved. I added @Table annotation with specified name parameter but this didn't work. My persistence.xml file:

    <persistence-unit name="pu_name">
    <jta-data-source>jdbc/baza1Postgres</jta-data-source>
</persistence-unit>

In glassfish I have defined JDBC Resource with name: "jdbc/baza1Postgres"
How "eclipse know" if my table exist? What else I should configure?

解决方案

Found this solution to "Table xxx cannot be resolved" error.

In Eclipse; goto Window -> Preferences -> Validation, JPA Validator, turn off for Build.

"Sometimes you’re developing an app along with a new database schema to go with it, but you get this: Schema "null" cannot be resolved for table "XXXX".

This probably shouldn’t be on by default anyhow, people are most likely going to build new apps from scratch than build new apps to fit old databases; and even if they do build from old, Eclipse’s JPA Tools has a build entities from tables function."

这篇关于Eclipse中的JPA Project的问题 - 类注释@Entity中的错误:表“xxx”无法解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆