N.A
N.A

Reputation: 855

jpa query error:the multi-part identifier could not be bound

I am using JPA custom query in Spring application in which I need to query one table multiple times.

I write this query in repository:

@Query(value="SELECT *"+
"FROM TBLSTUDENTEQUALITY as e"+
"left join VLE_LOOKUP_DATA as di on e.DISABLE_ID=di.ID"+
"left join VLE_LOOKUP_DATA as d on e.DOMICILE_ID=d.ID"+
"left join VLE_LOOKUP_DATA as n on e.ETHNIC_ID=n.ID"+
"left join VLE_LOOKUP_DATA as g on e.GENDER_ID=g.ID"+
"left join VLE_LOOKUP_DATA as na on e.NATIONALITY_ID=na.ID"+
"left join VLE_LOOKUP_DATA as s on e.SEX_ID=s.ID"+
"left join VLE_LOOKUP_DATA as o on e.SEXORT_ID=o.ID"+
"left join VLE_LOOKUP_DATA as r on e.RELIGION_ID=r.ID"+
"where STUDENT_ID=?1",nativeQuery=true)
public List<StudentEquality> getAll(Long ID);

This query runs successfully in sql server but in spring boot application it is producing error like:

 java.sql.SQLException: The multi-part identifier "e.DISABLE_ID" could not be bound.

If I remove e.disable-id line it comes on next line.I have explored many resources mostly suggest that may be column or table name for this isn't present but if this is the case it should give error in SQL server too.

Upvotes: 0

Views: 648

Answers (1)

Roman C
Roman C

Reputation: 1

The query is invalid because it doesn't have spaces between clauses at the end of each sentence. Add spaces before or after each line

@Query(value="SELECT * "+
"FROM TBLSTUDENTEQUALITY as e "+
"left join VLE_LOOKUP_DATA as di on e.DISABLE_ID=di.ID "+
"left join VLE_LOOKUP_DATA as d on e.DOMICILE_ID=d.ID "+
"left join VLE_LOOKUP_DATA as n on e.ETHNIC_ID=n.ID "+
"left join VLE_LOOKUP_DATA as g on e.GENDER_ID=g.ID "+
"left join VLE_LOOKUP_DATA as na on e.NATIONALITY_ID=na.ID "+
"left join VLE_LOOKUP_DATA as s on e.SEX_ID=s.ID "+
"left join VLE_LOOKUP_DATA as o on e.SEXORT_ID=o.ID "+
"left join VLE_LOOKUP_DATA as r on e.RELIGION_ID=r.ID "+
"where STUDENT_ID=?1",nativeQuery=true)

Upvotes: 1

Related Questions