Skip to main content


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
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 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,

"eclipselink.session.customizer"="<your.package.class>


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


Current Time: Fri Apr 19 05:01:11 GMT 2024

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

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

Back to the top