I'm trying to persist a object with the following code:
Code:
sessionFactory.getCurrentSession().save(myObject)
myObject is a instance of Class MyObject & most of the fields are set from Spring form. Only the columns which have default values defined in MySQL are not set e.g. ID
Code:
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "MyObjectID", unique = true, nullable = false)
public Integer getMyObjectID() {
return this.myObjectID;
}
There are other fields too like current_TS which has default in MYSQL.
But upon execution i get the following error:
Code:
org.hibernate.AssertionFailure: null id in .............. entry (don't flush the Session after an exception occurs)
How to persist an object without setting it's default values so that MySQL sets those default values. Please guide.
I'm stuck...please help.