@SuppressWarnings("unchecked") @Override public boolean readField(OpenJPAStateManager stateManager, QueryResult<ColumnSlice<DynamicComposite, ByteBuffer>> result) { StoreContext context = stateManager.getContext(); // TODO TN use our CollectionProxy here Collection<Object> collection = (Collection<Object>) stateManager .newProxy(fieldId); for (HColumn<DynamicComposite, ByteBuffer> col : result.get().getColumns()) { // the id will always be the first value in a DynamicComposite type, we // only care // about that value. ByteBuffer buff = col.getName().get(0, buffSerializer); Object nativeId = elementKeyStrategy.getInstance(buff); Object saved = context.find(context.newObjectId(targetClass, nativeId), true, null); if(saved == null){ logger.warn("Unable to find object with id '{}'. However it was referenced in the unordered collection with for field '{}' in class '{}'", new Object[]{nativeId, this.fieldName, this.targetClass}); continue; } collection.add(saved); } // now load all the objects from the ids we were given. stateManager.store(fieldId, collection); return result.get().getColumns().size() > 0; }
public Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res) throws SQLException { // process batched results if we haven't already Map rels; if (res instanceof Result) rels = processEagerParallelResult(sm, store, fetch, (Result) res); else rels = (Map) res; // look up the collection for this oid, and store in instance Object coll = rels.remove(sm.getObjectId()); if (field.getTypeCode() == JavaTypes.ARRAY) sm.storeObject(field.getIndex(), JavaTypes.toArray ((Collection) coll, field.getElement().getType())); else { if (coll == null) coll = sm.newProxy(field.getIndex()); sm.storeObject(field.getIndex(), coll); } return rels; }
/** * Set field-level information into the given state manager. */ protected void loadField(OpenJPAStateManager sm, FieldMetaData fmd, FetchConfiguration fetch, Object context) { int index = fmd.getIndex(); Object val = toField(sm, fmd, getData(index), fetch, context); // If val is null, make sure that we don't send back a null Embeddable or ElementCollection...perhaps others? // Probably should think about trying to shove this data back into the cache at this point so we don't // continually run through this code. if (val == null && fmd.isEmbeddedPC()) { val = sm.getContext().embed(null, null, sm, fmd).getManagedInstance(); } else if (val == null && fmd.isElementCollection()) { val = sm.newProxy(index); } sm.storeField(index, val); }
/** * Set field-level information into the given state manager. */ protected void loadField(OpenJPAStateManager sm, FieldMetaData fmd, FetchConfiguration fetch, Object context) { int index = fmd.getIndex(); Object val = toField(sm, fmd, getData(index), fetch, context); // If val is null, make sure that we don't send back a null Embeddable or ElementCollection...perhaps others? // Probably should think about trying to shove this data back into the cache at this point so we don't // continually run through this code. if (val == null && fmd.isEmbeddedPC()) { val = sm.getContext().embed(null, null, sm, fmd).getManagedInstance(); } else if (val == null && fmd.isElementCollection()) { val = sm.newProxy(index); } sm.storeField(index, val); }
public Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res) throws SQLException { // process batched results if we haven't already Map rels; if (res instanceof Result) rels = processEagerParallelResult(sm, store, fetch, (Result) res); else rels = (Map) res; // look up the collection for this oid, and store in instance Object coll = rels.remove(sm.getObjectId()); if (field.getTypeCode() == JavaTypes.ARRAY) sm.storeObject(field.getIndex(), JavaTypes.toArray ((Collection) coll, field.getElement().getType())); else { if (coll == null) coll = sm.newProxy(field.getIndex()); sm.storeObject(field.getIndex(), coll); } return rels; }
public Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res) throws SQLException { // process batched results if we haven't already Map rels; if (res instanceof Result) rels = processEagerParallelResult(sm, store, fetch, (Result) res); else rels = (Map) res; // look up the collection for this oid, and store in instance Object coll = rels.remove(sm.getObjectId()); if (field.getTypeCode() == JavaTypes.ARRAY) sm.storeObject(field.getIndex(), JavaTypes.toArray ((Collection) coll, field.getElement().getType())); else { if (coll == null) coll = sm.newProxy(field.getIndex()); sm.storeObject(field.getIndex(), coll); } return rels; }
public Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res) throws SQLException { // process batched results if we haven't already Map rels; if (res instanceof Result) rels = processEagerParallelResult(sm, store, fetch, (Result) res); else rels = (Map) res; // look up the collection for this oid, and store in instance Object coll = rels.remove(sm.getObjectId()); if (field.getTypeCode() == JavaTypes.ARRAY) sm.storeObject(field.getIndex(), JavaTypes.toArray ((Collection) coll, field.getElement().getType())); else { if (coll == null) coll = sm.newProxy(field.getIndex()); sm.storeObject(field.getIndex(), coll); } return rels; }
public Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch, Object res) throws SQLException { // process batched results if we haven't already Map rels; if (res instanceof Result) rels = processEagerParallelResult(sm, store, fetch, (Result) res); else rels = (Map) res; // look up the collection for this oid, and store in instance Object coll = rels.remove(sm.getObjectId()); if (field.getTypeCode() == JavaTypes.ARRAY) sm.storeObject(field.getIndex(), JavaTypes.toArray ((Collection) coll, field.getElement().getType())); else { if (coll == null) coll = sm.newProxy(field.getIndex()); sm.storeObject(field.getIndex(), coll); } return rels; }
/** * Set field-level information into the given state manager. */ protected void loadField(OpenJPAStateManager sm, FieldMetaData fmd, FetchConfiguration fetch, Object context) { int index = fmd.getIndex(); Object val = toField(sm, fmd, getData(index), fetch, context); // If val is null, make sure that we don't send back a null Embeddable or ElementCollection...perhaps others? // Probably should think about trying to shove this data back into the cache at this point so we don't // continually run through this code. if (val == null && fmd.isEmbeddedPC()) { val = sm.getContext().embed(null, null, sm, fmd).getManagedInstance(); } else if (val == null && fmd.isElementCollection()) { val = sm.newProxy(index); } sm.storeField(index, val); }
/** * Set field-level information into the given state manager. */ protected void loadField(OpenJPAStateManager sm, FieldMetaData fmd, FetchConfiguration fetch, Object context) { int index = fmd.getIndex(); Object val = toField(sm, fmd, getData(index), fetch, context); // If val is null, make sure that we don't send back a null Embeddable or ElementCollection...perhaps others? // Probably should think about trying to shove this data back into the cache at this point so we don't // continually run through this code. if (val == null && fmd.isEmbeddedPC()) { val = sm.getContext().embed(null, null, sm, fmd).getManagedInstance(); } else if (val == null && fmd.isElementCollection()) { val = sm.newProxy(index); } sm.storeField(index, val); }
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (field.isLRS()) { sm.storeObjectField(field.getIndex(), new LRSProxyMap(this)); return; } // select all and load into a normal proxy Joins[] joins = new Joins[2]; Result[] res = getResults(sm, store, fetch, JDBCFetchConfiguration.EAGER_PARALLEL, joins, false); try { Map map = (Map) sm.newProxy(field.getIndex()); Object key, val; while (res[0].next()) { if (res[1] != res[0] && !res[1].next()) break; key = loadKey(sm, store, fetch, res[0], joins[0]); val = loadValue(sm, store, fetch, res[1], joins[1]); map.put(key, val); } sm.storeObject(field.getIndex(), map); } finally { res[0].close(); if (res[1] != res[0]) res[1].close(); } }
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (field.isLRS()) { sm.storeObjectField(field.getIndex(), new LRSProxyMap(this)); return; } // select all and load into a normal proxy Joins[] joins = new Joins[2]; Result[] res = getResults(sm, store, fetch, JDBCFetchConfiguration.EAGER_PARALLEL, joins, false); try { Map map = (Map) sm.newProxy(field.getIndex()); Object key, val; while (res[0].next()) { if (res[1] != res[0] && !res[1].next()) break; key = loadKey(sm, store, fetch, res[0], joins[0]); val = loadValue(sm, store, fetch, res[1], joins[1]); map.put(key, val); } sm.storeObject(field.getIndex(), map); } finally { res[0].close(); if (res[1] != res[0]) res[1].close(); } }
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (field.isLRS()) { sm.storeObjectField(field.getIndex(), new LRSProxyMap(this)); return; } // select all and load into a normal proxy Joins[] joins = new Joins[2]; Result[] res = getResults(sm, store, fetch, JDBCFetchConfiguration.EAGER_PARALLEL, joins, false); try { Map map = (Map) sm.newProxy(field.getIndex()); Object key, val; while (res[0].next()) { if (res[1] != res[0] && !res[1].next()) break; key = loadKey(sm, store, fetch, res[0], joins[0]); val = loadValue(sm, store, fetch, res[1], joins[1]); map.put(key, val); } sm.storeObject(field.getIndex(), map); } finally { res[0].close(); if (res[1] != res[0]) res[1].close(); } }
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (field.isLRS()) { sm.storeObjectField(field.getIndex(), new LRSProxyMap(this)); return; } // select all and load into a normal proxy Joins[] joins = new Joins[2]; Result[] res = getResults(sm, store, fetch, JDBCFetchConfiguration.EAGER_PARALLEL, joins, false); try { Map map = (Map) sm.newProxy(field.getIndex()); Object key, val; while (res[0].next()) { if (res[1] != res[0] && !res[1].next()) break; key = loadKey(sm, store, fetch, res[0], joins[0]); val = loadValue(sm, store, fetch, res[1], joins[1]); map.put(key, val); } sm.storeObject(field.getIndex(), map); } finally { res[0].close(); if (res[1] != res[0]) res[1].close(); } }
coll = new ArrayList(); else coll = sm.newProxy(field.getIndex()); rels.put(oid, coll);
public void load(OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (field.isLRS()) { sm.storeObjectField(field.getIndex(), new LRSProxyMap(this)); return; } // select all and load into a normal proxy Joins[] joins = new Joins[2]; Result[] res = getResults(sm, store, fetch, JDBCFetchConfiguration.EAGER_PARALLEL, joins, false); try { Map map = (Map) sm.newProxy(field.getIndex()); Object key, val; while (res[0].next()) { if (res[1] != res[0] && !res[1].next()) break; key = loadKey(sm, store, fetch, res[0], joins[0]); val = loadValue(sm, store, fetch, res[1], joins[1]); map.put(key, val); } sm.storeObject(field.getIndex(), map); } finally { res[0].close(); if (res[1] != res[0]) res[1].close(); } }
coll = new ArrayList(); else coll = sm.newProxy(field.getIndex()); rels.put(oid, coll);
coll = new ArrayList(); else coll = sm.newProxy(field.getIndex()); rels.put(oid, coll);
coll = new ArrayList(); else coll = sm.newProxy(field.getIndex());
coll = new ArrayList(); else coll = sm.newProxy(field.getIndex());