简体   繁体   中英

Issue while implementing json_exists using JPA Native query

My Query looks like below,

@Query(value="SELECT * FROM Retention_Record retention where retention.entity=:entity and retention.category=:category and retention.record_type=:recordType and json_exists(retention.reference_data_id, '$?(@==$referenceDataId)' passing :referenceDataId as \"referenceDataId\")" , nativeQuery=true)

When i am getting below error while execution of this query

2020-07-23 16:12:11 [eventsTaskExecutor-5] [] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 29902, SQLState: 99
999
2020-07-23 16:12:11 [eventsTaskExecutor-5] [] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ORA-29902: error in executing
ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50900: text query parser error on line 1, column 10
DRG-50917: escape on at end of text query string

Can anyone please help.

I fixed the issue. Problem was with the way i was storing the Json Object in database. I was storing the value in db as ["50000021","50000022"] which in fact is a valid json, and was trying to execute my query to provide result, which was resulting in error. When i stored data in this format, { "ReferenceDataId": ["50000021","50000022"] } below query successfully executed. – Ritesh 1 min ago Edit Delete

@Query(value = "SELECT * FROM Retention_Record retention where retention.entity=:entity and retention.category=:category and retention.record_type=:recordType and json_exists(retention.reference_data_id, '$.ReferenceDataId?(@==$referenceDataId)' passing:referenceDataId as \"referenceDataId\")", nativeQuery = true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM