• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Hibernate Annotation Example id null issue

 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic