Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » historical query - only Oracle 9R2 or later?
historical query - only Oracle 9R2 or later? [message #539091] Wed, 09 June 2010 15:35 Go to next message
Wolfgang is currently offline WolfgangFriend
Messages: 7
Registered: June 2010
Junior Member

my JPA based code correctly fills the HistoryPolicy tables. When I try to select historical data however, I get the following error (glassfishv3 against mySQL)

Exception Description: At present historical queries only work with Oracle 9R2 or later databases, as it uses Oracles Flashback feature.
Query: ReadAllQuery(referenceClass=BankEntity ))

The coding I use is as follows:

    public void testRead() {
        EntityManager em = Persistence.createEntityManagerFactory("TisDatabase").createEntityManager();
        JpaEntityManager jem = em.unwrap(JpaEntityManager.class);
        //add logic for history tables
        Collection<ClassDescriptor> descs =
        for (ClassDescriptor descriptor : descs) {
            String primaryTable = descriptor.getTableName();
            HistoryPolicy policy = new HistoryPolicy();
            policy.addStartFieldName(primaryTable + ".row_start");
            policy.addEndFieldName(primaryTable + ".row_end");
            policy.addHistoryTableName(primaryTable, primaryTable + "_hist");

        Session session = jem.getSession();
        ReadAllQuery historicalQuery = new ReadAllQuery(BankEntity.class);
        AsOfClause asOfClause = new AsOfClause(new Timestamp(0));
        List pastBanks = (List) session.executeQuery(historicalQuery);

I expected that HistoryPolicy should work against any database, is my assumption wrong or my code?

best regards, Wolfgang
Re: historical query - only Oracle 9R2 or later? [message #539353 is a reply to message #539091] Thu, 10 June 2010 14:08 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You cannot (safely) change descriptors after startup, you need to make these changes before the EntityManagerFactory is created, or at least before the first EntityManager is created.

You can use a SessionCustomizer (org.eclipse.persistecne.config) in your persistence.xml using the property,


James : Wiki : Book : Blog : Twitter
Previous Topic:Select count(*)
Next Topic:NullPointerException with nested fetch join and multiselect
Goto Forum:

Current Time: Mon Apr 23 23:26:18 GMT 2018

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

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