1
votes

Environment

  • Ubuntu 12.04 LTS
  • Eclipse Juno 4.2 Build id: 20120614-1722
  • GWT SDK - 2.4.0
  • App Engine SDK - 1.7.2
  • Hibernate Version 3.5
  • 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/

Problem

The project is a GWT Web Application that uses Hibernate as the entity/persistence manager. 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; it runs successfully, but I get the import errors in the newly generated classes:

  • The import org.hibernate.LockMode cannot be resolved.
  • The import org.hibernate.SessionFactory cannot be resolved.
  • The import org.hibernate.criterion.Example cannot be resolved.

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. 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.

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.
  2. Downloaded the Hibernate4 jar files from the following location.
  3. Extracted files to the Eclipse workspace.
  4. In Eclipse, right-click on {Project} and go to Build Path > Configure Build Path... > Java Build Path.
  5. Click on the Libraries tab.
  6. Click on Add External JARs...
  7. Go to directory where Hibernate4 JAR files were extracted, and follow the path to lib > required.
  8. Select all JAR files in the folder and confirm.
1
are you using maven, ant or just importing the jars to the project in eclipse?ElderMael
@mael - I have installed Hibernate as an Eclipse plugin (just to reference how I'm using Hibernate); as for the other jars such as openjdk, I've imported them. I am not using any other build tools at this time.hulkmeister
Hibernate as an Eclipse Plugin? You mean Hibernate Tools?ElderMael
Well, that plugin does not necessarily puts the Hibernate required jars in your classpath. Right-click your project and look for the menu Build Path>Configure Build Path... and in the Libraries tab check for the Hibernate Libraries.ElderMael
If you don't find them then you will need to manually download the jars or use a tool like maven or ant to do that for you. Check also versions.ElderMael

1 Answers

1
votes

You may want to check your eclipse Build Path.

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.

I don't remember if Hibernate Tools incorporates the Hibernate jars in the eclipse set of libraries. But if it doesnt, it should I guess.