Examples of JavaTypeMapping


Examples of org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping

        super(mapping, storeMgr, col);
    }

    @Override
    public JavaTypeMapping getJavaTypeMapping() {
        final JavaTypeMapping javaTypeMapping = super.getJavaTypeMapping();
        return javaTypeMapping;
    }
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

                return new NullLiteral(qs);
            }
            else
            {
                DatastoreAdapter dba = qs.getStoreManager().getDatastoreAdapter();                 
                JavaTypeMapping m = dba.getMapping(id.getClass(), qs.getStoreManager(), qs.getClassLoaderResolver());
                return new ObjectLiteral(qs,m,id);
            }
        }
        else if (ObjectExpression.class.isAssignableFrom(expr.getClass()))
        {
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

            for (Iterator it=keys.iterator(); it.hasNext();)
            {
                Object current = it.next();
                if (null != current)
                {
                    JavaTypeMapping m = dba.getMapping(current.getClass(), qs.getStoreManager(), qs.getClassLoaderResolver());
                    ScalarExpression expr = m.newLiteral(qs, current);

                    // Append the SQLExpression (should be a literal) for the
                    // current element.
                    st.append(hadPrev ? "," : "");
                    st.append(expr);
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

            Object value = map.get(((Literal)expr).getValue());
            if( value == null )
            {
                return new NullLiteral(qs);
            }
            JavaTypeMapping m = dba.getMapping(value.getClass(), qs.getStoreManager(), qs.getClassLoaderResolver());
            return new ObjectLiteral(qs,m,value);
        }
        //impossible to invoke Map.get with an expression, only with literals
        //using CASE WHEN booleanexpression THEN expression does not work, since expression can only be
        //one single field (column), however, one could have two CASE expressions
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

            int stmtParamNum = 1;

            while (i.hasNext())
            {
                Object name = i.next();
                JavaTypeMapping mapping = (JavaTypeMapping)parameterMappingsByName.get(name);
                Object value = parameterValuesByName.get(name);

                mapping.setObject(om, datastoreStatement, Mappings.getParametersIndex(stmtParamNum,mapping), value);
                if (mapping.getNumberOfDatastoreFields() > 0)
                {
                    stmtParamNum += mapping.getNumberOfDatastoreFields();
                }
                else
                {
                    //if the JavaTypeMapping has no datastoreFields, at least one it may have
                    stmtParamNum += 1;
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

    public QueryExpression newQueryStatement(Class candidateClass, DatastoreIdentifier candidateAlias)
    {
        QueryExpression stmt = ((Queryable)extent).newQueryStatement(candidateClass, candidateAlias);
        ObjectManager om = extent.getObjectManager();
        MappedStoreManager storeMgr = (MappedStoreManager)om.getStoreManager();
        JavaTypeMapping m = storeMgr.getDatastoreClass(candidateClass.getName(),
            om.getClassLoaderResolver()).getIDMapping();

        /*
         * creates a query like WHERE ... AND (CANDIDATE_ID = ?1 OR CANDIDATE_ID =
         * ?2) or for classes with composite primary keys WHERE ... AND (
         * (CANDIDATE_IDa = ?1a AND CANDIDATE_IDb = ?1b) OR (CANDIDATE_IDa = ?2a
         * AND CANDIDATE_IDb = ?2b) )
         */
        BooleanExpression elementsExpr = null;
        for (Iterator it = userCandidates.iterator(); it.hasNext();)
        {
            Object candidateValue = it.next();
            ScalarExpression expr = m.newScalarExpression(stmt, stmt.getMainTableExpression());
            BooleanExpression keyExpr = expr.eq(m.newLiteral(stmt, candidateValue));
            if (elementsExpr == null)
            {
                elementsExpr = keyExpr;
            }
            else
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

            DatastoreAdapter dba = storeMgr.getDatastoreAdapter();
            ClassLoaderResolver clr = qs.getClassLoaderResolver();
            if (value instanceof OID)
            {
                // Object is an OID
                JavaTypeMapping m = dba.getMapping(((OID)value).getKeyValue().getClass(), storeMgr, clr);
                ScalarExpression oidExpr =  m.newLiteral(qs,((OID)value).getKeyValue());
                bExpr = expr.expressionList.getExpression(0).eq(oidExpr);
            }
            else
            {
                ApiAdapter api = qs.getStoreManager().getApiAdapter();
                AbstractClassMetaData cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(value.getClass(), clr);
                if (cmd == null)
                {
                    // if there is no metadata, we either have an SingleFieldIdentity, application identity, or any object
                    if (storeMgr.getApiAdapter().isSingleFieldIdentityClass(value.getClass().getName()))
                    {
                        // Object is SingleFieldIdentity
                        JavaTypeMapping m = dba.getMapping(api.getTargetClassForSingleFieldIdentity(value), storeMgr, clr);
                        ScalarExpression oidExpr =  m.newLiteral(qs, api.getTargetKeyForSingleFieldIdentity(value));
                        bExpr = expr.expressionList.getExpression(0).eq(oidExpr);
                    }
                    else
                    {
                        String pcClassName = storeMgr.getClassNameForObjectID(value, clr, null);
                        if (pcClassName != null)
                        {
                            // Object is an application identity
                            cmd = storeMgr.getOMFContext().getMetaDataManager().getMetaDataForClass(pcClassName, clr);
                            bExpr = eqApplicationIdentity(value, null, expr, null, storeMgr, clr);
                        }
                        else
                        {
                            // Value not PersistenceCapable nor an identity, so return nothing "(1 = 0)"
                            bExpr = new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
                        }
                    }
                }
                else
                {
                    // Value is a PersistenceCapable
                    if (cmd.getIdentityType() == IdentityType.APPLICATION)
                    {
                        // Application identity
                        if (api.getIdForObject(value) != null)
                        {
                            // Persistent PC object (FCO)
                            // Cater for composite PKs and parts of PK being PC mappings, and recursion
                            JavaTypeMapping[] pkMappingsApp = new JavaTypeMapping[expr.expressionList.size()];
                            Object[] pkFieldValues = new Object[expr.expressionList.size()];
                            int position = 0;
                            for (int i=0;i<cmd.getNoOfPrimaryKeyMembers();i++)
                            {
                                AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(cmd.getPKMemberPositions()[i]);
                                Object fieldValue = getFieldValue(mmd, value);
                                JavaTypeMapping mapping = dba.getMapping(fieldValue.getClass(), storeMgr, clr);
                                if (mapping instanceof PersistenceCapableMapping)
                                {
                                    position = populatePrimaryKeyMappingsValuesForPCMapping(pkMappingsApp,
                                        pkFieldValues, position, (PersistenceCapableMapping)mapping,
                                        cmd, mmd, fieldValue, storeMgr, clr);
                                }
                                else
                                {
                                    pkMappingsApp[position] = mapping;
                                    pkFieldValues[position] = fieldValue;
                                    position++;
                                }
                            }

                            for (int i=0; i<expr.expressionList.size(); i++)
                            {
                                ScalarExpression source = expr.expressionList.getExpression(i);
                                ScalarExpression target = pkMappingsApp[i].newLiteral(qs, pkFieldValues[i]);
                                if (bExpr == null)
                                {
                                    bExpr = source.eq(target);
                                }
                                else
                                {
                                    bExpr = bExpr.and(source.eq(target));
                                }
                            }
                        }
                        else
                        {
                            // PC object with no id (embedded, or transient maybe)
                            for (int i=0; i<expr.expressionList.size(); i++)
                            {
                                // Query should return nothing (so just do "(1 = 0)")
                                JPOXLogger.QUERY.warn(LOCALISER.msg("037003", value));
                                bExpr = new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
                                // It is arguable that we should compare the id with null (as below)
                                /*bExpr = expr.eq(new NullLiteral(qs));*/
                            }
                        }
                    }
                    else
                    {
                        // Datastore identity
                        for (int i=0; i<expr.expressionList.size(); i++)
                        {
                            ScalarExpression source = expr.expressionList.getExpression(i);
                            OID objectId = (OID)api.getIdForObject(value);
                            if (objectId == null)
                            {
                                // PC object with no id (embedded, or transient maybe)
                                // Query should return nothing (so just do "(1 = 0)")
                                JPOXLogger.QUERY.warn(LOCALISER.msg("037003", value));
                                bExpr = new BooleanLiteral(qs, mapping, false).eq(new BooleanLiteral(qs, mapping, true));
                                // It is arguable that we should compare the id with null (as below)
                                /*bExpr = expr.eq(new NullLiteral(qs));*/
                            }
                            else
                            {
                                JavaTypeMapping m = dba.getMapping(objectId.getKeyValue().getClass(), storeMgr, clr);
                                ScalarExpression oidExpr = m.newLiteral(qs, objectId.getKeyValue());
                                bExpr = source.eq(oidExpr);
                            }
                        }
                    }
                }
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

        JavaTypeMapping[] subMappings = pcMapping.getJavaTypeMapping();
        if (subMappings.length == 0)
        {
            // Embedded PC has no PK so must be embedded-only so use mapping from owner table
            DatastoreClass table = storeMgr.getDatastoreClass(cmd.getFullClassName(), clr);
            JavaTypeMapping ownerMapping = table.getFieldMapping(mmd);
            EmbeddedMapping embMapping = (EmbeddedMapping)ownerMapping;
            for (int k=0;k<embMapping.getNumberOfJavaTypeMappings();k++)
            {
                JavaTypeMapping subMapping = embMapping.getJavaTypeMapping(k);
                pkMappings[position] = subMapping;
                pkFieldValues[position] = getFieldValue(subMapping.getFieldMetaData(), fieldValue);
                position++;
            }
        }
        else
        {
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

            }
            else
            {
                //if a simple value, we simply apply the equals
                ScalarExpression source = expr.getExpressionList().getExpression(index.index);
                JavaTypeMapping mapping = storeMgr.getDatastoreAdapter().getMapping(value.getClass(), storeMgr, clr);
                ScalarExpression target = mapping.newLiteral(qs, value);
                if( bExpr == null )
                {
                    bExpr = source.eq(target);
                }
                else
View Full Code Here

Examples of org.jpox.store.mapped.mapping.JavaTypeMapping

            if (fieldValue == null)
            {
                return new NullLiteral(this.qs);
            }
            DatastoreAdapter dba = qs.getStoreManager().getDatastoreAdapter();
            JavaTypeMapping mapping;
            if (mappingClass != null && subfieldName == null)
            {
                mapping = dba.getMapping(qs.getClassLoaderResolver().classForName(mappingClass), qs.getStoreManager(),
                    qs.getClassLoaderResolver());
            }
            else
            {
                mapping = dba.getMapping(fieldValue.getClass(), qs.getStoreManager(), qs.getClassLoaderResolver());               
            }
            return mapping.newLiteral(qs,fieldValue);
        }
        catch (SecurityException e)
        {
            throw new JPOXUserException("Cannot access field: "+subfieldName,e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.