My application uses hibernate with Spring Boot.
I have created a table like this:
public class TopicSubscriberMap implements Serializable
{   
    @ColumnDefault(value="'pending'")
    @Column(nullable=false)
    private String status;
    ...
}
The table is getting created as follows in mysql:
mysql> desc topic_subscriber_map;
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| status        | varchar(255) | NO   |     | pending |       |
+---------------+--------------+------+-----+---------+-------+
On saving the table like this:
TopicSubscriberMap tsm = new TopicSubscriberMap();
tsm = mapRepository.save(tsm);
I am getting an error:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'status' cannot be null
If I make the field nullable, then although the table is getting saved, but in the db,
+--------+
| status | 
+--------+
| NULL   | 
+--------+
Why is the @ColumnDefault not working? Where is my mistake here?
Edit: when i remove the @ColumnDefault and declare the column as
private String status = "pending"
then although the default value does work, but the table schema shows:
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| status        | varchar(255) | NO   |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
How can I make the default value work and also show it in the table schema?
 
     
     
    