This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Spring + Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Spring + Hibernate" Watch "Spring + Hibernate" New topic
Author

Spring + Hibernate

Aravind M Jay
Greenhorn

Joined: Mar 16, 2006
Posts: 15
Hi,

This error is a combination of Spring + Hibernate. I have a FK in one of the tables which can accept null. But when this field is left blank the data is not saved in the DB.

This is the error message from the logs -



Table Details -



Hibernate Mapping -



POJO <excerpt> -



Please let me know where am I going wrong.

Thanks,
MJ
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

what is the data type of the column?


If you are not laughing at yourself, then you just didn't get the joke.
Aravind M Jay
Greenhorn

Joined: Mar 16, 2006
Posts: 15
Datatype is Integer.
Tried an alternative -
Replaced <column> with <formula> but this always saves NULL in the DB even though a value is entered.
Please let me know your inputs.
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
Please post your DDL and data insertion code.
Aravind M Jay
Greenhorn

Joined: Mar 16, 2006
Posts: 15
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
Aravind,

I would say that you need to IsolateTheProblem first; I am sure that this behavior can be reproduced without Spring, and without DAOs. The things that are needed, precise and complete, are the Java classes, hibernate mappings, and table definitions (the SQL "create table" statements).
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513



Did you try adding an type column saying it is integer like this,



Iam not sure. What Iam guessing is that, since you have not specified any type for the column mapping, may be it is trying to insert it as a String or something.
Aravind M Jay
Greenhorn

Joined: Mar 16, 2006
Posts: 15
I have tried even declaring the type but to no avail..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring + Hibernate