Techiio-author
Started by Peter DanielsSep 25, 2021

Open
JPA @query is not working when date value is null during insert

1 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 1 VIEWES SHARE

I have written below java code in my JPA repository.

@Query("insert into table (date_colum) value(:dateValue)",nativeQuery= true)
public int insertData(@Param("dateValue") dateValue);

Above code is working perfect when dateValue column is having some value. But when value of dateValue cloumn is null in that case it will giving the below error .

Error : ora-00932 inconsistent datatypes expected date got binary

Any solution please , help is appreciate.

1 Replies

Techiio-commentatorNeel Dey replied 4 months ago0 likes0 dislikes

If We add @Temporal to your Date parameter, Spring Data knows how to present that parameter to Hibernate, even if it is null:

The code is as below.

@Query("insert into table (date_colum) value(:dateValue)",nativeQuery= true)
public int insertData(@Param("dateValue") @Temporal java.util.Date dateValue);
You must be Logged in to reply
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance