Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Misunderstood Enthuware Questions

 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are correct regarding Java Persistence Query Language (JPQL)?

1) A JPQL Query must contain a 'select' and a 'where' clause.

2) A JPQL query must contain a 'select', a 'where', and a 'from' clause.

3) A JPQL query must contain a 'select', and a 'from' clause.

4) JQPL queries are based on the database schema.

5) None of these.

the correct answer given is 5. Just for your information, in the previous version (EJB 2.0), the query language was called EJBQL and it only supported select queries. Now, in EJB 3.0, it is called JPQL and it supports all types of queries. The syntax of both is quite similar with minor differences. Some new built in functions have also been added. For the purpose of the exam, you don't have to worry about EJBQL. Just go through chapter 4 of EJB 3.0 Persistence specification. It is quite easy to understand.

According to me the correct answer is 3.
 
Imran Arif
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JPQL query may be contain 'update' or 'delete' clause.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3712
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amandeep, There is an explanation for every option in this question( Qid: com.enthuware.ets.scbcd.v5.2.177 ) . Did you read that?
 
Bod Toki
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Query query = em.createQuery("UPDATE Post p SET p.body = 'this reply' WHERE p.user like '%Bod Toki%'");
int results = query.executeUpdate();

Query query = em.createQuery("DELETE Post p WHERE p.body = 'this reply''");
int results = query.executeUpdate();

These are valid JPQL queries and I do not see a 'SELECT' statement or 'FROM' clause...
When EJB3.0 talks about queries it means selects, updates, deletes.... not just selects.
 
Amandeep Singh
Ranch Hand
Posts: 850
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok ok i got it. I was wrong here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic