• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Statements about JPQL

 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Identify FALSE (i.e. INCORRECT) statements about JPQL.

1. It is vendor independent.
2. JPQL queries are compiled into the database specific SQL queries by the container.
3. It can accomodate complex joins involving multiple tables.
4. It can be used to update entity beans.
5. It can be used to insert new rows into the database.
6. It can be used to select values only from tables that have been mapped to the abstract persistent schema.

The answers are 6

// Why is the answer not 5.
It is always possible to select values from tables that have not been mapped with abstract persistent schema. This is done using createNativeQuery.

This can be definately used to insert new rows using persist???
 
Nikhil Jain
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The explanation given to 5 was

Insert statements are not supported by JPQL. New rows can be created in the database using em.persist() operation.

The exp given to 6 was

The domain of a JPQL query consists of the abstract schema types of all entities that are defined in the same persistence unit. Thus, arbitrary tables cannot be accessed using JPQL.

Please help!!!
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It is always possible to select values from tables that have not been mapped with abstract persistent schema. This is done using createNativeQuery.


createNativeQuery is used with native SQL queries, not JPQL. Remember that JPQL is not SQL. With JPQL, only entities from the abstract persistent schema can be retrieved.

And in JPQL, there is no insert statement. You're mixing it again with native SQL.
 
Nikhil Jain
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But the insert options looks so confusing. It technically inserts it into database table. The syntax used is persist method. When I read the statement, it never occured to me that it was talking about insert statement
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the answer is: em.persist() is not part of JPQL.
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused, is the answer 5 or 6???

I think its 5 because 6 sounds like a valid statement.
 
Nikhil Jain
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The 5/6 are quite confusing. Any what I gather from here is, that this question talks about JPQL. So things in em.createQuery(JPQL), where JPQL has to be something related to our schemas. right?

There is also createNativeQuery which does not expect JPQL, it requires native queries.

In terms of these, JPQL does not have insert statement as such.

reply
    Bookmark Topic Watch Topic
  • New Topic