This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread 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 Head First Android this week in the Android 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: 659

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: 659



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..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Spring + Hibernate
 
It's not a secret anymore!