Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

find() method in EJB 3 /JPA  RSS feed

 
Joemon Anthony
Greenhorn
Posts: 26
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using EJB3 with JPA. In that I want to use the find() method. My question is that, can I use find method to find all the records on the non primary key basis ie; my search condition is not the primary key.

 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36463
464
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch Joemon!

The find() method only works with primary keys. You can use the createQuery() method to pass in random queries though using any where clause. createNamedQuery() is generally better because it can prepare/cache the query for reuse.
 
Joemon Anthony
Greenhorn
Posts: 26
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!