Examples of JpaColumn


Examples of org.apache.cayenne.jpa.map.JpaColumn

                    .firstInstanceOf(JpaEntityMap.class)
                    .embeddableForClass(jpaEmbedded.getPropertyDescriptor().getType());

            for (JpaBasic jpaBasic : jpaEmbeddable.getAttributes().getBasicAttributes()) {

                JpaColumn column = jpaBasic.getColumn();
                String tableName = column.getTable() != null ? column.getTable() : entity
                        .getDbEntityName();

                createDbAttribute(tableName, jpaBasic.getColumn(), jpaBasic);
            }
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

    class JpaColumnVisitor extends BaseTreeVisitor {

        @Override
        public boolean onStartNode(ProjectPath path) {
            JpaColumn jpaColumn = (JpaColumn) path.getObject();
            JpaAttribute attribute = (JpaAttribute) path.getObjectParent();

            DbAttribute dbAttribute = new DbAttribute(jpaColumn.getName());

            if (attribute instanceof JpaBasic) {
                JpaBasic basic = (JpaBasic) attribute;
                dbAttribute.setType(basic.getDefaultJdbcType());
            }
            else if (attribute instanceof JpaVersion) {
                JpaVersion version = (JpaVersion) attribute;
                dbAttribute.setType(version.getDefaultJdbcType());
            }

            dbAttribute.setMandatory(!jpaColumn.isNullable());
            dbAttribute.setMaxLength(jpaColumn.getLength());

            // DbAttribute "no scale" means -1, not 0 like in JPA.
            if (jpaColumn.getScale() > 0) {
                dbAttribute.setScale(jpaColumn.getScale());
            }

            // DbAttribute "no precision" means -1, not 0 like in JPA.
            if (jpaColumn.getPrecision() > 0) {
                dbAttribute.setAttributePrecision(jpaColumn.getPrecision());
            }

            if (jpaColumn.getTable() == null) {
                throw new JpaProviderException("No default table defined for JpaColumn "
                        + jpaColumn.getName());
            }

            DbEntity entity = ((DataMap) targetPath.firstInstanceOf(DataMap.class))
                    .getDbEntity(jpaColumn.getTable());

            if (entity == null) {
                throw new JpaProviderException("No DbEntity defined for table  "
                        + jpaColumn.getTable());
            }

            entity.addAttribute(dbAttribute);

            return false;
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

    class JpaIdColumnVisitor extends BaseTreeVisitor {

        @Override
        public boolean onStartNode(ProjectPath path) {
            JpaColumn jpaColumn = (JpaColumn) path.getObject();

            DbAttribute dbAttribute = new DbAttribute(jpaColumn.getName());

            JpaId jpaId = (JpaId) path.firstInstanceOf(JpaId.class);

            dbAttribute.setType(jpaId.getDefaultJdbcType());

            dbAttribute.setMaxLength(jpaColumn.getLength());
            dbAttribute.setMandatory(true);
            dbAttribute.setPrimaryKey(true);

            if (jpaColumn.getScale() > 0) {
                dbAttribute.setScale(jpaColumn.getScale());
            }

            if (jpaColumn.getPrecision() > 0) {
                dbAttribute.setAttributePrecision(jpaColumn.getPrecision());
            }

            if (jpaColumn.getTable() == null) {
                recordConflict(path, "No table defined for JpaColumn '"
                        + jpaColumn.getName()
                        + "'");
                return false;
            }

            DbEntity entity = ((DataMap) targetPath.firstInstanceOf(DataMap.class))
                    .getDbEntity(jpaColumn.getTable());

            if (entity == null) {
                recordConflict(path, "Invalid table definition for JpaColumn: "
                        + jpaColumn.getTable()
                        + "'");
                return false;
            }

            entity.addAttribute(dbAttribute);
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

    final class ColumnVisitor extends BaseTreeVisitor {

        @Override
        public boolean onStartNode(ProjectPath path) {
            JpaColumn column = (JpaColumn) path.getObject();

            JpaAttribute parent = (JpaAttribute) path.firstInstanceOf(JpaAttribute.class);

            if (column.getName() == null) {
                column.setName(parent.getName());
            }

            if (column.getTable() == null) {
                JpaEntity entity = (JpaEntity) path.firstInstanceOf(JpaEntity.class);

                // parent can be a mapped superclass
                if (entity != null) {
                    column.setTable(entity.getTable().getName());
                }
            }

            if (parent.getPropertyDescriptor().isStringType()) {
                if (column.getLength() <= 0) {
                    column.setLength(JpaColumn.DEFAULT_LENGTH);
                }
            }
            else {
                // length for non-string types should be ignored...
                column.setLength(-1);
            }

            return true;
        }
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

        public boolean onStartNode(ProjectPath path) {
            JpaId id = (JpaId) path.getObject();

            if (id.getColumn() == null) {

                JpaColumn column = new JpaColumn(AnnotationPrototypes.getColumn());
                column.setName(id.getName());

                JpaEntity entity = (JpaEntity) path.firstInstanceOf(JpaEntity.class);
                column.setTable(entity.getTable().getName());
                id.setColumn(column);
            }

            return true;
        }
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

        void onAttribute(
                JpaAttribute attribute,
                AnnotatedElement element,
                AnnotationProcessorStack context) {

            JpaColumn column = new JpaColumn(element.getAnnotation(Column.class));

            if (attribute instanceof JpaBasic) {
                ((JpaBasic) attribute).setColumn(column);
            }
            else if (attribute instanceof JpaVersion) {
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

        @Override
        public boolean onStartNode(ProjectPath path) {
            JpaBasic jpaBasic = (JpaBasic) path.getObject();
            if (jpaBasic.getColumn() == null) {
                JpaColumn column = new JpaColumn(AnnotationPrototypes.getColumn());
                column.setName(jpaBasic.getName());
                column.setNullable(jpaBasic.isOptional());
                jpaBasic.setColumn(column);
            }

            JpaAbstractEntity entity = (JpaAbstractEntity) path
                    .firstInstanceOf(JpaAbstractEntity.class);
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

        @Override
        public boolean onStartNode(ProjectPath path) {
            JpaVersion jpaBasic = (JpaVersion) path.getObject();
            if (jpaBasic.getColumn() == null) {
                JpaColumn column = new JpaColumn(AnnotationPrototypes.getColumn());
                column.setName(jpaBasic.getName());
                jpaBasic.setColumn(column);
            }

            if (jpaBasic.getTemporal() == null) {
                JpaEntity entity = (JpaEntity) path.firstInstanceOf(JpaEntity.class);
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

        assertEquals(2, entity2.getAttributeOverrides().size());
        List<JpaAttributeOverride> overrides = new ArrayList<JpaAttributeOverride>(
                entity2.getAttributeOverrides());

        assertEquals("attribute1", overrides.get(0).getName());
        JpaColumn c1 = overrides.get(0).getColumn();
        assertEquals("ao_column1", c1.getName());
        assertEquals("count(1)", c1.getColumnDefinition());
        assertEquals("ao_table1", c1.getTable());
        assertEquals(3, c1.getLength());
        assertEquals(4, c1.getPrecision());
        assertEquals(5, c1.getScale());
        assertTrue(c1.isInsertable());
        assertTrue(c1.isNullable());
        assertTrue(c1.isUnique());
        assertTrue(c1.isUpdatable());

        assertEquals("attribute2", overrides.get(1).getName());
    }
View Full Code Here

Examples of org.apache.cayenne.jpa.map.JpaColumn

                    .firstInstanceOf(JpaEntityMap.class)
                    .embeddableForClass(jpaEmbedded.getPropertyDescriptor().getType());

            for (JpaBasic jpaBasic : jpaEmbeddable.getAttributes().getBasicAttributes()) {

                JpaColumn column = jpaBasic.getColumn();
                String tableName = column.getTable() != null ? column.getTable() : entity
                        .getDbEntityName();

                createDbAttribute(tableName, jpaBasic.getColumn(), jpaBasic);
            }
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.