users@glassfish.java.net

hot to load a class from multiple tables with JPA

From: <glassfish_at_javadesktop.org>
Date: Mon, 19 Nov 2007 13:18:48 PST

Hi, I have a question.
I'm using JPA to persist a class. Now, there will be millions of instances of this class (not in memory, of course, but stored in the database). This instances will be used in intensive processes, which will require maximum performance. If I store all records in the same table, it's very likely that performance problems will arise. So, I'd like to persist these entities (all of the same class) in different tables, in order to reduce the access time for each table.
For instance, consider a billing system that generates charges for clients every month. 10M clients and 10 charges per client per month would generate 100M records per month. What I'd like to do, is to have one table per month, and then to be able to run a JPQL query such as this:

SELECT c from Charge c where c.client = :client

This select should be converted into N selects to the N tables available, or into a single select with UNION statements (whatever the persistence provider choses).
Of course, it's not possible to do this out of the box.
Did anyone run into a similar problem? Did anyone find a solution? If so, could you please sumarize the solution?

Thanks in advance
[Message sent by forum member 'martinstraus' (martinstraus)]

http://forums.java.net/jive/thread.jspa?messageID=246193