This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes [JBoss 6.0 M1]  EJB 3.0 Named queries (orm.xml) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "[JBoss 6.0 M1]  EJB 3.0 Named queries (orm.xml)" Watch "[JBoss 6.0 M1]  EJB 3.0 Named queries (orm.xml)" New topic
Author

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

Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

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.


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

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

Joined: Jul 20, 2005
Posts: 9912
    
158

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.


[My Blog] [JavaRanch Journal]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9912
    
158

Moving to ORM forum.
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [JBoss 6.0 M1] EJB 3.0 Named queries (orm.xml)
 
Similar Threads
call a stored procedure using eclipselink Problem...
Can someone plz tell me how to use "named-native-query" tag in orm.xml file of EJB3
Can someone plz tell me how to use "named-native-query" tag in orm.xml file of EJB3.
@NamedQuery - Where it should be
@NamedQuery : does it have to be declared on an @Entity ?