Example usage for org.hibernate.mapping Table getQuotedName

List of usage examples for org.hibernate.mapping Table getQuotedName

Introduction

In this page you can find the example usage for org.hibernate.mapping Table getQuotedName.

Prototype

public String getQuotedName() 

Source Link

Usage

From source file:kr.debop4j.data.ogm.test.datastore.DatastoreProviderGeneratingSchema.java

License:Apache License

@Override
public void start(Configuration configuration, SessionFactoryImplementor sessionFactoryImplementor) {
    Iterator<Table> tables = configuration.getTableMappings();
    while (tables.hasNext()) {
        Table table = tables.next();
        if (table.isPhysicalTable()) {
            String tableName = table.getQuotedName();
            // do something with table
            Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator();
            while (columns.hasNext()) {
                Column column = columns.next();
                String columnName = column.getCanonicalName();
                // do something with column
            }//from  ww w.  j  a v  a2s  .c o  m
            //TODO handle unique constraints?
        }
    }
    throw new RuntimeException("STARTED!");
}

From source file:org.n52.sos.ds.datasource.AbstractHibernateDatasource.java

License:Open Source License

@Override
public boolean checkIfSchemaExists(Map<String, Object> settings) {
    Connection conn = null;/*from  w w  w. ja v a 2 s  .c o  m*/
    try {
        /* check if any of the needed tables is existing */
        conn = openConnection(settings);
        DatabaseMetadata metadata = getDatabaseMetadata(conn, getConfig(settings));
        Iterator<Table> iter = getConfig(settings).getTableMappings();
        String catalog = checkCatalog(conn);
        String schema = checkSchema((String) settings.get(SCHEMA_KEY), catalog, conn);
        while (iter.hasNext()) {
            Table table = iter.next();
            if (table.isPhysicalTable() && metadata.isTable(table.getQuotedName())
                    && metadata.getTableMetadata(table.getName(), schema, catalog, table.isQuoted()) != null) {
                return true;
            }
        }
        return false;
    } catch (SQLException ex) {
        throw new ConfigurationException(ex);
    } finally {
        close(conn);
    }
}

From source file:org.n52.sos.ds.datasource.CustomConfiguration.java

License:Open Source License

protected boolean checkTable(Table table, DatabaseMetadata m) {
    return table.isPhysicalTable() && m.isTable(table.getQuotedName());
}

From source file:org.teiid.spring.autoconfigure.RedirectionSchemaInitializer.java

License:Apache License

List<Resource> generatedScripts() {
    List<Resource> resources = Collections.emptyList();

    for (PersistentClass clazz : metadata.getEntityBindings()) {
        org.hibernate.mapping.Table ormTable = clazz.getTable();
        String tableName = ormTable.getQuotedName();
        if (this.schema.getTable(tableName) != null) {
            org.hibernate.mapping.Column c = new org.hibernate.mapping.Column(
                    RedirectionSchemaBuilder.ROW_STATUS_COLUMN);
            c.setSqlTypeCode(TypeFacility.getSQLTypeFromRuntimeType(Integer.class));
            c.setSqlType(JDBCSQLTypeInfo.getTypeName(TypeFacility.getSQLTypeFromRuntimeType(Integer.class)));
            ormTable.addColumn(c);/*from w  w w . j  ava  2 s .  c o  m*/
            ormTable.setName(tableName + TeiidConstants.REDIRECTED_TABLE_POSTFIX);
        }
    }

    List<String> statements = createScript(metadata, dialect, true);
    StringBuilder sb = new StringBuilder();
    for (String s : statements) {
        // we have no need for sequences in the redirected scenario, they are fed from
        // other side.
        if (s.startsWith("drop sequence") || s.startsWith("create sequence")) {
            continue;
        }
        sb.append(s).append(";\n");
    }
    logger.debug("Redirected Schema:\n" + sb.toString());
    resources = Arrays.asList(new ByteArrayResource(sb.toString().getBytes()));
    return resources;
}