Examples of JpaEntity


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

    public ClassVisitor createVisitor(String className, ClassVisitor out) {

        String key = className.replace('/', '.');

        JpaEntity entity = entityMap.entityForClass(key);
        if (entity != null) {

            // create enhancer chain
            PojoVisitor e1 = new JpaPojoVisitor(out, entity);
            JpaAccessorVisitor e2 = new JpaAccessorVisitor(e1, entity);
View Full Code Here

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

                    .getManagedClass()
                    .getSuperclass();

            while (superclass != null && !superclass.getName().equals("java.lang.Object")) {

                JpaEntity superEntity = map.getEntity(superclass.getName());
                if (superEntity != null) {
                    entity.setSuperEntity(superEntity);
                    break;
                }
View Full Code Here

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

        public void onStartElement(
                AnnotatedElement element,
                AnnotationProcessorStack context) {
            Entity entityAnnotation = element.getAnnotation(Entity.class);

            JpaEntity entity = new JpaEntity();
            entity.setClassName(((Class<?>) element).getName());
            entity.setAttributes(new JpaAttributes());

            if (!Util.isEmptyString(entityAnnotation.name())) {
                entity.setName(entityAnnotation.name());
            }

            context.push(entity);
        }
View Full Code Here

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

        }

        public void onFinishElement(
                AnnotatedElement element,
                AnnotationProcessorStack context) {
            JpaEntity entity = (JpaEntity) context.pop();
            JpaEntityMap entityMap = (JpaEntityMap) context.peek();
            entityMap.getEntities().add(entity);
        }
View Full Code Here

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

    public ClassVisitor createVisitor(String className, ClassVisitor out) {

        String key = className.replace('/', '.');

        JpaEntity entity = entityMap.entityForClass(key);
        if (entity != null) {

            // create enhancer chain
            PojoVisitor e1 = new JpaPojoVisitor(out, entity);
            JpaAccessorVisitor e2 = new JpaAccessorVisitor(e1, entity);
View Full Code Here

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

        public void onFinishNode(ProjectPath path) {

            // now that attributes are parsed, we can fill in secondary table joins that
            // may depend on previous entity id column processing.

            JpaEntity entity = (JpaEntity) path.getObject();
            for (JpaSecondaryTable table : entity.getSecondaryTables()) {

                if (table.getPrimaryKeyJoinColumns().isEmpty()) {

                    for (JpaId id : entity.getAttributes().getIds()) {
                        JpaPrimaryKeyJoinColumn joinColumn = new JpaPrimaryKeyJoinColumn();
                        joinColumn.setName(id.getColumn().getName());
                        joinColumn.setReferencedColumnName(joinColumn.getName());
                        table.getPrimaryKeyJoinColumns().add(joinColumn);
                    }
                }
                else {
                    for (JpaPrimaryKeyJoinColumn joinColumn : table
                            .getPrimaryKeyJoinColumns()) {

                        if (joinColumn.getReferencedColumnName() == null) {
                            if (entity.getAttributes().getIds().size() == 1) {
                                JpaId id = entity
                                        .getAttributes()
                                        .getIds()
                                        .iterator()
                                        .next();
                                joinColumn.setReferencedColumnName(id
                                        .getColumn()
                                        .getName());
                            }
                        }
                    }
                }
            }

            JpaDiscriminatorColumn discriminator = entity.lookupDiscriminatorColumn();
            if (discriminator != null) {

                if (entity.getDiscriminatorValue() == null) {
                    switch (discriminator.getDiscriminatorType()) {

                        case STRING:
                            entity.setDiscriminatorValue(entity.getName());
                            break;
                        default:
                            context.recordConflict(new SimpleValidationFailure(
                                    entity,
                                    "Can't guess default discriminator value for non-String discriminator column: "
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 = 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 = 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

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