Package com.mysema.query.sql

Examples of com.mysema.query.sql.ColumnMetadata


public class ColumnMetadataTest {

    @Test
    public void DefaultColumn() {
        ColumnMetadata column = ColumnMetadata.named("Person");
        assertEquals("Person", column.getName());
        assertFalse(column.hasJdbcType());
        assertFalse(column.hasSize());
        assertTrue(column.isNullable());
    }
View Full Code Here


        assertTrue(column.isNullable());
    }

    @Test
    public void FullyConfigured() {
        ColumnMetadata column = ColumnMetadata.named("Person").withSize(10)
                .notNull().ofType(Types.BIGINT);
        assertEquals("Person", column.getName());
        assertTrue(column.hasJdbcType());
        assertEquals(Types.BIGINT, column.getJdbcType());
        assertTrue(column.hasSize());
        assertEquals(10, column.getSize());
        assertFalse(column.isNullable());
    }
View Full Code Here

        assertFalse(column.isNullable());
    }

    @Test
    public void ExtractFromRelationalPath() {
        ColumnMetadata column = ColumnMetadata.getColumnMetadata(QEmployee.employee.id);
        assertEquals("ID", column.getName());
    }
View Full Code Here

        assertEquals("ID", column.getName());
    }

    @Test
    public void FallBackToDefaultWhenMissing() {
        ColumnMetadata column = ColumnMetadata.getColumnMetadata(QEmployee.employee.salary);
        assertEquals("SALARY", column.getName());
    }
View Full Code Here

        if (columnComparator != null) {
            Collections.sort(properties, columnComparator);
        }
        for (Property property : properties) {
            String name = property.getEscapedName();
            ColumnMetadata metadata = (ColumnMetadata) property.getData().get("COLUMN");
            StringBuilder columnMeta = new StringBuilder();
            columnMeta.append("ColumnMetadata");
            columnMeta.append(".named(\"" + metadata.getName() + "\")");
            columnMeta.append(".withIndex(" + metadata.getIndex() + ")");
            String type = String.valueOf(metadata.getJdbcType());
            if (typeConstants.containsKey(metadata.getJdbcType())) {
                type = "Types." + typeConstants.get(metadata.getJdbcType());
            }
            columnMeta.append(".ofType(" + type + ")");
            if (metadata.hasSize()) {
                columnMeta.append(".withSize(" + metadata.getSize() + ")");
            }
            if (metadata.getDigits() > 0) {
                columnMeta.append(".withDigits(" + metadata.getDigits() + ")");
            }
            if (!metadata.isNullable()) {
                columnMeta.append(".notNull()");
            }
            writer.line("addMetadata(", name, ", ", columnMeta.toString(), ");");
        }
        writer.end();
View Full Code Here

    @Override
    public int compare(Property property1, Property property2) {
        Integer comparison = null;
        for (Property property : Arrays.asList(property1, property2)) {
            Map<Object, Object> data = property.getData();
            ColumnMetadata columnMetadata = (ColumnMetadata) data.get("COLUMN");
            int index = columnMetadata.getIndex();
            comparison = comparison == null ? index : comparison - index;
        }
        return comparison;
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.sql.ColumnMetadata

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.