File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate Annotation Example id null issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Annotation Example id null issue" Watch "Hibernate Annotation Example id null issue" New topic
Author

Hibernate Annotation Example id null issue

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
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
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 650
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

Joined: Jun 08, 2009
Posts: 238
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

Joined: Apr 01, 2009
Posts: 650
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,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Annotation Example id null issue