Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

executing custom query with ejb3.0  RSS feed

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to execute a query like the foll in ejb3.0..

SELECT s.severity as severity, count(*) as alarmcount FROM ALARMS a, SEVERITY s WHERE a.severityid=s.severityid group by s.severity


Since the result returned is not in the structure as any of the entity bean objects, I cannot use a named query. The createQuery() does not seem to work as well. It gives an error saying that "java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: ALARMS is not mapped"

Please anybody suggest what I can do with this type of query???
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the method createNativeQuery(...) from the EntityManager
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!