Package com.alibaba.druid.mapping

Examples of com.alibaba.druid.mapping.Property


        SQLIdentifierExpr ownerExpr = (SQLIdentifierExpr) x.getOwner();
        String ownerName = ownerExpr.getName();

        String propertyName = x.getName();

        Property property = null;
        Entity entity = visitor.getEntity(ownerName);

        if (entity == null) {
            visitor.getUnresolveList().add(x);
            return false;
        }
        property = entity.getProperty(propertyName);

        if (property == null) {
            throw new DruidMappingException("property not found : " + propertyName);
        }

        String dbColumName = visitor.resovleColumnName(entity, property);
        x.setName(dbColumName);
        x.putAttribute(MAPPING_PROPERTY, property);
        x.putAttribute(MAPPING_ENTITY, entity);

        if (x.getParent() instanceof SQLSelectItem) {
            SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
            if (visitor.getContext().isGenerateAlias() && selectItem.getAlias() == null) {
                selectItem.setAlias('"' + property.getName() + '"');
            }
        }

        return false;
    }
View Full Code Here


    }

    public static boolean visit(MappingVisitor visitor, SQLIdentifierExpr x) {
        String propertyName = x.getName();

        Property property = null;
        Entity propertyEntity = null;

        for (SQLTableSource tableSource : visitor.getTableSources().values()) {
            Entity entity = (Entity) tableSource.getAttribute(MAPPING_ENTITY);
            if (entity != null) {
                property = entity.getProperty(propertyName);
                if (property != null) {
                    propertyEntity = entity;
                    break;
                }
            }
        }

        if (property == null) {
            visitor.getUnresolveList().add(x);
            return false;
        }

        String dbColumName = visitor.resovleColumnName(propertyEntity, property);
        x.setName(dbColumName);

        x.putAttribute(MAPPING_PROPERTY, property);
        x.putAttribute(MAPPING_ENTITY, propertyEntity);

        if (visitor.getContext().isGenerateAlias() && x.getParent() instanceof SQLSelectItem) {
            SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
            if (visitor.getContext().isGenerateAlias() && selectItem.getAlias() == null) {
                selectItem.setAlias('"' + property.getName() + '"');
            }
        }

        return false;
    }
View Full Code Here

            if (x.getLeft() instanceof SQLIdentifierExpr && isSimpleValue(visitor, x.getRight())) {
                visit(visitor, (SQLIdentifierExpr) x.getLeft());
                x.getRight().accept(visitor);

                Entity entity = (Entity) x.getLeft().getAttribute(MAPPING_ENTITY);
                Property property = (Property) x.getLeft().getAttribute(MAPPING_PROPERTY);
                Object value = x.getRight().getAttribute(MAPPING_VALUE);

                PropertyValue propertyValue = new PropertyValue(entity, property, value);
                propertyValue.putAttribute("mapping.expr", x.getRight());
               
                visitor.getPropertyValues().add(propertyValue);

                return false;
            }

            if (x.getLeft() instanceof SQLPropertyExpr && isSimpleValue(visitor, x.getRight())) {
                visit(visitor, (SQLPropertyExpr) x.getLeft());
                x.getRight().accept(visitor);

                Entity entity = (Entity) x.getLeft().getAttribute(MAPPING_ENTITY);
                Property property = (Property) x.getLeft().getAttribute(MAPPING_PROPERTY);
                Object value = x.getRight().getAttribute(MAPPING_VALUE);

                PropertyValue propertyValue = new PropertyValue(entity, property, value);
                propertyValue.putAttribute("mapping.expr", x.getRight());
               
View Full Code Here

        String propertyName = x.getName();

        for (SQLTableSource tableSource : visitor.getTableSources().values()) {
            Entity entity = (Entity) tableSource.getAttribute(MAPPING_ENTITY);
            if (entity != null) {
                Property property = entity.getProperty(propertyName);
                if (property != null) {
                    String columnName = visitor.resovleColumnName(entity, property);
                    x.setName(columnName);

                    x.putAttribute(MAPPING_ENTITY, entity);
                    x.putAttribute(MAPPING_PROPERTY, property);

                    if (visitor.getContext().isGenerateAlias() && x.getParent() instanceof SQLSelectItem) {
                        SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
                        if (selectItem.getAlias() == null) {
                            selectItem.setAlias('"' + property.getName() + '"');
                        }
                    }

                    return true;
                }
View Full Code Here

            String ownerName = ((SQLIdentifierExpr) x.getOwner()).getName();
            SQLTableSource tableSource = visitor.getTableSources().get(ownerName);
            Entity entity = (Entity) tableSource.getAttribute(MAPPING_ENTITY);

            if (entity != null) {
                Property property = entity.getProperty(x.getName());
                if (property != null) {
                    String columnName = visitor.resovleColumnName(entity, property);
                    x.setName(columnName);
                    x.putAttribute(MAPPING_ENTITY, entity);
                    x.putAttribute(MAPPING_PROPERTY, property);

                    if (visitor.getContext().isGenerateAlias() && x.getParent() instanceof SQLSelectItem) {
                        SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
                        if (selectItem.getAlias() == null) {
                            selectItem.setAlias('"' + property.getName() + '"');
                        }
                    }

                    return true;
                }
View Full Code Here

    }

    public static boolean visit(MappingVisitor visitor, SQLIdentifierExpr x) {
        String propertyName = x.getName();

        Property property = null;
        for (Entity entity : visitor.getEntities().values()) {
            property = entity.getProperty(propertyName);
            if (property != null) {
                break;
            }
        }

        if (property == null) {
            throw new DruidMappingException("property not found : " + propertyName);
        }

        String dbColumName = property.getDbColumnName();
        x.setName(dbColumName);

        if (x.getParent() instanceof SQLSelectItem) {
            SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
            if (selectItem.getAlias() == null) {
                selectItem.setAlias('"' + property.getName() + '"');
            }
        }

        return false;
    }
View Full Code Here

        SQLIdentifierExpr ownerExpr = (SQLIdentifierExpr) x.getOwner();
        String ownerName = ownerExpr.getName();

        String propertyName = x.getName();

        Property property = null;
        Entity entity = visitor.getEntity(ownerName);

        if (entity == null) {
            visitor.getUnresolveList().add(x);
            return false;
        }
        property = entity.getProperty(propertyName);

        if (property == null) {
            throw new DruidMappingException("property not found : " + propertyName);
        }

        String dbColumName = visitor.resovleColumnName(entity, property);
        x.setName(dbColumName);
        x.putAttribute(MAPPING_PROPERTY, property);
        x.putAttribute(MAPPING_ENTITY, entity);

        if (x.getParent() instanceof SQLSelectItem) {
            SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
            if (visitor.getContext().isGenerateAlias() && selectItem.getAlias() == null) {
                selectItem.setAlias('"' + property.getName() + '"');
            }
        }

        return false;
    }
View Full Code Here

    }

    public static boolean visit(MappingVisitor visitor, SQLIdentifierExpr x) {
        String propertyName = x.getName();

        Property property = null;
        Entity propertyEntity = null;

        for (SQLTableSource tableSource : visitor.getTableSources().values()) {
            Entity entity = (Entity) tableSource.getAttribute(MAPPING_ENTITY);
            if (entity != null) {
                property = entity.getProperty(propertyName);
                if (property != null) {
                    propertyEntity = entity;
                    break;
                }
            }
        }

        if (property == null) {
            visitor.getUnresolveList().add(x);
            return false;
        }

        String dbColumName = visitor.resovleColumnName(propertyEntity, property);
        x.setName(dbColumName);

        x.putAttribute(MAPPING_PROPERTY, property);
        x.putAttribute(MAPPING_ENTITY, propertyEntity);

        if (visitor.getContext().isGenerateAlias() && x.getParent() instanceof SQLSelectItem) {
            SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
            if (visitor.getContext().isGenerateAlias() && selectItem.getAlias() == null) {
                selectItem.setAlias('"' + property.getName() + '"');
            }
        }

        return false;
    }
View Full Code Here

            if (x.getLeft() instanceof SQLIdentifierExpr && isSimpleValue(visitor, x.getRight())) {
                visit(visitor, (SQLIdentifierExpr) x.getLeft());
                x.getRight().accept(visitor);

                Entity entity = (Entity) x.getLeft().getAttribute(MAPPING_ENTITY);
                Property property = (Property) x.getLeft().getAttribute(MAPPING_PROPERTY);
                Object value = x.getRight().getAttribute(MAPPING_VALUE);

                PropertyValue propertyValue = new PropertyValue(entity, property, value);
                propertyValue.putAttribute("mapping.expr", x.getRight());
               
                visitor.getPropertyValues().add(propertyValue);

                return false;
            }

            if (x.getLeft() instanceof SQLPropertyExpr && isSimpleValue(visitor, x.getRight())) {
                visit(visitor, (SQLPropertyExpr) x.getLeft());
                x.getRight().accept(visitor);

                Entity entity = (Entity) x.getLeft().getAttribute(MAPPING_ENTITY);
                Property property = (Property) x.getLeft().getAttribute(MAPPING_PROPERTY);
                Object value = x.getRight().getAttribute(MAPPING_VALUE);

                PropertyValue propertyValue = new PropertyValue(entity, property, value);
                propertyValue.putAttribute("mapping.expr", x.getRight());
               
View Full Code Here

        String propertyName = x.getName();

        for (SQLTableSource tableSource : visitor.getTableSources().values()) {
            Entity entity = (Entity) tableSource.getAttribute(MAPPING_ENTITY);
            if (entity != null) {
                Property property = entity.getProperty(propertyName);
                if (property != null) {
                    String columnName = visitor.resovleColumnName(entity, property);
                    x.setName(columnName);

                    x.putAttribute(MAPPING_ENTITY, entity);
                    x.putAttribute(MAPPING_PROPERTY, property);

                    if (visitor.getContext().isGenerateAlias() && x.getParent() instanceof SQLSelectItem) {
                        SQLSelectItem selectItem = (SQLSelectItem) x.getParent();
                        if (selectItem.getAlias() == null) {
                            selectItem.setAlias('"' + property.getName() + '"');
                        }
                    }

                    return true;
                }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.mapping.Property

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.