Oracle® Data Integrator Java API Reference
11g Release 1 (11.1.1.3.0)

E17060-01

oracle.odi.core.persistence
Interface IOdiEntityManager


public interface IOdiEntityManager

Interface used to interact with the persistence context of an instance of ODI.

An IOdiEntityManager instance is associated with an instance of ODI's persistence context. That persistence context is made of IOdiEntitys Irrespectively of the ODI repository that effectively contains the IOdiEntity instances (Master repository, Work development repository or Work runtime repository). The persistence context manage the entities and their life cycle. The IOdiEntityManager interface provides the methods to interact with the persistence context in order to make CRUD (Create, Read, Update, Delete) operations against IOdiEntity instances.

IOdiEntity have four fields IOdiEntity.getFirstDate(), IOdiEntity.getFirstUser(), IOdiEntity.getLastDate(), IOdiEntity.getLastUser() that are updated when inserting of updating the objects in the underlying database. These IOdiEntity's fields will be refreshed after a flush() or at commit time, only if a persist() or a merge() has been called and some real changes have taken place in database.

Since:
11.1.1.3.0

Method Summary
 void close()
          Close this application-managed IOdiEntityManager.
 java.util.Collection findAll(java.lang.Class pRequiredType)
          Find all the entity instances of the given class from the ODI instance that manager belongs to.
 IOdiEntity findById(java.lang.Class pRequiredType, java.io.Serializable pId)
          Find the entity instance of the given class and with the given identifier / primary key from the ODI instance that manager belongs to.
 void flush()
          Synchronize the persistence context to the underlying repository database.
 IFinder getFinder(java.lang.Class pEntityType)
          Obtains the IFinder instance for the given entity type.
 void initialize(IOdiEntity pEntity, IInitializationCriteria pInitializationCriteria)
          WARNING : This method is experimental and may be removed in future drop.
 boolean isOpen()
          Returns whether this IOdiEntityManager is open, or not.
 IOdiEntity merge(IOdiEntity pEntity)
          Merge the states of the given entity into the current persistent context.
 void persist(IOdiEntity pEntity)
          Make the given entity instance managed and persistent.
 void refresh(IOdiEntity pEntity)
          Refresh the given entity with the persistente context.
 void remove(IOdiEntity pEntity)
          Remove the given entity from the persistent context.
 void removeAll(java.util.Collection pEntities)
          Remove all the given entities from the persistent context.
 void setDefaultContext(java.lang.String pContextCode)
          Sets the OdiContext with code equals to pContextCode as default.
 

Method Detail

close

void close()
Close this application-managed IOdiEntityManager.

Throws:
java.lang.IllegalStateException - if this IOdiEntityManager is already closed

findAll

java.util.Collection findAll(java.lang.Class pRequiredType)
Find all the entity instances of the given class from the ODI instance that manager belongs to.

Parameters:
pRequiredType - the entity class
Returns:
a collection of entity instances
Throws:
java.lang.IllegalArgumentException - if the given class doesn't derive from IOdiEntity
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.DataAccessException - if a data access error occurs

findById

IOdiEntity findById(java.lang.Class pRequiredType,
                    java.io.Serializable pId)
Find the entity instance of the given class and with the given identifier / primary key from the ODI instance that manager belongs to.

Parameters:
pRequiredType - the entity class
pId - the entity identifier
Returns:
the entity instance or null if not found
Throws:
java.lang.IllegalArgumentException - if the given class doesn't derive from IOdiEntity
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.DataAccessException - if a data access error occurs

flush

void flush()
Synchronize the persistence context to the underlying repository database.

That method need to be called within an active transaction.

Throws:
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.InvalidDataAccessApiUsageException - if the method is called outside an active transaction
org.springframework.dao.DataAccessException - if the flush failed

getFinder

IFinder getFinder(java.lang.Class pEntityType)
Obtains the IFinder instance for the given entity type.

The returned finder should be cast into the specific finder interface according the given entity type in order to access specific finder methods.

The finder interface is the convenient way to query entities for the 11g release.

Parameters:
pEntityType - the entity type the finder has to provide support for
Returns:
the finder supporting the given entity type
Throws:
java.lang.IllegalArgumentException - if the given type is not assignable from IOdiEntity class
java.lang.IllegalArgumentException - if the given entity type is null
java.lang.IllegalArgumentException - if no finder found for the given type
java.lang.IllegalStateException - if this IOdiEntityManager has been closed

initialize

void initialize(IOdiEntity pEntity,
                IInitializationCriteria pInitializationCriteria)
WARNING : This method is experimental and may be removed in future drop.

Initialize pEntity using the specified IInitializationCriteria. Be aware that this method may be very eager depending on the specified pInitializationCriteria.

Parameters:
pEntity - an entity
pInitializationCriteria - an init criteria
Throws:
java.lang.IllegalArgumentException - if the given entity is null
java.lang.IllegalArgumentException - if the given initialization criteria is null
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.DataAccessException - if a data access error occurs

isOpen

boolean isOpen()
Returns whether this IOdiEntityManager is open, or not.

Returns:
true if this IOdiEntityManager is open, false otherwise

merge

IOdiEntity merge(IOdiEntity pEntity)
Merge the states of the given entity into the current persistent context.

This is the convenient method to to re-attach a detached instance to the persistent context. Can also be used to update an entity that has been loaded from another transaction. Calling that method will also cascade merge related entities according to the cascading policy.

The returned entity must be used in place of the merged entity after this method was called.

Parameters:
pEntity - the updated entity to merge
Returns:
the updated persistent instance that the state was merged to
Throws:
java.lang.IllegalArgumentException - if the given entity is null or cannot be merged
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.DataAccessException - if a data access error occurs

persist

void persist(IOdiEntity pEntity)
Make the given entity instance managed and persistent. Calling that method will also cascade persistence to related entities according to the cascading policy defined for the given entity.

This is the convenient method to store a newly created entity. All newly created entities must be persisted, by calling persist(IOdiEntity) on entities themseleves, or on any parent root entity according cascading policy, in order to be inserted at commit time.

After invoking that method, all persisted entities have got there identifier set.

Parameters:
pEntity - the entity to persist
Throws:
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
java.lang.IllegalArgumentException - if the given entity is null
org.springframework.dao.DataAccessException - if a data access error occurs

refresh

void refresh(IOdiEntity pEntity)
Refresh the given entity with the persistente context. Calling that method will also cascade refresh to related entities according to the cascading policy.

Parameters:
pEntity - the entity object to refresh
Throws:
java.lang.IllegalArgumentException - if the given entity is null
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.DataAccessException - if a data access error occurs

remove

void remove(IOdiEntity pEntity)
Remove the given entity from the persistent context.

This is the convenient method to delete an entity. Calling that method will also cascade remove related entities according to the cascading policy.

Parameters:
pEntity - the entity to remove
Throws:
java.lang.IllegalArgumentException - if the given entity is null or cannot be removed
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.DataAccessException - if a data access error occurs

removeAll

void removeAll(java.util.Collection pEntities)
Remove all the given entities from the persistent context.

Calling that method will also cascade remove to related entities according to the cascading policy.

Parameters:
pEntities - the collection of entities to be removed
Throws:
java.lang.IllegalArgumentException - if the given collection is null or contains entity that cannot be removed
java.lang.IllegalStateException - if this IOdiEntityManager has been closed
org.springframework.dao.DataAccessException - if a data access error occurs
See Also:
remove(IOdiEntity)

setDefaultContext

void setDefaultContext(java.lang.String pContextCode)
Sets the OdiContext with code equals to pContextCode as default.

Parameters:
pContextCode - - the code of existing OdiContext which has to be set as default

Oracle® Data Integrator Java API Reference
11g Release 1 (11.1.1.3.0)

E17060-01

Copyright © 2010, Oracle and/or its affiliates. All rights reserved.