Home > Object Persistency API > API Reference > Object Creation and Deletion
Object Creation
To create a new entity you just call the insert method and pass a single entity object or a collection of entities. Entity objects must be previously created with the Java new operator or a jSDL statement.
package org.oomega.persistence; public interface EOContainerSession extends EOResolver, SecurityContext, StreamingContext, TXContext { public <EO extends EntityObject> EO insert(EO eo); public <EO extends EntityObject> Collection<EO> insert(Collection<EO> eos); }
For example you can create a new User entity with the following code snippet assuming you hold a valid reference to an EOContainerSession in the variable eocSession.
User u = eocSession.insert( User() );
To create a new attribute object you simply use the Java new operator or a jSDL statement. To create e.g. an instance of CartesianComplex you have to code:
CartesianComplex cc = CartesianComplex();
Object Deletion
The deletion of an entity is straightforward. Just call delete and pass the respective entity as a parameter. Bulk deletions are also supported by specifying a class identifier (CID) and a predicate.
package org.oomega.persistence; public interface EOContainerSession extends EOResolver, SecurityContext, StreamingContext, TXContext { public void delete(EntityObject eo); public void delete(CId<? extends EntityObject> cid, Predicate predicate); }
The deletion of an attribute object is not necessary as they are garbage collected if not reachable any more. Just use update methods to assign the right attribute objects to entities.
Next chapter: Object Retrieval and Queries