Package org.apache.isis.objectstore.sql

Examples of org.apache.isis.objectstore.sql.Results


            sql.append(" from ");
            sql.append(table);
            sql.append(" where ");
            idMapping.appendUpdateValues(connector, sql, parentAdapter);
           
            final Results rs = connector.select(sql.toString());
            final List<ObjectAdapter> list = new ArrayList<ObjectAdapter>();
            while (rs.next()) {
                final Oid oid = idMapping.recreateOid(rs, specification);
                final ObjectAdapter element = getAdapter(specification, oid);
                loadFields(element, rs);
                if(LOG.isDebugEnabled()) {
                    LOG.debug("  element  " + element.getOid());
                }
                list.add(element);
            }
            final CollectionFacet collectionFacet = collectionAdapter.getSpecification().getFacet(CollectionFacet.class);
            collectionFacet.init(collectionAdapter, list.toArray(new ObjectAdapter[list.size()]));
            rs.close();
        } finally {
            PersistorUtil.toEndState(collectionAdapter);
        }

    }
View Full Code Here


            sql.append(", ");
            elementMapping.appendColumnNames(sql);
            sql.append(" from ");
            sql.append(tableName);

            final Results rs = connector.select(sql.toString());
            final List<ObjectAdapter> list = new ArrayList<ObjectAdapter>();
            while (rs.next()) {
                final ObjectAdapter element = ((JdbcObjectReferenceMapping) elementMapping).initializeField(rs);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("  element  " + element.getOid());
                }
                list.add(element);
            }
            final CollectionFacet collectionFacet =
                collectionAdapter.getSpecification().getFacet(CollectionFacet.class);
            collectionFacet.init(collectionAdapter, list.toArray(new ObjectAdapter[list.size()]));
            rs.close();
        } finally {
            PersistorUtil.toEndState(collectionAdapter);
        }
    }
View Full Code Here

    @Override
    public ObjectAdapter getObject(final DatabaseConnector connector, final TypedOid typedOid) {
        final StringBuffer sql = createSelectStatement();
        sql.append(" WHERE ");
        idMapping.appendWhereClause(connector, sql, (RootOid) typedOid);
        final Results rs = connector.select(completeSelectStatement(sql, 0, 0));
        final ObjectSpecification objectSpec = getSpecificationLoader().lookupBySpecId(typedOid.getObjectSpecId());
        if (rs.next()) {
            return loadMappedObject(connector, objectSpec, rs);
        } else {
            throw new ObjectNotFoundException("No object with with " + typedOid + " in table " + table);
        }
    }
View Full Code Here

    private void loadInstancesToVector(final DatabaseConnector connector, final ObjectSpecification cls, final String selectStatment, final Vector<ObjectAdapter> instances) {
        LOG.debug("loading instances from SQL " + table);

        try {
            final Results rs = connector.select(selectStatment);
            final int maxInstances = Defaults.getMaxInstances();
            for (int count = 0; rs.next() && count < maxInstances; count++) {
                final ObjectAdapter instance = loadMappedObject(connector, cls, rs);
                LOG.debug("  instance  " + instance);
                instances.addElement(instance);
            }
            rs.close();
        } catch (final SqlObjectStoreException e) {
            // Invalid SELECT means no object found.. don't worry about it,
            // here.
        }
    }
View Full Code Here

        sql.append(versionMapping.appendColumnNames());
        sql.append(" from " + table + " WHERE ");
        final RootOid oid = (RootOid) object.getOid();
        idMapping.appendWhereClause(connector, sql, oid);

        final Results rs = connector.select(sql.toString());
        if (rs.next()) {
            loadFields(object, rs);
            rs.close();

            for (final CollectionMapper collectionMapper : collectionMappers) {
                collectionMapper.loadInternalCollection(connector, object);
            }
        } else {
            rs.close();
            throw new SqlObjectStoreException("Unable to load data from " + table + " with id " + object.getOid().enString(getOidMarshaller()));
        }
    }
View Full Code Here

        sql.append(" from ");
        sql.append(table);
        sql.append(" where ");
        appendCollectionWhereValues(connector, parent, sql);

        final Results rs = connector.select(sql.toString());

        final SpecificationLoaderSpi reflector = IsisContext.getSpecificationLoader();
        final JdbcPolymorphicObjectReferenceMapping idMapping =
            (JdbcPolymorphicObjectReferenceMapping) idMappingAbstract;

        while (rs.next()) {
            final ObjectSpecification itemSpecification = reflector.loadSpecification(rs.getString(classColumnName));
            idMapping.setObjectSpecification(itemSpecification);

            // Load new recordSet for the actual class
            final ObjectMapping itemMapper = objectMappingLookup.getMapping(itemSpecification, connector);
            final TypedOid oid = idMapping.recreateOid(rs, itemSpecification);
            final ObjectAdapter loadedObject = itemMapper.getObject(connector, oid);

            LOG.debug("  element  " + loadedObject.getOid());

            list.add(loadedObject);
        }
        rs.close();

    }
View Full Code Here

        sql.append(" from ");
        sql.append(table);
        sql.append(" where ");
        appendCollectionWhereValues(connector, parent, sql);

        final Results rs = connector.select(sql.toString());
        while (rs.next()) {
            final Oid oid = idMappingAbstract.recreateOid(rs, specification);
            final ObjectAdapter element = getAdapter(specification, oid);
            loadFields(element, rs, fieldMappingByField);
            LOG.debug("  element  " + element.getOid());
            list.add(element);
        }
        rs.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.objectstore.sql.Results

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.