1

Whenever my primaryGrpId comes as null the following native query is failing with SQLGrammerException, because it is expecting NUMBER. Andy idea how to set NULL if parameter value is null with native query in JPA. The database is ORACLE.

@Modifying
@Query(nativeQuery = true, value = "update EVENT set PRIMARY_CATEGORY_ID=?2, PRIMARY_GROUPING_ID=?3 where PRIMARY_PERFORMER_ID=?1")
  void updatePrimaryCatGrpOfEntities(Long primaryPerfId, Long primaryCatId, Long primaryGrpId);

Caused by: java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY

All my DAO methods are just declared, no implementation is provided to write something like "setParameter"....etc.

enter image description here

10
  • suppose this post address this issue you are facing. Commented Aug 16, 2017 at 0:21
  • possible duplicate stackoverflow.com/questions/21731343/… Commented Aug 16, 2017 at 0:26
  • see the answers in this question Commented Aug 16, 2017 at 1:07
  • 1
    I would not like to write any implementation for DAO method updatePrimaryCatGrpOfEntities. I don't see any of these answers are providing a solid solution especially for update queries. Commented Aug 16, 2017 at 1:26
  • 1
    It seems to be not possible to deal with NULL values with native queries in JPA Commented Aug 16, 2017 at 19:22

1 Answer 1

-2

Check the column definition allows null.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.