This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate save Oracle Number Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Hibernate save Oracle Number" Watch "Hibernate save Oracle Number" New topic
Author

Hibernate save Oracle Number

Jay Abrahm
Ranch Hand

Joined: May 28, 2008
Posts: 182
I am having issues with Hibernate save. I wanted the newly created primary key so I had saved the object but it gives me a class cast exception. Persist works just fine.

Employee e = sessionFactory.getCurrentSession().save does not work
sessionFactory.getCurrentSession().persist works

java.lang.ClassCastException: java.lang.Long incompatible with com.test.Employee
java.math.BigDecimal incompatible with com.test.Employee -- If I change it to BigDecimal

Oracle column - "ID" NUMBER(36 , 0) NOT NULL

@Id
@GeneratedValue(generator = "testKey")
@SequenceGenerator(name = "testKey", sequenceName = "ID_SEQ")
@Column(name = "ID")
private Long id;

Should I be using something other than Long
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate save Oracle Number
 
Similar Threads
Setting SYSDATE for insert/update
Hibernate: using oracle sequence
Weblogic 10.3.1 + Oracle 10g : Invalid Username / Password on LOB inserts!
Hibernate_listing database values
Sequence generation issue