I have a many-to-one mapping and not null constraint on the column. i am getting the exception column is Null while saving. Can anybody please suggest how do i use cascade and inverse in this scenario?
Instead of @NotNull, indicate that the association is not optional using @ManyToOne(optional = false). The @NotNull is not specific to Hibernate; it's a generic bean annotation that may be enforced prior to saving the entitites. To be safe, I suggest using @NotNull primarily for @Column attributes.
the entity with the onetomany/collection will by default maintain the association by cascading to the child which inserts first without the backreference and then updates the id. To solve this the onetomany/collection mapping must have the inverse attribute set and the backreference in the child must be set correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With