Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA Queries with Historical Session
JPA Queries with Historical Session [message #819249] Mon, 12 March 2012 17:15 Go to next message
Alfredo Osorio is currently offline Alfredo OsorioFriend
Messages: 6
Registered: March 2012
Junior Member
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 17:00]

Report message to a moderator

Re: JPA Queries with Historical Session [message #825195 is a reply to message #819249] Tue, 20 March 2012 15:33 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.


James : Wiki : Book : Blog : Twitter
Previous Topic:Criteria Query Expression isNull() not working
Next Topic:cache coordination - Received JMS message is null
Goto Forum:
  


Current Time: Thu Apr 25 09:29:23 GMT 2024

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

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

Back to the top