Difference between revisions of "EclipseLink/Examples/Foundation/DynamicPersistence"
|Line 12:||Line 12:|
Revision as of 15:00, 16 December 2009
Simple Example using EclipseLink Dynamic Persistence
Dynamic Persistence is defined as the ability to create a dynamic persistent entity and use it within an application without a-priori the entity's Java .class being present on the classpath (or in some .jar/.war archive).
The purpose of Dynamic Persistence is to enable simplified data access where only mapping information is required and no concrete Java model is required. This allows applications with dynamic storage requirements to avoid coupling to static classes or require specialized handling of new types. The application uses standard EclipseLink APIs to read, create, modify, and remove dynamic persistent entities from their data stores based on types that are either defined in XML mapping files or are constructed within the running application.
The classes from the new package org.eclipse.persistence.dynamic are used to construct a simple persistence example: DynamicClassLoader, DynamicHelper, and DynamicTypeBuilder:
//build a shared session (a.k.a. <tt>ServerSession</tt>) ... DynamicHelper helper = new DynamicHelper(getSharedSession()); DynamicClassLoader dcl = helper.getDynamicClassLoader(); Class<?> javaType = dcl.createDynamicClass("model.Simple");