private Object getPrimaryKey(EJBLocalObject o) { try { return o.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } } }
public GlobalIdentity getGlobalIdentity(Object domainId) throws IdentityTransformException { Object pk = ((EJBLocalObject) domainId).getPrimaryKey(); return next.getGlobalIdentity(pk); }
public void set(Row row, Object value) throws FieldTransformException { try { next.set(row, ((EJBLocalObject)value).getPrimaryKey()); } catch (EJBException e) { throw new FieldTransformException("Unable to fetch primary key for reference", e); } } }
public Object get(Row row) throws FieldTransformException { try { EJBLocalObject proxy = (EJBLocalObject) next.get(row); return proxy.getPrimaryKey(); } catch (EJBException e) { throw new FieldTransformException("Unable to fetch primary key for reference", e); } }
private Object getPrimaryKey(Object o) { if(o == null) { throw new IllegalArgumentException("This implementation does not support null members."); } if(!relatedEntity.getLocalInterface().isInstance(o)) { throw new IllegalArgumentException("Argument must be of type " + entity.getLocalInterface().getName()); } EJBLocalObject local = (EJBLocalObject)o; try { return local.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } }
private Object getRelatedPrimaryKey(Object localObject) { Object relatedId; if(relatedEntity.getLocalInterface().isAssignableFrom(localObject.getClass())) { EJBLocalObject local = (EJBLocalObject) localObject; try { relatedId = local.getPrimaryKey(); } catch(NoSuchObjectLocalException e) { throw new IllegalArgumentException(e.getMessage()); } /* if(relatedManager.wasCascadeDeleted(relatedId)) { throw new IllegalArgumentException("The instance was cascade-deleted: pk=" + relatedId); } */ } else { throw new IllegalArgumentException("The values of this field must be of type " + relatedEntity.getLocalInterface().getName()); } return relatedId; }
/** * Tests if a given EJB is identical to the invoked EJB object. * @param obj - An object to test for identity with the invoked object. * @return True if the given EJB object is identical to the invoked object. * @throws EJBException Thrown when the method failed due to a system-level * failure. */ public boolean isIdentical(EJBLocalObject obj) { if (TraceEjb.isDebugIc()) { TraceEjb.interp.log(BasicLevel.DEBUG, ""); } boolean ret = false; if (obj != null) { // Get the home class name String homeClassName = getEJBLocalHome().getClass().getName(); String objHomeClassName = obj.getEJBLocalHome().getClass().getName(); // Tests the home equality and the primary key equality ret = ((objHomeClassName.equals(homeClassName)) && (obj.getPrimaryKey().equals(getPrimaryKey()))); } return ret; }
/** * Converts EJBLocalObject to persistence-capable instance. * @param o the EJBLocalObject instance to be converted. * @param pm the associated instance of PersistenceManager. * @param validate true if the existence of the instance is to be validated. * @return persistence-capable instance. * @throws IllegalArgumentException if validate is true and instance does * not exist in the database or is deleted. */ public Object convertEJBLocalObjectToPC(EJBLocalObject o, PersistenceManager pm, boolean validate) { Object key = null; try { key = o.getPrimaryKey(); } catch (Exception ex) { EJBException e = new EJBException(I18NHelper.getMessage(messages, "EXC_ConvertEJBObjectToPC", o.getClass().getName()), ex);// NOI18N logger.throwing("JDOEJB20HelperImpl", "convertEJBLocalObjectToPC", e); // NOI18N throw e; } return convertPrimaryKeyToPC(key, pm, validate); }
public void setValue(EntityEnterpriseContext ctx, Object value) { if(value != null) { Object relatedId = getPrimaryKey(value); addRelatedId(ctx, relatedId); relatedCMRField.invokeAddRelatedId(relatedId, ctx.getId()); localObject = (EJBLocalObject)value; } else { destroyExistingRelationships(ctx); } }
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final EntityBeanComponentInstance instance = (EntityBeanComponentInstance) context.getPrivateData(ComponentInstance.class); try { final Object primaryKey = context.getPrivateData(EntityBeanComponent.PRIMARY_KEY_CONTEXT_KEY); final Object other = context.getParameters()[0]; if (!componentView.getViewClass().isAssignableFrom(other.getClass())) { return false; } if (context.getMethod().getParameterTypes()[0].equals(EJBLocalObject.class)) { return ((EJBLocalObject) other).getPrimaryKey().equals(primaryKey); } else { return ((EJBObject) other).getPrimaryKey().equals(primaryKey); } } finally { instance.getComponent().getCache().release(instance, true); } } }
arg = ((EJBLocalObject)arg).getPrimaryKey();
public void cascadeDelete(EntityEnterpriseContext ctx) throws RemoveException { if(manager.registerCascadeDelete(ctx.getId(), ctx.getId())) { EJBLocalObject value = (EJBLocalObject)getValue(ctx); if(value != null) { changeValue(null); final Object relatedId = value.getPrimaryKey(); final JDBCStoreManager2 relatedManager = (JDBCStoreManager2)relatedEntity.getManager(); if(!relatedManager.isCascadeDeleted(relatedId)) { value.remove(); } } manager.unregisterCascadeDelete(ctx.getId()); } }