This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!