So I got an error, string or binary data would be truncated error from sql-server. I am using hibernate to persist data to MS sql-server.
Usually when you get an error like this it means that the column you're trying to save to is not big enough to hold the data you are trying to insert.
I carefully started to compare to see if one of my BigDecimal variables in the domain doesn't have the correct precision, but after spending a lot of time, I realized this was not the case.
Turns out, I was missing @ManyToOne(optional = false) in the child domain. My parent domain object has a one to many relationship with the child. Adding the annotation solved the issue for me. And I am Hoping this will help somebody seeing similar error.
The question is: Why is database giving a data truncation error when ManyToOne annotation is missing in the domain?