2

I am trying to set a previously set date field to null in oracle using hibernate but once the "nullable" column is set to a date, I can't set it to null again because I don't know how to represent the null date to pass as a parameter in the below query.

Query updateQuery; updateQuery = em.createNativeQuery("UPDATE STATION SET MOD_DT = ?1 WHERE STATION_ID = ?2"); updateQuery.setParameter(2, stationId); updateQuery.setParameter(1, null); updateQuery.executeUpdate(); 

Log:

g! Dec 02, 2014 4:41:46 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 932, SQLState: 42000 <02-Dec-2014 16:41:46 o'clock EET> <Warning> <org.hibernate.engine.jdbc.spi.SqlExceptionHelper> <BEA-000000> <SQL Error: 932, SQLState: 42000> Dec 02, 2014 4:41:46 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: ORA-00932: inconsistent datatypes: expected DATE got BINARY <02-Dec-2014 16:41:46 o'clock EET> <Error> <org.hibernate.engine.jdbc.spi.SqlExceptionHelper> <BEA-000000> <ORA-00932: inconsistent datatypes: expected DATE got BINARY> 
0

2 Answers 2

1
Query updateQuery; updateQuery = em.createNativeQuery("UPDATE STATION SET MOD_DT = null WHERE STATION_ID = ?1"); updateQuery.setParameter(1, stationId); updateQuery.executeUpdate(); 

Some info here: https://hibernate.atlassian.net/browse/HHH-9165

Sign up to request clarification or add additional context in comments.

Comments

0

try solution from this question: similar question

setParameter with 3 arguments, one of argument is type of value

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.