@Override public void jsonRead(SpiJsonReader readJson, EntityBean bean) throws IOException { if (jsonDeserialize && targetDescriptor != null) { T assocBean = targetDescriptor.jsonRead(readJson, name); setValue(bean, assocBean); } }
@Override public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException { Object embId = read(ctx); if (embId != null) { embIdProperty.setValue(bean, embId); return embId; } else { return null; } }
@Override Object readSet(DataReader reader, EntityBean bean) throws SQLException { Object dbVal = read(reader); if (bean != null) { property.setValue(bean, dbVal); } return dbVal; }
/** * Read and return the property setting value into the bean. */ Object readSet(DataReader reader, EntityBean bean) throws SQLException { Object val = read(reader); if (bean != null) { property.setValue(bean, val); } return val; }
@Override public void setTenantValue(EntityBean entityBean, Object tenantId) { T refBean = targetDescriptor.createReference(tenantId, null); setValue(entityBean, refBean); }
/** * Set the join properties from the parent bean to the child bean. * This is only valid for OneToMany and NOT valid for ManyToMany. */ public void setJoinValuesToChild(EntityBean parent, EntityBean child, Object mapKeyValue) { if (mapKeyProperty != null) { mapKeyProperty.setValue(child, mapKeyValue); } if (!manyToMany && childMasterProperty != null) { // bidirectional in the sense that the 'master' property // exists on the 'detail' bean childMasterProperty.setValue(child, parent); } }
/** * Read setting values into the bean. */ Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException { Object val = read(ctx); if (bean != null) { property.setValue(bean, val); ctx.propagateState(val); } return val; }
@Override Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException { Object dbVal = read(ctx); if (bean != null) { // set back to the parent bean property.setValue(bean, dbVal); ctx.propagateState(dbVal); return dbVal; } else { return null; } }
@Override public void setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context) { if (cacheData == null) { setValue(bean, null); } else { if (embedded) { setValue(bean, targetDescriptor.cacheEmbeddedBeanLoad((CachedBeanData) cacheData, context)); } else { if (cacheData instanceof String) { cacheData = targetDescriptor.getIdProperty().scalarType.parse((String) cacheData); } // cacheData is the id value, maybe already in persistence context Object assocBean = targetDescriptor.contextGet(context, cacheData); if (assocBean == null) { assocBean = targetDescriptor.createReference(cacheData, context); } setValue(bean, assocBean); } } }
/** * Read the collection (JSON Array) containing entity beans. */ public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException { if (elementDescriptor != null && manyType.isMap()) { return elementDescriptor.jsonReadCollection(readJson, parentBean); } BeanCollection<?> collection = createEmpty(parentBean); BeanCollectionAdd add = getBeanCollectionAdd(collection, null); do { EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name); if (detailBean == null) { // read the entire array break; } add.addEntityBean(detailBean); if (parentBean != null && childMasterProperty != null) { // bind detail bean back to master via mappedBy property childMasterProperty.setValue(detailBean, parentBean); } } while (true); return collection; }
@Override public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException { Object embId = read(ctx); if (embId != null) { embIdProperty.setValue(bean, embId); return embId; } else { return null; } }
@Override Object readSet(DataReader reader, EntityBean bean) throws SQLException { Object dbVal = read(reader); if (bean != null) { property.setValue(bean, dbVal); } return dbVal; }
@Override public void setTenantValue(EntityBean entityBean, Object tenantId) { T refBean = targetDescriptor.createReference(tenantId, null); setValue(entityBean, refBean); }
@Override public void jsonRead(SpiJsonReader readJson, EntityBean bean) throws IOException { if (jsonDeserialize && targetDescriptor != null) { T assocBean = targetDescriptor.jsonRead(readJson, name); setValue(bean, assocBean); } }
/** * Read and return the property setting value into the bean. */ Object readSet(DataReader reader, EntityBean bean) throws SQLException { Object val = read(reader); if (bean != null) { property.setValue(bean, val); } return val; }
/** * Set the join properties from the parent bean to the child bean. * This is only valid for OneToMany and NOT valid for ManyToMany. */ public void setJoinValuesToChild(EntityBean parent, EntityBean child, Object mapKeyValue) { if (mapKeyProperty != null) { mapKeyProperty.setValue(child, mapKeyValue); } if (!manyToMany && childMasterProperty != null) { // bidirectional in the sense that the 'master' property // exists on the 'detail' bean childMasterProperty.setValue(child, parent); } }
/** * Read setting values into the bean. */ Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException { Object val = read(ctx); if (bean != null) { property.setValue(bean, val); ctx.propagateState(val); } return val; }
@Override Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException { Object dbVal = read(ctx); if (bean != null) { // set back to the parent bean property.setValue(bean, dbVal); ctx.propagateState(dbVal); return dbVal; } else { return null; } }
@Override public void setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context) { if (cacheData == null) { setValue(bean, null); } else { if (embedded) { setValue(bean, targetDescriptor.cacheEmbeddedBeanLoad((CachedBeanData) cacheData, context)); } else { if (cacheData instanceof String) { cacheData = targetDescriptor.getIdProperty().scalarType.parse((String) cacheData); } // cacheData is the id value, maybe already in persistence context Object assocBean = targetDescriptor.contextGet(context, cacheData); if (assocBean == null) { assocBean = targetDescriptor.createReference(cacheData, context); } setValue(bean, assocBean); } } }
/** * Read the collection (JSON Array) containing entity beans. */ public Object jsonReadCollection(SpiJsonReader readJson, EntityBean parentBean) throws IOException { if (elementDescriptor != null && manyType.isMap()) { return elementDescriptor.jsonReadCollection(readJson, parentBean); } BeanCollection<?> collection = createEmpty(parentBean); BeanCollectionAdd add = getBeanCollectionAdd(collection, null); do { EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name); if (detailBean == null) { // read the entire array break; } add.addEntityBean(detailBean); if (parentBean != null && childMasterProperty != null) { // bind detail bean back to master via mappedBy property childMasterProperty.setValue(detailBean, parentBean); } } while (true); return collection; }