/** * This method is called when an entity shall be removed from the * underlying storage. The persistence manager must call ejbRemove on the * instance and then remove its state from the underlying storage. * * @param ctx the instance to remove * * @throws javax.ejb.RemoveException thrown if the instance could not be removed */ public void removeEntity (EntityEnterpriseContext ctx) throws javax.ejb.RemoveException { if (this.beans.remove (ctx.getId ()) == null) throw new javax.ejb.RemoveException ("Could not remove bean:" + ctx.getId ()); }
public void addRelatedId(EntityEnterpriseContext ctx, Object relatedId) { relationTable.addRelation(JDBCCMRFieldBridge2.this, ctx.getId(), relatedCMRField, relatedId); } }
public void removeRelatedId(EntityEnterpriseContext ctx, Object relatedId) { relationTable.removeRelation(JDBCCMRFieldBridge2.this, ctx.getId(), relatedCMRField, relatedId); }
/** * Marks the instance as scheduled for batch cascade delete (not for cascade delete) * @param ctx instance's context. */ public void scheduleForBatchCascadeDelete(EntityEnterpriseContext ctx) { getEntityState(ctx).scheduleForBatchCascadeDelete(); if(log.isTraceEnabled()) log.trace("Scheduled for batch-cascade-delete: " + ctx.getId()); }
/** * Marks the instance as scheduled for cascade delete (not for batch cascade delete) * @param ctx instance's context. */ public void scheduleForCascadeDelete(EntityEnterpriseContext ctx) { getEntityState(ctx).scheduleForCascadeDelete(); if(log.isTraceEnabled()) log.trace("Scheduled for cascade-delete: " + ctx.getId()); }
public void removeEntity(final EntityEnterpriseContext ctx) throws RemoveException { // Remove file File file = getFile(ctx.getId()); if (!file.delete()) { throw new RemoveException("Could not remove file: " + file); } }
/** * This method is called whenever an entity shall be stored to the * underlying storage. The persistence manager must call ejbStore on the * supplied instance and then store the state to the underlying storage. * * @param ctx the instance to synchronize */ public void storeEntity (EntityEnterpriseContext ctx) { storeEntity (ctx.getId (), ctx.getInstance ()); }
public void destroyExistingRelationships(EntityEnterpriseContext ctx) { Object value = getLoadedValue(ctx); if(value != null) { removeRelatedId(ctx, value); relatedCMRField.invokeRemoveRelatedId(value, ctx.getId()); } }
public boolean add(Object o) { Object relatedId = getPrimaryKey(o); boolean modified = addRelatedId(ctx, relatedId); if(modified) { relatedCMRField.invokeAddRelatedId(relatedId, ctx.getId()); loader.addRelatedId(ctx, relatedId); } return modified; }
private boolean removeById(Object relatedId) { boolean modified = removeRelatedId(ctx, relatedId); if(modified) { relatedCMRField.invokeRemoveRelatedId(relatedId, ctx.getId()); loader.removeRelatedId(ctx, relatedId); } return modified; }
/** * Adds the foreign key to the set of related ids, and updates any foreign key fields. */ public void addRelation(EntityEnterpriseContext myCtx, Object fk) { addRelation(myCtx, fk, true); relationManager.addRelation(this, myCtx.getId(), relatedCMRField, fk); }
public void storeEntity(final EntityEnterpriseContext ctx) { storeEntity(ctx.getId(), ctx.getInstance()); }
/** * Invokes ejbStore method on the instance * @param ctx the instance to invoke ejbStore on * @throws Exception */ public void invokeEjbStore(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); pm.invokeEjbStore(ctx); } }
public String toString() { return getContainer().getBeanMetaData().getEjbName() + '#' + getId(); }
/** * For CMP actually stores the instance */ public void storeEntity(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); if(pm.isStoreRequired(ctx)) { pm.storeEntity(ctx); } } }
public boolean addRelatedId(EntityEnterpriseContext ctx, Object relatedId) { Object value = getLoadedValue(ctx); if(value != null) { relatedCMRField.invokeRemoveRelatedId(value, ctx.getId()); } changeValue(relatedId); loader.addRelatedId(ctx, relatedId); cacheValue(ctx); modified = true; return true; }
public void initInstance(EntityEnterpriseContext ctx) { ctx.setPersistenceContext(new PersistentContext(this, table.getRow(ctx.getId()))); for(int i = 0; i < tableFields.length; ++i) { tableFields[i].initInstance(ctx); } for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].initInstance(ctx); } }
/** * Local home interface implementation */ public EJBLocalObject createLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBLocalObject final EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().createEntity(mi.getMethod(), mi.getArguments(), ctx); // The context implicitely carries the EJBObject createCount++; return localProxyFactory.getEntityEJBLocalObject(ctx.getId(), true); }
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { EntityContainer container = (EntityContainer)instance.getContainer(); if(container.getPersistenceManager().isStoreRequired(instance)) { throw new EJBException("The instance of " + container.getBeanMetaData().getEjbName() + " with pk=" + instance.getId() + " was not stored to prevent potential inconsistency of data in the database:" + " the instance was evicted from the cache during the transaction" + " and the database was possibly updated by another process."); } }
public void destroyRelationLinks(EntityEnterpriseContext myCtx, Object relatedId, boolean updateValueCollection, boolean updateForeignKey) { if(isReadOnly()) { throw new EJBException("Field is read-only: " + getFieldName()); } removeRelation(myCtx, relatedId, updateValueCollection, updateForeignKey); relatedCMRField.invokeRemoveRelation(getTransaction(), relatedId, myCtx.getId()); }