简体   繁体   English

未通过Eclipse Juno和GWT导入的Hibernate类:LockMode,SessionFactory,Criterion

[英]Hibernate Classes Not Importing with Eclipse Juno and GWT: LockMode, SessionFactory, Criterion

Environment 环境

  • Ubuntu 12.04 LTS Ubuntu 12.04 LTS
  • Eclipse Juno 4.2 Build id: 20120614-1722 Eclipse Juno 4.2内部版本号:20120614-1722
  • GWT SDK - 2.4.0 GWT SDK-2.4.0
  • App Engine SDK - 1.7.2 App Engine SDK-1.7.2
  • Hibernate Version 3.5 休眠版本3.5
  • JRE: java-7-openjdk-amd64 JRE:java-7-openjdk-amd64

In reference to @mael comment, Hibernate Tools was installed from the following Eclipse repo: http://download.jboss.org/jbosstools/updates/stable/indigo/ 为了引用@mael注释,从以下Eclipse存储库中安装了Hibernate Tools: http : //download.jboss.org/jbosstools/updates/stable/indigo/

Problem 问题

The project is a GWT Web Application that uses Hibernate as the entity/persistence manager. 该项目是一个GWT Web应用程序,它使用Hibernate作为实体/持久性管理器。 I have successfully configured Hibernate to connect to the database, and it pulls in all the tables and associated columns I am interested in. I use Hibernate to reverse engineer the entity/persistence classes; 我已经成功配置了Hibernate来连接数据库,并且它引入了我感兴趣的所有表和关联的列。我使用Hibernate对实体/持久性类进行反向工程; it runs successfully, but I get the import errors in the newly generated classes: 它成功运行,但是在新生成的类中出现导入错误:

  • The import org.hibernate.LockMode cannot be resolved. 导入org.hibernate.LockMode无法解析。
  • The import org.hibernate.SessionFactory cannot be resolved. 导入org.hibernate.SessionFactory无法解析。
  • The import org.hibernate.criterion.Example cannot be resolved. 导入org.hibernate.criterion.Example无法解析。

Research/Troubleshooting 研究/故障排除

There was similar problem I found here . 我在这里发现类似的问题。 I performed the search for the aforementioned classes, and did not find them. 我搜索了上述类,但没有找到它们。 I then readded java-7-openjdk-amd64 JRE under Windows > Preferences > Installed JREs . 然后,在Windows>首选项>已安装的 JRE下阅读java-7-openjdk-amd64 JRE This did not resolve the problem. 这不能解决问题。

Also, there does not seem to be very much out there for this problem. 同样,似乎没有太多的问题可以解决。 So I am assuming there is something I have not understood in the setup of Hibernate and reverse engineering. 因此,我假设在Hibernate和逆向工程的设置中有些不了解的事情。

Another Similar Problem - Same Solution 另一个类似的问题-相同的解决方案

Update: Solution 更新:解决方案

  1. Following @mael's solution, I confirmed that Hibernate Tools does not automatically include the Hibernate jar files required for the auto-generated entity/persistence classes. 按照@mael的解决方案,我确认Hibernate Tools不会自动包含自动生成的实体/持久性类所需的Hibernate jar文件。
  2. Downloaded the Hibernate4 jar files from the following location . 从以下位置下载了Hibernate4 jar文件。
  3. Extracted files to the Eclipse workspace. 将文件解压缩到Eclipse工作区。
  4. In Eclipse, right-click on {Project} and go to Build Path > Configure Build Path... > Java Build Path. 在Eclipse中,右键单击{Project},然后转到Build Path> Configure Build Path ...> Java Build Path。
  5. Click on the Libraries tab. 单击库选项卡。
  6. Click on Add External JARs... 点击添加外部JAR ...
  7. Go to directory where Hibernate4 JAR files were extracted, and follow the path to lib > required . 转到提取了Hibernate4 JAR文件的目录,然后遵循lib> required的路径。
  8. Select all JAR files in the folder and confirm. 选择文件夹中的所有JAR文件并确认。

You may want to check your eclipse Build Path. 您可能需要检查Eclipse的构建路径。

Right-click your project and navigate Build Path>Configure Build Path and in the tab libraries look for the Hibernate library, if you do not see it then download the jars manually or optionally use maven or ant to do this. 右键单击您的项目,然后导航到“构建路径”>“配置构建路径”,然后在选项卡库中查找Hibernate库,如果看不到它,则手动下载jar或选择使用maven或ant来执行此操作。

I don't remember if Hibernate Tools incorporates the Hibernate jars in the eclipse set of libraries. 我不记得Hibernate Tools是否在eclipse库集合中包含了Hibernate jars。 But if it doesnt, it should I guess. 但是,如果没有,我应该猜。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM