• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!