• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NamedQuery

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: Maikalai Zaikin's notes.

Given:



When invoking this query from another bean,.... Given,


Is it legal to call to that named query as "magsOverPrice"?
Shouldn't it be "Magazine.magsOverPrice" ?
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Named queries are persistence-unit scoped, so the names are global and must be unique per unit. Thus, you don't prefix it with anything as it doesn't add any meaning.
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understood! Thank you Raf
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raf,

What would be the result if a entity tries to access a query, out of the entity's persistence-unit?
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EntityManager.createNamedQuery() throws IllegalArgumentException in this case. See the API.

Raf
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! got it!
 
jkjllkj jkjllkj
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ARG: Removed BA post ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic