= Creating and Deleting !MeshObjects = == Creating a MeshObject == To create a MeshObject, a MeshBase must be available. {{{ MeshBase mb = ...; }}} The MeshBase's MeshBaseLifecycleManager offers the creation methods. To obtain it: {{{ MeshBaseLifecycelManager life = mb.getMeshBaseLifecycleManager(); }}} A [wiki:Transaction] is necessary to create, delete or update any MeshObject. To create a MeshObject with an automatically assigned MeshObjectIdentifier: {{{ MeshObjectIdentifier newIdentifier = mb.getMeshObjectIdentifierFactory().fromExternalForm( "my-first-identifier" ); Transaction tx = null; try { tx = mb.createTransactionAsap(); MeshObject newObject = life.createMeshObject(); // creation } finally { if( tx != null ) { tx.commitTransaction(); } } }}} To create a MeshObject with a specified MeshObjectIdentifier, simultaneously blessing it with EntityType `org.infogrid.model.Test/AA`: {{{ Transaction tx = null; try { tx = mb.createTransactionAsap(); MeshObject newObject = life.createMeshObject( newIdentifier, TestSubjectArea.AA ); // creation } finally { if( tx != null ) { tx.commitTransaction(); } } }}} == Deleting a MeshObject == To delete a MeshObject, the MeshObject's MeshBase must be determined. {{{ MeshObject toDelete = ...; MeshBase mb = toDelete.getMeshBase(); }}} The MeshBase's MeshBaseLifecycleManager offers the creation methods. To obtain it: {{{ MeshBaseLifecycelManager life = mb.getMeshBaseLifecycleManager(); }}} A [wiki:Transaction] is necessary to create, delete or update any MeshObject. To delete a MeshObject: {{{ Transaction tx = null; try { tx = mb.createTransactionAsap(); life.deleteMeshObject( toDelete ); // deletion } finally { if( tx != null ) { tx.commitTransaction(); } } }}} Deletion of a MeshObject may have [wiki:Docs/CascadingDelete cascading delete] effects. See also: * [wiki:Docs/CreatingDeletingRelationships Creating and deleting Relationships] * [wiki:Docs/CascadingDelete Cascading delete]