Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate mapping problem

 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to run hibernate example


above is my main class.


below is my model class



file

here is the cfg  file.



I am using oracle 11g database.

I am getting below exception



i tried to find solution in internet.Most of guys says compile jdk version and run runtime version difference may be the problem.But i am using same version in eclipse.


hibernate.png
[Thumbnail for hibernate.png]
screenshot
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem's not in your mapping, it's in a compiler version mismatch. The error indicates that the Hibernate classes are compiled against Java 8 (version 52.0). You're running it with Java 7 though. You'll need to either find a Java 7 compatible Hibernate version, or upgrade to Java 8.
 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i dont have Java 8 installed. I only have java 7 and java 6 versions only. it should be another reason.
 
Dave Tolls
Ranch Hand
Posts: 2369
25
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest solution, if you can't install a Java 8 JRE, is to get hold of Hibernate 5.1.
That was the last version that was 1.7 compatible.
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sam liya wrote:it should be another reason.

There isn't. As Dave indicated, Hibernate 5.2 is built on Java 8; you will need the latest 5.1 version if you need to keep using Java 7.
 
sam liya
Ranch Hand
Posts: 1246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THANKS  ALL.I change the hibernate version to 5.1 and its fine now.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!