Sneak preview: Quaere for JPA
Even if only the Quaere for Object implementation has been available, the project has generated quite a lot of buzz. Quaere for Objects only shows some of the things you can do with the framework, and I feel that the biggest potential is how one can extend Quaere to enable querying of other data sources. Therefore, I’m very glad to let you know that the first sneak preview of Quaere for Java Persistence API (JPA) has been added to the trunk. Quaere for JPA still only supports a subset of the Quaere language, but it is usable. Below is an example of how one can retrieve all the customers in the Washington region from the database.
EntityManagerFactory entityManagerFactory = new EntityManagerFactoryImpl(sessionFactory, PersistenceUnitTransactionType.RESOURCE_LOCAL, true);
QueryableEntityManager entityManager = new QueryableEntityManager(entityManagerFactory.createEntityManager());
Iterable<Customer> waCustomers =
from("c").in(entityManager.entity(Customer.class)).
where(eq("c.getRegion()", "WA")).
select("c");
for (Customer c : waCustomers) {
log.info(c);
Assert.assertEquals("WA", c.getRegion());
}
Notice that the only difference between this and a Quaere for Objects query is that the from-in clause accepts an entity reference provided by a wrapper around a regular javax.persitence.EntityManager.
If you want to see more head on over to http://svn.codehaus.org/quaere/trunk/QuaereForJPA/
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using