openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Using JPA for large object sets
Date Mon, 16 Jan 2012 16:10:07 GMT
It sounds like you are interested in the getReference method capabilities:

/**
* Get an instance, whose state may be lazily fetched.
* If the requested instance does not exist in the database,
* the EntityNotFoundException is thrown when the instance
* state is first accessed. (The persistence provider runtime is
* permitted to throw the EntityNotFoundException when
* getReference is called.)
* The application should not expect that the instance state will
* be available upon detachment, unless it was accessed by the
* application while the entity manager was open.
* @param entityClass
* @param primaryKey
* @return the found entity instance
* @throws IllegalArgumentException if the first argument does
* not denote an entity type or the second argument is
* not a valid type for that entity’s primary key or
* is null
* @throws EntityNotFoundException if the entity state
* cannot be accessed
*/
public <T> T getReference(Class<T> entityClass,
Object primaryKey);

On Sun, Jan 15, 2012 at 8:14 PM, Tomas Pluskal <pluskal@oist.jp> wrote:

> Dear OpenJPA community,
>
> I am developing a desktop Java (Swing, J2SE) application that handles
> large amounts of scientific data (this one: http://mzmine.sourceforge.net/
> ).
> The amount of data can go up to tens of gigabytes, so it is not possible
> to store all the data as Java objects on the heap.
>
> I have no previous experience with JPA/OpenJPA, so I hope to get some
> advice from more experienced users.
>
> I would like to develop an elegant solution to store the Java objects in a
> database and retrieve the data on-demand, ideally with some support for
> caching.
> Searching in the internet I found that OpenJPA combined with Derby might
> provide this kind of functionality, but I am not sure if such solution
> would be efficient.
>
> I played with OpenJPA for a while and I managed to implement a simple
> hello-world type of program that creates an instance of an EntityManager
> and stores an instance of my class by calling
> EntityManager.persist(instance)
> So far it works. Now I am wondering: is there any easy way how to remove
> the object from memory, but keep a reference to it, loading the persisted
> data on-demand using the reference?
>
> I will appreciate your insights!
>
> Tomas
>
> ===============================================
> Tomas Pluskal
> G0 Cell Unit, Okinawa Institute of Science and Technology Graduate
> University
> 1919-1 Tancha, Onna-son, Okinawa 904-0495, Japan
> TEL:  +81-98-966-8684
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message