Overview | Package | Class | Tree | Deprecated | Index | Help
| Oracle TopLink API Reference 10g Release 3 (10.1.3) B13698-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.toplink.sessions.entitymanager
Interface EntityManager

All Known Subinterfaces:
  EntityManager

public interface EntityManager

Interface used to interact with the persistence context.

Method Summary
`void` | `close()` Closes this EntityManager.
`boolean` | `contains(java.lang.Object entity)` Check if the instance belongs to the current persistence context.
`Query` | `createNamedQuery(java.lang.String name)` Create an instance of Query for executing a named query (in EJBQL or native SQL).
`Query` | `createNativeQuery(java.lang.String sqlString)` Create an instance of Query for executing a native SQL query.
`Query` | `createNativeQuery(java.lang.String sqlString, java.lang.Class resultClass)` Create an instance of Query for executing a native SQL query.
`Query` | `createNativeQuery(java.lang.String sqlString, java.lang.String resultSetMapping)` Create an instance of Query for executing a native SQL query.
`Query` | `createQuery(java.lang.String ejbqlString)` Create an instance of Query for executing an EJBQL query.
`java.lang.Object` | `find(java.lang.Class entityClass, java.lang.Object primaryKey)` Find by primary key.
`java.lang.Object` | `find(java.lang.String entityName, java.lang.Object primaryKey)` Find by primary key.
`void` | `flush()` Synchronize the persistence context with the underlying database.
`EntityTransaction` | `getUserTransaction()` Looks up the current user transaction.
`boolean` | `isOpen()` Indicates whether or not this entity manager is open.
`java.lang.Object` | `merge(java.lang.Object entity)` Merge the state of the given entity into the current persistence context, using the unqualified class name as the entity name.
`void` | `persist(java.lang.Object entity)` Make an instance managed, using the unqualified class name as the entity name.
`void` | `refresh(java.lang.Object entity)` Refresh the state of the instance from the database.
`void` | `remove(java.lang.Object entity)` Remove the instance.

Method Detail

### persist

    public void persist(java.lang.Object entity)

  Make an instance managed, using the unqualified class name as the entity name.
  Parameters:
    `entity` -

### merge

    public java.lang.Object merge(java.lang.Object entity)

  Merge the state of the given entity into the current persistence context, using the unqualified class name as the entity name.
  Parameters:
    `entity` -
  Returns:
    the instance that the state was merged to jdk14

### remove

    public void remove(java.lang.Object entity)

  Remove the instance.
  Parameters:
    `entity` -

### refresh

    public void refresh(java.lang.Object entity)

  Refresh the state of the instance from the database.
  Parameters:
    `entity` -
  Throws:
    `java.lang.IllegalArgumentException` - if not an entity or entity is not in managed state
    `TransactionRequiredException` - if there is no transaction

### find

    public java.lang.Object find(java.lang.String entityName,
                                 java.lang.Object primaryKey)

  Find by primary key.
  Parameters:
    `entityName` -
    `primaryKey` -
  Returns:
    the found entity instance

### find

    public java.lang.Object find(java.lang.Class entityClass,
                                 java.lang.Object primaryKey)

  Find by primary key.
  Parameters:
    `entityClass` -
    `primaryKey` -
  Returns:
    the found entity instance jdk14

### flush

    public void flush()

  Synchronize the persistence context with the underlying database.

### createQuery

    public Query createQuery(java.lang.String ejbqlString)

  Create an instance of Query for executing an EJBQL query.
  Parameters:
    `ejbqlString` - an EJBQL query string
  Returns:
    the new query instance

### createNamedQuery

    public Query createNamedQuery(java.lang.String name)

  Create an instance of Query for executing a named query (in EJBQL or native SQL).
  Parameters:
    `name` - the name of a query defined in metadata
  Returns:
    the new query instance

### createNativeQuery

    public Query createNativeQuery(java.lang.String sqlString)

  Create an instance of Query for executing a native SQL query. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.
  Parameters:
    `sqlString` - a native SQL query string
  Returns:
    the new query instance

### createNativeQuery

    public Query createNativeQuery(java.lang.String sqlString,
                                   java.lang.Class resultClass)

  Create an instance of Query for executing a native SQL query.
  Parameters:
    `sqlString` - a native SQL query string
    `resultClass` - the class of the resulting instances
  Returns:
    the new query instance
  Throws:
    `java.lang.IllegalArgumentException` - if query string is not valid

### createNativeQuery

    public Query createNativeQuery(java.lang.String sqlString,
                                   java.lang.String resultSetMapping)

  Create an instance of Query for executing a native SQL query. Warning: Allowing an unverified SQL string to be passed into this method makes your application vulnerable to SQL injection attacks.
  Parameters:
    `sqlString` - a native SQL query string
    `resultSetMapping` - the name of the result set mapping
  Returns:
    the new query instance
  Throws:
    `java.lang.IllegalArgumentException` - if query string is not valid

### contains

    public boolean contains(java.lang.Object entity)

  Check if the instance belongs to the current persistence context.
  Parameters:
    `entity` -
  Returns:

### close

    public void close()

  Closes this EntityManager. This can only be called when the transaction that this EntityManager is associated with has a status of `Status#STATUS_NO_TRANSACTION`, `Status#Status_COMMITTED` or `Status#STATUS_ROLLEDBACK`. It will throw an `IllegalStateException` if invoked when this condition is not true.

  After invoking this method, all methods on the instance will throw an `IllegalStateException` except for `isOpen()`, which will return `false` .

  This should be called when a method is finished with the EntityManager in a bean-managed transaction environment or when executed outside a container. Closing of the EntityManager is handled by the container when using container-managed transactions.

### isOpen

    public boolean isOpen()

  Indicates whether or not this entity manager is open. Returns `true` until a call to `close()` is made.

### getUserTransaction

    public EntityTransaction getUserTransaction()

  Looks up the current user transaction. This may cause an exception to be raised if a UserTransaction is not accessible. If outside a managed environment, JTA semantics are emulated.

  This always returns a UserTransaction when outside a container and equates to a simple JNDI lookup on the UserTransaction when inside the Container. The returned UserTransaction may or may not be a proxy around the actual object.

  Inside a container, the EM will use the TransactionManager as a means to synchronize, but outside the Container the EM is tightly coupled with (essentially it implements) the TransactionManager.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 1998, 2006, Oracle. All Rights Reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD