Examples of JpaEntity


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

            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) {
View Full Code Here

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

            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.JpaEntity

        public boolean onStartNode(ProjectPath path) {
            JpaRelationship relationship = (JpaRelationship) path.getObjectParent();
            JpaJoinColumn column = (JpaJoinColumn) path.getObject();

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

            // JPA Spec, 2.1.8.2 (same for all relationship owners):
            // The following mapping defaults apply: [...]
            // Table A contains a foreign key to table B. The foreign key column
            // name is formed as the concatenation of the following: the name of
            // the relationship property or field of entityA; "_" ; the name of
            // the primary key column in table B. The foreign key column has the
            // same type as the primary key of table B.

            JpaEntityMap map = (JpaEntityMap) path.firstInstanceOf(JpaEntityMap.class);
            JpaEntity target = map.entityForClass(relationship.getTargetEntityName());

            if (target == null) {
                context.recordConflict(new SimpleValidationFailure(
                        relationship,
                        "Invalid relationship target "
                                + relationship.getTargetEntityName()));
            }
            else if (target.getAttributes() == null
                    || target.getAttributes().getIds().isEmpty()) {
                context.recordConflict(new SimpleValidationFailure(
                        target,
                        "Relationship target has no PK defined: "
                                + relationship.getTargetEntityName()));
            }
            else if (target.getAttributes().getIds().size() > 1) {
                // TODO: andrus, 4/30/2006 implement this; note that instead of
                // checking for "attribute.getJoinColumns().isEmpty()" above,
                // we'll have to match individual columns
                context.recordConflict(new SimpleValidationFailure(
                        relationship,
                        "Defaults for compound FK are not implemented."));
            }
            else {
                JpaId id = target.getAttributes().getIds().iterator().next();

                String pkName = id.getColumn() != null ? id.getColumn().getName() : id
                        .getName();
                column.setName(relationship.getName() + '_' + pkName);
                column.setReferencedColumnName(id.getColumn() != null ? id
View Full Code Here

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

            if (abstractEntity.getClassName() == null) {
                return false;
            }

            if (abstractEntity instanceof JpaEntity) {
                JpaEntity entity = (JpaEntity) abstractEntity;
                if (entity.getName() == null) {
                    // use unqualified class name
                    String fqName = abstractEntity.getClassName();
                    int split = fqName.lastIndexOf('.');
                    entity.setName(split > 0 ? fqName.substring(split + 1) : fqName);
                }

                // * default table (see @Table annotation defaults, JPA spec 9.1.1)
                if (entity.getTable() == null) {
                    JpaTable table = new JpaTable(AnnotationPrototypes.getTable());

                    // unclear whether we need to apply any other name transformations ...
                    // or even if we need to uppercase the name. Per default examples
                    // looks
                    // like we need. table.setName(entity.getName().toUpperCase());
                    table.setName(entity.getName());
                    entity.setTable(table);
                }
            }

            if (abstractEntity.getAttributes() == null) {
                abstractEntity.setAttributes(new JpaAttributes());
View Full Code Here

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

                column.setName(jpaBasic.getName());
                jpaBasic.setColumn(column);
            }

            if (jpaBasic.getTemporal() == null) {
                JpaEntity entity = (JpaEntity) path.firstInstanceOf(JpaEntity.class);
                JpaClassDescriptor descriptor = entity.getClassDescriptor();
                JpaPropertyDescriptor property = descriptor.getProperty(jpaBasic
                        .getName());

                if (Date.class.equals(property.getType())) {
                    jpaBasic.setTemporal(TemporalType.TIMESTAMP);
View Full Code Here

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

            addChildVisitor(JpaEntityListeners.class, listenersVisitor);
        }

        @Override
        Object createObject(ProjectPath path) {
            JpaEntity jpaEntity = (JpaEntity) path.getObject();
            ObjEntity cayenneEntity = new ObjEntity(jpaEntity.getName());
            cayenneEntity.setClassName(jpaEntity.getClassName());
            initCallbacks(jpaEntity, cayenneEntity);

            ((DataMap) targetPath.getObject()).addObjEntity(cayenneEntity);

            return cayenneEntity;
View Full Code Here

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

            ObjRelationship cayenneRelationship = new ObjRelationship(relationship
                    .getName());

            cayenneSrcEntity.addRelationship(cayenneRelationship);

            JpaEntity jpaTargetEntity = ((JpaEntityMap) path.getRoot())
                    .entityForClass(relationship.getTargetEntityName());

            if (jpaTargetEntity == null) {
                recordConflict(path, "Unknown target entity '"
                        + relationship.getTargetEntityName());
                return null;
            }

            cayenneRelationship.setTargetEntityName(jpaTargetEntity.getName());

            DbEntity cayenneSrcDbEntity = cayenneSrcEntity.getDbEntity();
            DbEntity cayenneTargetDbEntity = cayenneSrcEntity.getDataMap().getDbEntity(
                    jpaTargetEntity.getTable().getName());
            if (cayenneTargetDbEntity == null) {
                cayenneTargetDbEntity = new DbEntity(jpaTargetEntity.getTable().getName());
                cayenneSrcEntity.getDataMap().addDbEntity(cayenneTargetDbEntity);
            }

            JpaDbRelationship dbRelationship = new JpaDbRelationship(cayenneRelationship
                    .getName());
View Full Code Here

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

        // apply defaults
        new EntityMapDefaultsProcessor().applyDefaults(context);

        JpaEntityMap map = context.getEntityMap();
        JpaEntity entity = map.entityForClass(MockAnnotatedBeanVersion.class);
        assertNotNull(entity);

        JpaVersion v = entity.getAttributes().getVersionAttribute("attribute1");
        assertNotNull(v);
        assertNotNull(v.getColumn());
    }
View Full Code Here

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

        // apply defaults
        new EntityMapDefaultsProcessor().applyDefaults(context);

        JpaEntityMap map = context.getEntityMap();
        assertEquals(1, map.getEntities().size());
        JpaEntity entity = map.getEntities().iterator().next();

        // testing that static fields are not loaded as persistent
        assertEquals(1, entity.getAttributes().size());
        assertEquals(1, entity.getAttributes().getIds().size());
    }
View Full Code Here

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

                    new JpaSQLResultSetMappingVisitor());
        }

        @Override
        Object createObject(ProjectPath path) {
            JpaEntity jpaEntity = (JpaEntity) path.getObject();
            ObjEntity cayenneEntity = new ObjEntity(jpaEntity.getName());

            if (jpaEntity.getInheritance() == null
                    && jpaEntity.lookupInheritanceStrategy() == InheritanceType.SINGLE_TABLE) {
                cayenneEntity.setSuperEntityName(jpaEntity.getSuperEntity().getName());
            }

            cayenneEntity.setClassName(jpaEntity.getClassName());
            initCallbacks(jpaEntity, cayenneEntity);

            ((DataMap) targetPath.getObject()).addObjEntity(cayenneEntity);

            return cayenneEntity;
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.