1

I'm creating web application. I'm using Spring and hibernate. When doing the below,

userprofile.setFirstName(firstname); userprofile.setLastName(lastname); userprofile.setDob(bday); userprofile.setPhoneNumber(telephone); userprofile.setEmailId(email); userprofile.setPassword(password); // userprofile.setCreatedDate(sysdate); session.save(userprofile); t.commit(); 

Hibernate is generating the below insert query

Hibernate: insert into USER_PROFILE (CREATED_DATE, DATE_OF_BIRTH, EMAIL_ID, FIRST_NAME, LAST_NAME, PASSWORD, PHONE_NUMBER, PROFILE_ID) values (?, ?, ?, ?, ?, ?, ?, ?) 

which is inserting null value in my created_date field. I've made that created_date field's default value as sysdate. Please help me to sort out this.

1
  • Post your userprofile class Commented Sep 25, 2018 at 12:49

1 Answer 1

1

I got it resolved..In pojo class, the following insertable=false should be added. This will avoid insertion of null and default value set in table will be inserted instead.

@Column(name = "CREATED_DATE", insertable=false) private Date createdDate; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.