jpanamed-parametersnamed-querytoplink-essentials

JPA TopLink Help!


Greetings,

As of now I had accomplished building a single-table JPA. But when going to one-to-one or one-to-many. Things get complicated. Especially when it comes to queries with parameters.

I always get an exception on a named-query

Exception Description: Error compiling the query [Subject.searchBySubjectCode: 
SELECT s FROM Subject s WHERE s.subjectcode = :subjectcode], line 1, column 33: 
unknown state or association field [subjectcode] of class [model.Subject].

How is this possible? Yet I added both entities on the persistence.xml. BTW, I'm using TopLink Essentials and implement the JPA on MVC Architecture. In addition, when I re-open the form, this exception always returns then.

java.lang.IllegalArgumentException: NamedQuery of name: <query> not found.

Solution

  • Solved the problem again... Just used TypedQuery