Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Hibernate Annotation Example id null issue

 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using annotation tags within hibernate example 'CreateData.java'class to do simple insert into oracle 10g database table 'student2'. IP am getting error like



My createData.jaava looks like



hibernate-cfg class looks like

student2.java class looks like



within oracle 10g my student2 table creation syntax looks like

I am not sure why it is complaining about id is not null.

How can i resolve this issue. Any ideas, suggestions, links, resources, sample code highly appreciated. Thanks in advance
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if these are causing your problems, but I noticed a couple problems.

1. In your hibernate configuration file, you are using the MySQL Dialect while the rest of the configuration specified Oracle. Is that intentional?

2. In your Student2.java class, you defined the ID column as int, but in your database table creation script, you define it as varchar2(20, byte).

These just looked funny to me.

Good luck.
 
Mathew Lee
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you for your response. You are right. In hibernate.cfg.xml file dialect i have not changed to oracle still pointing to old mysql. After changing everything is working fine
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

gudim gudi wrote:Hi,

Thank you for your response. You are right. In hibernate.cfg.xml file dialect i have not changed to oracle still pointing to old mysql. After changing everything is working fine

Then you should mark your post as 'Resolved'.

Best Regards,
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic