English 中文(简体)
日食时无法创建 jpa 表格
原标题:can t create jpa tables in eclipse

I had a working project in eclipse which created a JPA table from entity to mysql database (still learning). Unfortunately it made the table in the wrong database as I wanted there to be test and production databases. Somehow it got the details for the production db, even that it looked like the selected database connection was for the test. I tampered with the project a bit and made it to connect with right connection object for certain (test). I can ping the db in eclipse (both dbs) and see the db in the Data Source Explorer. But now I can not create the table(s) for the project by right clicking on it and selecting JPA Tools > Generate Tables from Entities . The creation starts and finishes with no errors, like everything works, yet I see no tables in either of the databases. (In eclipse Database explorer or from command line). The persistence.xml should be fine as it already created that one table before.

唯一的错误是对实体类的错误,正如对实体注解中所说的“表XXX 无法解决 ” 。 正如我所看到的,它来自表格,没有创建。

Here s the persistence.xml just in case. http://pastebin.com/djPZei90

该项目也是马文项目,它使用SVN。 月食/项目依赖区成功地由月食/项目修道院装载,与SVN没有并发症。

由于 Maven, 有 2 个持久性. xml 文件( 只有登录证书和数据库名称更改) 用于生产和测试。 可能是 db 连接在第一处被检查并装入错误的文件 。 (只是猜测)

我还试图在生成表格时创建脚本. sql。 我找到了文件, 但它是空的 。

Anyway the problem is now that I can t create the tables anywhere. I am totally puzzled by this. Any hints where I should look to fix this?

最佳回答

Chris had it right, even that I didn t understand the answer correctly at the first reading. I tried with the other provider, but I may had modified the wrong file by accident (2 persistence.xml files as it s a maven project), or there may have been some other reason I failed to spot. I was given a hint earlier, that I should use the given provider (in persitence.xml). Causing that I didn t pay too much attention to it after all. Since using eclipselink, the provider has to be indeed:

    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

再次感谢克里斯, 即使我第一次尝试失败了, 不得不花几个小时 解决这个问题。

问题回答

您能否解决问题? 不幸的是,我碰巧遇到了同样罕见的问题,这完全说不通。 JPA 工具只是不增加绘图课程,不管原因为何,尽管它将它们写进了持久性。 xml 。

上周,所有工作都完美无缺, 但现在一切都是fem/ em。 我甚至在不同的工作空间创建了一个新的独立项目, 但情况却相同。 显然这是一个日蚀/ 插座错误, 否则我无法解释它。 使用日蚀 4. 2. 0. 0. 0. 。 我并不高兴 。

编辑 : 在删除 Dali 工具后, JPA 配置器、 缝合 3 插件创建实体似乎再次起作用 。 不知道为什么, 很可能是冲突, 但它仍然无法解释为什么它发生在现在, 而不是一个月前。 从那以后, 我根本就没有改变我的日食安装...

花一整天在这上面

I created a completely new (JPA) project in Eclipse (Indigo btw). Also created a new database (mysql) for that.

文件 & gt; 新建 & gt; 其它... & gt; 连接配置 。

制作了新的包件结构, 让日圆创造持久性. xml (src/META-INF/ persistence. xml) 。

I made an JPA Entity class with eclipse wizard. (added id (PK) and content fields) Copied the pom.xml from my previous project to the new one (made only minor changes like the project name).

还复制了上一个工程的持久性.xml文件(src/main/java/META-INF/, 不包括测试),从持久性文件更改的数据库细节和登录证书。

Made the project Maven project in eclipse (right click on project name > Configure) As it was now a Maven project the default persistence.xml could be removed as it was in wrong place. (Mavenizing the project removed all the errors from un-existing jars with the pom.xml)

尝试为工程再次创建表格( 相同错误, 但等待... ) 。

在工程 & gt; Maven & gt; 禁用 Maven 自然特性上右单击的工程 & gt; Maven & gt; 禁用 Maven 自然

然后又再次使它 Maven 工程, 右键点击项目 & gt; 配置 & gt;...

重新尝试创造桌子,它创造了这些桌子,一切都成功了!

动作快!

似乎一切都很好,就像我猜想的那样。 似乎有某种马文(插座)+日食的虫子。

在上一个工程上玩同样的把戏没有帮助。 我甚至用向导创建了实体类( 重新移动了已有的 ) 。 将 & lt; glass & gt; 声明添加到持久性. xml 中, 但它仍然无法完成该表 。 (也尝试删除和重新添加maven 性质)

我可能会漏掉一些程序上的内容,或者换种方式,或者一起做错事。但考虑到我得到了另一个项目的工作,而其他项目却没有,用同样的把戏,似乎有一个大恶臭的虫子。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签