Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORA-01425: escape character must be character string of length 1 #3753

Closed
gowrishankarjhcbb opened this issue Jan 28, 2025 · 3 comments
Closed
Labels
for: external-project For an external project and not something we can fix

Comments

@gowrishankarjhcbb
Copy link

gowrishankarjhcbb commented Jan 28, 2025

Query Generated by spring data jpa is invalid and having double slash for oracle.

This is my code snippet

Optional<EdpRecordData> findByMsgIdAndCreditorAgentStartsWithAndDebtorAgentStartsWith(
      String msgId,
      String creditorAgent,
      String debtorAgent);

SQL Query Generated

    select
        erd1_0.msg_id,
        erd1_0.debtor_agent,
        erd1_0.creditor_agent 
    from
        edp_records erd1_0 
    where
        erd1_0.edp_status=? 
        and erd1_0.creditor_auto_presentment_flag=1 
        and erd1_0.creditor_auto_presentment_date=? 
        and erd1_0.creditor_agent like ? escape '\\'
Hibernate: 
    select
        erd1_0.msg_id,
        erd1_0.debtor_agent,
        erd1_0.creditor_agent 
    from
        edp_records erd1_0 
    where
        erd1_0.edp_status=? 
        and erd1_0.creditor_auto_presentment_flag=1 
        and erd1_0.creditor_auto_presentment_date=? 
        and erd1_0.creditor_agent like ? escape '\\'

Exception thrown by Oracle.
java.sql.SQLDataException: ORA-01425: escape character must be character string of length 1

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 28, 2025
@christophstrobl
Copy link
Member

Please do not post images of code but use proper code fences.
If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.

@gowrishankarjhcbb
Copy link
Author

Please do not post images of code but use proper code fences. If you'd like us to spend some time investigating, please take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem.

updated with code snippet

@mp911de
Copy link
Member

mp911de commented Jan 29, 2025

Spring Data isn't generating any SQL from queries, Hibernate is doing so. I suggest reporting the issue in the Hibernate issue tracker as we're using CriteriaBuilder.like(Predicate like(Expression<String> x, Expression<String> pattern, char escapeChar) to create the LIKE expression.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2025
@mp911de mp911de added for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

4 participants