Using JPA (with Hibernate), I was inserting a record in my database. In my table, one column is defined with a DEFAULT Value.
But when I insert a save, persist my record, JPA put it as NULL.
So using JPA, the solution was to use insertable = false in the column definition. JPA will ignore then that column while inserting in the Database and the default value will be used.
@Column(name = "myColumn", length = 35, insertable = false)
But when I insert a save, persist my record, JPA put it as NULL.
So using JPA, the solution was to use insertable = false in the column definition. JPA will ignore then that column while inserting in the Database and the default value will be used.
@Column(name = "myColumn", length = 35, insertable = false)
Hello Mariem, content de voir que tu refais du JAVA ;)
ReplyDeleteSalut Sothea, Eh bah oui je suis toujours fidele au Java ;0 Bon la c'est du JPA aussi
DeleteIs there Anyway to allow user to set the value when inserting and, if user haven't set the value apply the default value?
DeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete