@Override public Object getResultObject() throws Exception { DynamicComposite current = results.get(index); int length = current.getComponents().size(); Object id = keyStrategy.getInstance(current.getComponent(length - 1) .getBytes()); Object jpaId = ctx.newObjectId(classMeta.getDescribedType(), id); return ctx.find(jpaId, fetchConfig, null, null, 0); }
public Object toObjectValue(ValueMapping vm, Object val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (val == null) return null; String str = (String) val; int idx = str.indexOf(':'); if (idx == -1) throw new StoreException(_loc.get("oid-invalid", str, vm)); String clsName = str.substring(0, idx); String oidStr = str.substring(idx + 1); StoreContext ctx = store.getContext(); ClassLoader loader = store.getConfiguration(). getClassResolverInstance().getClassLoader(vm.getType(), ctx.getClassLoader()); Class cls = null; try { cls = Class.forName(clsName, true, loader); } catch (ClassNotFoundException cnfe) { throw new StoreException(cnfe); } Object oid = ctx.newObjectId(cls, oidStr); return store.find(oid, vm, fetch); }
public Object toObjectValue(ValueMapping vm, Object val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (val == null) return null; String str = (String) val; int idx = str.indexOf(':'); if (idx == -1) throw new StoreException(_loc.get("oid-invalid", str, vm)); String clsName = str.substring(0, idx); String oidStr = str.substring(idx + 1); StoreContext ctx = store.getContext(); ClassLoader loader = store.getConfiguration(). getClassResolverInstance().getClassLoader(vm.getType(), ctx.getClassLoader()); Class cls = null; try { cls = Class.forName(clsName, true, loader); } catch (ClassNotFoundException cnfe) { throw new StoreException(cnfe); } Object oid = ctx.newObjectId(cls, oidStr); return store.find(oid, vm, fetch); }
public Object toObjectValue(ValueMapping vm, Object val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (val == null) return null; String str = (String) val; int idx = str.indexOf(':'); if (idx == -1) throw new StoreException(_loc.get("oid-invalid", str, vm)); String clsName = str.substring(0, idx); String oidStr = str.substring(idx + 1); StoreContext ctx = store.getContext(); ClassLoader loader = store.getConfiguration(). getClassResolverInstance().getClassLoader(vm.getType(), ctx.getClassLoader()); Class cls = null; try { cls = Class.forName(clsName, true, loader); } catch (ClassNotFoundException cnfe) { throw new StoreException(cnfe); } Object oid = ctx.newObjectId(cls, oidStr); return store.find(oid, vm, fetch); }
public Object toObjectValue(ValueMapping vm, Object val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (val == null) return null; String str = (String) val; int idx = str.indexOf(':'); if (idx == -1) throw new StoreException(_loc.get("oid-invalid", str, vm)); String clsName = str.substring(0, idx); String oidStr = str.substring(idx + 1); StoreContext ctx = store.getContext(); ClassLoader loader = store.getConfiguration(). getClassResolverInstance().getClassLoader(vm.getType(), ctx.getClassLoader()); Class cls = null; try { cls = Class.forName(clsName, true, loader); } catch (ClassNotFoundException cnfe) { throw new StoreException(cnfe); } Object oid = ctx.newObjectId(cls, oidStr); return store.find(oid, vm, fetch); }
public Object toObjectValue(ValueMapping vm, Object val, OpenJPAStateManager sm, JDBCStore store, JDBCFetchConfiguration fetch) throws SQLException { if (val == null) return null; String str = (String) val; int idx = str.indexOf(':'); if (idx == -1) throw new StoreException(_loc.get("oid-invalid", str, vm)); String clsName = str.substring(0, idx); String oidStr = str.substring(idx + 1); StoreContext ctx = store.getContext(); ClassLoader loader = store.getConfiguration(). getClassResolverInstance().getClassLoader(vm.getType(), ctx.getClassLoader()); Class cls = null; try { cls = Class.forName(clsName, true, loader); } catch (ClassNotFoundException cnfe) { throw new StoreException(cnfe); } Object oid = ctx.newObjectId(cls, oidStr); return store.find(oid, vm, fetch); }
/** * Read the field from the query result into the opject within the state * manager. * * @param stateManager * @param result */ public boolean readField(OpenJPAStateManager stateManager, QueryResult<ColumnSlice<String, ByteBuffer>> result) { HColumn<String, ByteBuffer> column = result.get().getColumnByName(name); if ( log.isDebugEnabled() ) { log.debug("Read column: {}", column); } if (column == null) { stateManager.store(fieldId, null); return false; } ByteBuffer idBuff = column.getValue(); Object id = keyStrategy.getInstance(idBuff); StoreContext context = stateManager.getContext(); Object entityId = context.newObjectId(targetClass, id); Object returned = context.find(entityId, true, null); stateManager.store(fieldId, returned); return true; }
Object oid = context.newObjectId(targetClass, nativeId);
@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; }