Errai 3.0.1-SNAPSHOT

org.jboss.errai.jpa.client.local
Class PersistenceContext

java.lang.Object
  extended by org.jboss.errai.jpa.client.local.PersistenceContext

public class PersistenceContext
extends Object

A container for all the live, in-memory objects in a particular entity manager.

Author:
Jonathan Fuerth

Constructor Summary
PersistenceContext(ErraiMetamodel mm)
          Creates a new PersistenceContext that can track entities represented within the given metamodel.
 
Method Summary
 boolean contains(Key<?,?> key)
          Returns true if this persistence context contains an entity retrievable by the given key.
 Set<Map.Entry<Key<?,?>,Object>> entrySet()
          Returns the set of all entities in this persistence context.
<X> X
get(Key<X,?> key)
          Looks up and returns the entity that matches the given key.
<X,Y> void
put(Key<X,Y> key, X object)
          Stores the given object in the persistence context.
 void remove(Key<?,?> key)
          Removes the entity having the given key from this persistence context.
 Collection<Object> values()
          Returns the collection of all entities in this persistence context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceContext

public PersistenceContext(ErraiMetamodel mm)
Creates a new PersistenceContext that can track entities represented within the given metamodel.

Parameters:
mm - The metamodel that knows about all the entity types that will be stored in this Persistence Context. Not null.
Method Detail

put

public <X,Y> void put(Key<X,Y> key,
                      X object)
Stores the given object in the persistence context. Discovers its correct runtime class and builds the correct Key instance for it.

Parameters:
key - The key to store the entity under. Care must be taken that this key type reflects the actual runtime type of the given object.
object - The object to put into the persistence context.

remove

public void remove(Key<?,?> key)
Removes the entity having the given key from this persistence context.

Parameters:
key - The key of the entity to remove. The key type must be an exact match for the target object's runtime type.

get

public <X> X get(Key<X,?> key)
Looks up and returns the entity that matches the given key. The key's type need not be an exact match; any supertype of the requested entity will suffice.

Parameters:
key - the key to look up. The entity type portion can be any supertype of the matched entity. The ID is always an exact match. Must not be null.
Returns:
The entity that matches the ID and has the same type or a subtype of the type specified in the key.

contains

public boolean contains(Key<?,?> key)
Returns true if this persistence context contains an entity retrievable by the given key. The type matching is done in the same way as described in get(Key).

Parameters:
key - the identity of the entity to look for. Must not be null.
Returns:
True if and only if this persistence context contains an entity retrievable by the given key.

entrySet

public Set<Map.Entry<Key<?,?>,Object>> entrySet()
Returns the set of all entities in this persistence context. The type portion of the keys reflect the actual runtime type of the entity.


values

public Collection<Object> values()
Returns the collection of all entities in this persistence context.


Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.