Friday 11 November 2011

JPA/Hibernate reminder: initialize all fields! if not then set it to null

If I don't initialize a field then I get a transient exception.
If I initialized it by calling a class constructor then the new object is
persisted to db. What if I want this Foreign Key (FK) to be empty?

solution: If I initialize it to null then everything it's ok (why?).

Note: If I remove the CascadeType.ALL then I get again the transient exception

References

http://cagataycivici.wordpress.com/2005/11/15/pivefacedwith/

No comments:

Post a Comment