Skip to main content



      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 11:35 Go to next message
Eclipse UserFriend
Hello,

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)
Quote:

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:

@Test
    public void testRead() {
        EntityManager em = Persistence.createEntityManagerFactory("TisDatabase").createEntityManager();
        JpaEntityManager jem = em.unwrap(JpaEntityManager.class);
        //add logic for history tables
        Collection<ClassDescriptor> descs =
                jem.getServerSession().getProject().getDescriptors().values();
        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");
            descriptor.setHistoryPolicy(policy);
        }

        Session session = jem.getSession();
        ReadAllQuery historicalQuery = new ReadAllQuery(BankEntity.class);
        AsOfClause asOfClause = new AsOfClause(new Timestamp(0));
        historicalQuery.setAsOfClause(asOfClause);
        historicalQuery.dontMaintainCache();
        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 10:08 Go to previous message
Eclipse UserFriend
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,

"eclipselink.session.customizer"="<your.package.class>
Previous Topic:Select count(*)
Next Topic:NullPointerException with nested fetch join and multiselect
Goto Forum:
  


Current Time: Wed Jul 16 01:23:48 EDT 2025

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

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

Back to the top