java - JPQL Query doesn't work -
hello wanna try to run query
update warmtimemonitoring wtm set wtm.warmtime = (extract(hour current_timestamp - wtm.entrydate)*60)+ extract(minute current_timestamp - wtm.entrydate ) wtm.leavingdate null
when try query right on database works
update warmtime_monitoring w set w.warm_time = (extract(hour current_timestamp - w.entry_date)*60)+ extract(minute current_timestamp - w.entry_date) leaving_date null;
if try jpql following error:
exception occurred while performing database query: illegalargumentexception-> exception occurred while creating query in entitymanager: exception description: syntax error parsing [update warmtimemonitoring wtm set wtm.warmtime = (extract(hour current_timestamp - wtm.entrydate)*60)+ extract(minute current_timestamp - wtm.entrydate ) wtm.leavingdate null ]. [68, 85] left expression not arithmetic expression. [131, 148] left expression not arithmetic expression.
can explain me why happens , how can fix it?
and yes checked warmtime entrydate , leavingdate callable.
as @neil stockon said, of functions not valid jpql operations, suggest, first go record , information needed make , update
select w.id, w.entry_date warmtime_monitoring w leaving_date null;
once id of record , entry_date operations need date, conform new date , jpql update
update warmtime_monitoring w set w.warm_time = :time id = :id
this inefficient if have large amount of data.
Comments
Post a Comment