My favorites | Sign in
Project Home
Search
for
EntityManager  
Updated Jun 10, 2010 by devdavek@gmail.com

The Entity Manager

The EntityManager is the central access point for ORM functionality provided by Flextrine. It is used to manage the persistence of your object and to query for objects from the database. This class is a singleton which means that there is only ever one instance of the EntityManager in existence. To get a reference to this instance use the following code:

var em:EntityManager = EntityManager.getInstance();

Configuring the Entity Manager

To configure the EntityManager to point to your Flextrine server-side component set the configuration using the following code. Since EntityManager is a singleton you only need to do this once in your Flex application.

var configuration:Configuration = new Configuration();
configuration.gateway = "http://localhost/myflextrineproject/gateway.php";
em.setConfiguration(configuration);

Working with entities

The following methods are commonly used to manage your entities through the EntityManager.

em.persist(entity:Object)

The persist method marks the given entity for insertion into the database on the next flush. If an entity is removed with remove before the next flush occurs no action will be taken.

em.remove(entity:Object)

The remove method marks the given entity for deletion from the database on the next flush.

em.flush()

The flush method executes all queued operations against the server. This includes all persists, removes and any updates made to managed entities.


Sign in to add a comment
Powered by Google Project Hosting