Home » Java » Update column to default value without specifying it in Spring Data JPA

Update column to default value without specifying it in Spring Data JPA

Posted by: admin July 23, 2018 Leave a comment

Questions:

I wish to set default value for a given column defined in DB, as explained here, without specifying it from my application. What I wish for Oracle JDBC to generate is the following;

UPDATE TABLE_X SET COLUMN_A = default WHERE ...

or maybe

UPDATE TABLE_X SET COLUMN_A = systimestamp WHERE ...

since COLUMN_A TIMESTAMP WITH TIME ZONE DEFAULT systimestamp NOT NULL

When I specify the default value for the column, JDBC generated the string value in an unwanted format, and I was unable to customize this behaviour, which was explained here.

Is there a way to trigger this behaviour through Hibernate/JPA? I am trying to circumvent defining a default value within my application, but utilizing default keyword within SQL so that predefined value from Oracle side will be used.

I do not want any solution from DB side, but only for application side.

Answers: