Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » JPA Queries with Historical Session
JPA Queries with Historical Session [message #819249] Mon, 12 March 2012 13:15 Go to next message
Eclipse UserFriend
Is it possible to execute a JPQL using a HistoricalSession instead of the EclipseLink query language?


Right now I'm forced to do queries like this:

JpaEntityManager jpaEntityManager = entityManager.unwrap(JpaEntityManager.class);

ClientSession clientSession = jpaEntityManager.getServerSession().acquireClientSession();
AsOfClause asOfClause = new AsOfClause(date);
Session historicalSession = clientSession.acquireHistoricalSession(asOfClause);


ReadAllQuery historicalQuery = new ReadAllQuery(Employee.class);

List<Employee> employees = (List<Employee>)historicalSession.executeQuery(historicalQuery);


I would like to do something like:
String jpql = "select e from Employee e";
List<Employee> employees = entityManager.createQuery(jpql, Employee.class).getResultList();


instead of using the ReadAllQuery and still be using the Historical Session.

Is it possible?

If it is not possible I would like to contribute to implement it. Can someone tell me where to start?

Regards,
Alfredo Osorio
Shows Infantiles

[Updated on: Fri, 12 December 2014 12:00] by Moderator

Re: JPA Queries with Historical Session [message #825195 is a reply to message #819249] Tue, 20 March 2012 11:33 Go to previous message
Eclipse UserFriend
This is not directly possible, but you can set an asOf clause on a JPQL query using the query hint "eclipselink.history.as-of".

To get a historical EntityManager would be more work, you could implement this is you want to give it a try. You would add an asOf() API to JpaEntityManager and EntityManagerImpl in EclipseLink. This would return an EntityManagerImpl that wrapped the HistoricalSession instead of a UnitOfWork as it normally does. This would be a read-only EntityManager, so would need to throw an error to any request for modification such as persist/merge/flush/getTransaction/etc.

It would be some work, but should not be too difficult.
Previous Topic:Criteria Query Expression isNull() not working
Next Topic:cache coordination - Received JMS message is null
Goto Forum:
  


Current Time: Wed Jul 23 19:43:34 EDT 2025

Powered by FUDForum. Page generated in 0.03144 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top