historical query - only Oracle 9R2 or later? [message #539091] |
Wed, 09 June 2010 11:35  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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>
|
|
|
Powered by
FUDForum. Page generated in 0.24687 seconds