Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[JBoss 6.0 M1] EJB 3.0 Named queries (orm.xml)

 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My application seems to show some weird beahviour regarding named queries.
I use both ways to define named queries:
inside META-INF/orm.xml and with the annotation @NamedQuery on the entity bean.

Calling a named query that is define in the orm.xml file works well.
However calling a named query that is define at the class level (entity bean) does not seem to work (no logs).

Does anyone know if this is normal behaviour with JBoss, before i investigate further ?
The specs do not say anything about not using both at the same time, as far as i know.
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind. Fixed it.

With JBoss, it seems :


is not the same as


Notice the space at the end.

Someone has an explanation for that ?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The (hibernate) persistence provider doesn't seem to "trim" the name while looking for a matching @NamedQuery. The spec doesn't mandate it to trim, so i don't think it can be called a bug. But i would have expected it to throw a IllegalArgumentException if the named query was not found, instead of silently failing. The EntityManager.createNamedQuery expects it to throw an IllegalArgumentException.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to ORM forum.
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm thanks.
It makes sense.

There is no visible exception because i am testing with a JSF client which seems to dismiss that exception in the errors output.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic