Examples of JpaBasic


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

            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());
            }
View Full Code Here

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

        JpaAttribute findOrCreateAttribute(
                AnnotatedElement element,
                Object parent,
                AnnotationProcessorStack context) {

            JpaBasic basic = null;

            if (parent instanceof JpaManagedClass) {
                JpaManagedClass managedClass = (JpaManagedClass) parent;
                String name = ((Member) element).getName();
                basic = managedClass.getAttributes().getBasicAttribute(name);
                if (basic == null) {
                    basic = new JpaBasic();

                    // do push/pop as the context does some required injection
                    context.push(basic);
                    context.pop();
View Full Code Here

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

        @Override
        void onManagedClass(
                JpaManagedClass managedClass,
                AnnotatedElement element,
                AnnotationProcessorStack context) {
            JpaBasic attribute = new JpaBasic(element.getAnnotation(Basic.class));
            managedClass.getAttributes().getBasicAttributes().add(attribute);
            context.push(attribute);
        }
View Full Code Here

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

                return;
            }

            if (property.isDefaultNonRelationalType()) {

                JpaBasic attribute = new JpaBasic();

                attribute.setPropertyDescriptor(property);
                attribute.setName(property.getName());
                attributes.getBasicAttributes().add(attribute);
            }
            else {
                String path = descriptor.getManagedClass().getName()
                        + "."
View Full Code Here

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

            addChildVisitor(JpaColumn.class, new ColumnVisitor());
        }

        @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);

            // process temporal type defaults
            if (jpaBasic.getTemporal() == null && jpaBasic.getEnumerated() == null) {
                JpaClassDescriptor descriptor = entity.getClassDescriptor();
                JpaPropertyDescriptor property = descriptor.getProperty(jpaBasic
                        .getName());

                // sanity check
                if (property == null) {
                    throw new IllegalStateException("No class property found for name: "
                            + jpaBasic.getName());
                }

                if (java.sql.Date.class.isAssignableFrom(property.getType())) {
                    jpaBasic.setTemporal(TemporalType.DATE);
                }
                else if (Time.class.isAssignableFrom(property.getType())) {
                    jpaBasic.setTemporal(TemporalType.TIME);
                }
                else if (Timestamp.class.isAssignableFrom(property.getType())) {
                    jpaBasic.setTemporal(TemporalType.TIMESTAMP);
                }
                else if (Date.class.isAssignableFrom(property.getType())) {
                    jpaBasic.setTemporal(TemporalType.TIMESTAMP);
                }
                else if (property.getType().isEnum()) {
                    jpaBasic.setEnumerated(EnumType.ORDINAL);
                }
            }

            return true;
        }
View Full Code Here

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

        JpaAttributes attributes = embeddable1.getAttributes();
        assertNotNull(attributes);
        assertEquals(2, attributes.size());
        assertEquals(1, attributes.getBasicAttributes().size());
        JpaBasic a1 = attributes.getBasicAttribute("ea1");

        assertEquals("ea1", a1.getName());
        assertTrue(a1.isOptional());
        assertSame(FetchType.EAGER, a1.getFetch());

        assertTrue(a1.isLob());
        assertNotNull(a1.getColumn());
        assertEquals("column9", a1.getColumn().getName());

        assertEquals(1, attributes.getTransientAttributes().size());
        JpaTransient a2 = attributes.getTransientAttribute("ea2");
        assertEquals("ea2", a2.getName());
    }
View Full Code Here

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

    }

    protected void assertAttributes(JpaAttributes attributes) {
        // BASIC
        assertEquals(5, attributes.getBasicAttributes().size());
        JpaBasic a0 = attributes.getBasicAttribute("attribute1");
        assertEquals("attribute1", a0.getName());
        assertTrue(a0.isOptional());
        assertSame(FetchType.EAGER, a0.getFetch());

        // LOB
        assertNotNull(attributes.getBasicAttribute("attribute12"));
        assertTrue(attributes.getBasicAttribute("attribute12").isLob());
View Full Code Here

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

        JpaEntity entity = map.getEntities().iterator().next();

        // regardless of the ordering of annotations, we should get the same result for
        // both attributes
        assertEquals(3, entity.getAttributes().getBasicAttributes().size());
        JpaBasic a1 = entity.getAttributes().getBasicAttribute("attribute1");
        assertTrue(a1.isLob());

        JpaBasic a2 = entity.getAttributes().getBasicAttribute("attribute2");
        assertTrue(a2.isLob());

        JpaBasic a3 = entity.getAttributes().getBasicAttribute("attribute3");
        assertTrue(a3.isLob());
    }
View Full Code Here

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

    }

    public void testDate() throws Exception {
        assertTrue(context.getConflicts().getFailures(
                MockAnnotatedBean3.class.getDeclaredField("date")).isEmpty());
        JpaBasic date = entity.getAttributes().getBasicAttribute("date");
        assertEquals(TemporalType.TIMESTAMP, date.getTemporal());
    }
View Full Code Here

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

            JpaAttribute attribute) {

        DbAttribute dbAttribute = new DbAttribute(column.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());
        }
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.