Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Development/Dynamic/Design PublicAPI

Public API

This page captures the design of the public API - introduced in the new package org.eclipse.persistence.dynamic -
that allows developers to define and use dynamic entities.

Dynpersist.png

public interface DynamicEntity
  • Primary interface of a dynamic persistent entity. This is the API an application uses to interact with an entity.

DynamicEntity is the public interface for dealing with dynamic persistent objects.
The purpose of dynamic persistent objects is to enable (simple) data access when only mapping information is available
and no concrete Java model is present (specifically, no .class files .)

Applications using DynamicEntity's can access the persistent state using property names which correspond to
the mapped attributes in the underlying EclipseLink descriptors. For properties mapped to containers (Collection,Map, etc.),
the property is retrieved then the resulting container can be manipulated.

To discover meta-data about a DynamicEntity's properties, see the DynamicHelper class

Since:
EclipseLink 1.2/2.0
Method Summary
<T> T

get(String propertyPath)
Return the persistence value for the given property as the specified type.
boolean isSet(String propertyPath)
Discover if a property has a persistent value
DynamicEntity set(String propertyPath, Object value)
Set the persistence value for the given property to the specified value


public interface EntityType
  • Provides access to the type information (meta-model) as well as functioning as a factory for new instances

An EntityType provides a metadata facade into the EclipseLink object-relational metadata (descriptors & mappings)
with specific knowledge of the entity types being dynamic.

Since:
EclipseLink 1.2/2.0
Method Summary
boolean containsProperty(String propertyName)
String getClassName()
o.e.p.descriptors.ClassDescriptor getDescriptor()
Class<?> getJavaClass()
String getName()
Return the entity type's name.
int getNumberOfProperties()
The current number of properties.
EntityType getParentType()
java.util.List<String> getPropertiesNames()
The current names of properties.
int getPropertyIndex(String propertyName)
Class<?> getPropertyType(int propertyIndex)
Class<?> getPropertyType(String propertyName)
DynamicEntity newInstance()



public class EntityTypeBuilder
  • Factory for creating dynamic types and bootstrapping using XML

The EntityTypeBuilder is a factory class for creating and extending dynamic entity types. After being constructed in either usage the application can then use the provided API to customize mapping information of the type.

Since:
EclipseLink 1.2
Constructor Summary
EntityTypeBuilder(java.lang.Class<?> dynamicClass, org.eclipse.persistence.dynamic.EntityType parentType, java.lang.String...tableNames)
Create an EntityType for a new dynamic type.
EntityTypeBuilder(org.eclipse.persistence.internal.dynamic.DynamicClassLoader dcl, org.eclipse.persistence.descriptors.ClassDescriptor descriptor, org.eclipse.persistence.dynamic.EntityType parentType)
Create an EntityTypeBuilder for an existing descriptor.
Method Summary
org.eclipse.persistence.mappings.AggregateObjectMapping [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addAggregateObjectMapping(java.lang.String, org.eclipse.persistence.dynamic.EntityType, boolean) addAggregateObjectMapping](java.lang.String name, org.eclipse.persistence.dynamic.EntityType refType, boolean allowsNull)
TODO
org.eclipse.persistence.mappings.DirectCollectionMapping [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addDirectCollectionMapping(java.lang.String, java.lang.String, java.lang.String, java.lang.Class, java.lang.String...) addDirectCollectionMapping](java.lang.String name, java.lang.String targetTable, java.lang.String valueColumn, java.lang.Class<?> valueType, java.lang.String...fkFieldNames)
TODO
org.eclipse.persistence.mappings.DirectToFieldMapping [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addDirectMapping(java.lang.String, java.lang.Class, java.lang.String) addDirectMapping](java.lang.String name, java.lang.Class<?> javaType, java.lang.String fieldName)
Allows DirectToFieldMapping (@Basic) mapping to be added to a dynamic type through API.
void [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addManyToManyMapping(java.lang.String, org.eclipse.persistence.dynamic.EntityType, java.lang.String) addManyToManyMapping](java.lang.String name, org.eclipse.persistence.dynamic.EntityType refType, java.lang.String relationshipTableName)
TODO
org.eclipse.persistence.mappings.OneToManyMapping [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addOneToManyMapping(java.lang.String, org.eclipse.persistence.dynamic.EntityType, java.lang.String...) addOneToManyMapping](java.lang.String name, org.eclipse.persistence.dynamic.EntityType refType, java.lang.String...fkFieldNames)
TODO
org.eclipse.persistence.mappings.OneToOneMapping [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addOneToOneMapping(java.lang.String, org.eclipse.persistence.dynamic.EntityType, java.lang.String...) addOneToOneMapping](java.lang.String name, org.eclipse.persistence.dynamic.EntityType refType, java.lang.String...fkFieldNames)
Allows OneToOneMapping (@OneToOne and @ManyToOne) mappings to be added to a dynamic type through API.
void [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addToSession(org.eclipse.persistence.sessions.DatabaseSession, boolean, boolean) addToSession](org.eclipse.persistence.sessions.DatabaseSession session, boolean createMissingTables, boolean generateFKConstraints)
static void [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#addToSession(org.eclipse.persistence.sessions.DatabaseSession, boolean, boolean, org.eclipse.persistence.dynamic.EntityType...) addToSession](org.eclipse.persistence.sessions.DatabaseSession session, boolean createMissingTables, boolean generateFKConstraints, org.eclipse.persistence.dynamic.EntityType...types)
Add one or more EntityType instances to a session and optionally generate needed tables with or without FK constraints.
void [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#configureSequencing(org.eclipse.persistence.sequencing.Sequence, java.lang.String, java.lang.String) configureSequencing](org.eclipse.persistence.sequencing.Sequence sequence, java.lang.String numberName, java.lang.String numberFieldName)
void [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#configureSequencing(java.lang.String, java.lang.String) configureSequencing](java.lang.String numberName, java.lang.String numberFieldName)
org.eclipse.persistence.dynamic.EntityType [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#getType() getType]()
static org.eclipse.persistence.sessions.Project [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#loadDynamicProject(java.io.InputStream, org.eclipse.persistence.sessions.DatabaseLogin, org.eclipse.persistence.internal.dynamic.DynamicClassLoader) loadDynamicProject](java.io.InputStream resourceStream, org.eclipse.persistence.sessions.DatabaseLogin login, org.eclipse.persistence.internal.dynamic.DynamicClassLoader dynamicClassLoader)
Load a dynamic project from deployment XML creating dynamic types for all descriptors where the provided class name does not exist.
static org.eclipse.persistence.sessions.Project [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#loadDynamicProject(java.lang.String, org.eclipse.persistence.sessions.DatabaseLogin, org.eclipse.persistence.internal.dynamic.DynamicClassLoader) loadDynamicProject](java.lang.String resourcePath, org.eclipse.persistence.sessions.DatabaseLogin login, org.eclipse.persistence.internal.dynamic.DynamicClassLoader dynamicClassLoader)
Load a dynamic project from deployment XML creating dynamic types for all descriptors where the provided class name does not exist.
void [../../../../org/eclipse/persistence/dynamic/EntityTypeBuilder.html#setPrimaryKeyFields(java.lang.String...) setPrimaryKeyFields](java.lang.String... pkFieldNames)
Set the PK field names on the underlying descriptor ensuring no duplicate names are added.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Internal Design

New package org.eclipse.persistence.internal.dynamic

Back to the top