VKP
VKP

Reputation: 658

Why literal does not match format string exception in JPA while saving Date Field

I have some Date fields in Oracle but i kept it as String in Entity Class. Except one field all other fields are saving correctly . For one field i am getting an error as

ORA-01861: literal does not match format string. 

Just before calling the save function in JPA i see the values exactly matching with the values which are saving correctly . Not sure what else can debug or how i can fix it . Below are the values just before calling save .

paymentDate=2013-03-04 16:30:07,
noteDate   =2013-03-04 16:30:07,

Upvotes: 1

Views: 479

Answers (1)

kameshsr
kameshsr

Reputation: 357

using To_Date TO_DATE(dateStr, formatStr) may solve your problem.

if your table column data type is String then you should typecast to a string before saving it to your database.

Upvotes: 2

Related Questions