mysql - How to make a working SQL query a native query in spring data -


i created sql query:

select order_num, stuff2, stuff3 table1 t1 (stuff3 = 'poor') , not exists (select order_num table2 t2 t1.order_num = t2.order_num)

the query works correctly , desired result; however, trying use working query in spring data application native query, using @query annotation.

@query(value = "select order_num, stuff2, stuff3 table1 t1 (stuff3 = ?0) , not exists (select order_num table2 t2 t1.order_num = t2.order_num)", nativequery = true) list<eorder> findbystuff3(string stuff3); 

i copied exact same query , placed in repository (as shown above) value binding null , no records showing. there step missing make query work spring application?

through further research able fix problem having. native query used in repository work, there simple error in code, instead of 0, replaced 1 , worked great!

old version:

@query(value = "select order_num, stuff2, stuff3 table1 t1 (stuff3 = ?0) , not exists (select order_num table2 t2 t1.order_num = t2.order_num)", nativequery = true) list<eorder> findbystuff3(string stuff3); 

modified version:

@query(value = "select order_num, stuff2, stuff3 table1 t1 (stuff3 = ?1) , not exists (select order_num table2 t2 t1.order_num = t2.order_num)", nativequery = true) list<eorder> findbystuff3(string stuff3); 

i came across method works using jpql able query run in spring application:

@query(value = "select t1.order_num, t1.stuff2, t1.stuff3 table1 t1 (t1.stuff3 = ?0) , not exists (select t2.order_num table2 t2 t1.order_num = t2.order_num)", nativequery = true) list<eorder> findbystuff3(string stuff3); 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -