The setter is never called if you don't set the value on the jsf page.
To achieve what you want either use a default on the column value by changing the created database schema or use the @Prepersist annotation.
Thank you, great. Prepersist did help.
Still, with above scenario I have the problem with id. It supposed to be auto generated. However, when I add @GeneratedValue I am getting the exception on startup:
Reason: javax.persistence.PersistenceException: org.hibernate.HibernateException: Missing sequence or table: hibernate_sequence
I Depend On:
With the old variant of Hibernate this auto sequence generated worked with the following annotation used in Doclet:
* @hibernate.id column="ID" generator-class="increment" unsaved-value="0"
Again, any suggestions?
I think it is not a good idea to use the generator strategy increment.
Create the sequence insted. If you have already data in the schema, set the initial value of the sequence so you don't get duplicate pks.
Use @SequenceGenerator or alter the sequence manually.