CodeDCode
CodeDCode

Reputation: 400

set Oracle Current Timestamp to JPA entity

I Have simple question,

I want to set Oracle CURRENT_TIMESTAMP to my JPA entity, I do not want Java to send value.

I tried below but did not work.

@Column(name="TMSP", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable=false)
private Timestamp tmsp;

its either inserting null or date I set in java but not the DB date.

Upvotes: 2

Views: 1688

Answers (1)

Saranya Ganesan
Saranya Ganesan

Reputation: 11

You can use

updatable= false
@Column(name="TMSP", updatable= false, columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable=false)
private Timestamp tmsp;

Upvotes: 1

Related Questions