Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to extend JPA entity NamedQueries?

 
Ralf Butler
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

How do I extend a JPA entity in regard to its NamedQueries. Following doesn't work:


I then invoke the whole thing via:


I receive the error message that singleResult is empty.

Help is much appreciated.
Thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. These two are just nitpicks and you don't have to change it.

1) I put my Named queries above the @Entity because Named Queries, while you have them in a class are not scoped to the class but to the SessionFactory.
2) What is with all those front underscores. "_". This is Java we don't use underscores in variable names. ;)

So do you have show_sql on so that you can see the query that gets run? Then check to see if the query itself actually returns records from the database. The error that shows is saying that the query is running except that the result set has no records in it.

Mark
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!