Package com.scooterframework.orm.sqldataexpress.object

Examples of com.scooterframework.orm.sqldataexpress.object.PrimaryKey


        List<String> columns = null;
        try {
          if (connName == null)
            connName = DatabaseConfig.getInstance().getDefaultDatabaseConnectionName();
            PrimaryKey pk = SqlExpressUtil.lookupPrimaryKey(connName, tableName);

            if (pk == null) {
                log.info("There is no primary key detected for table \"" +
                    tableName + "\" as it may be just a resource, " +
                    "not a real table, maybe a view. \"" +
                        RouteConstants.ROUTE_DEFAULT_ID +
                        "\" will be used to represent dynamic id for " +
                        model + " in the route definition instead.");
            }
            else {
                columns = pk.getColumns();
            }
        } catch(Exception ex) {
          log.error(ex);
        }
View Full Code Here


            //ti.setSchema(ti.getHeader().getColumnInfo(0).getSchemaName());
            //ti.setCatalog(ti.getHeader().getColumnInfo(0).getCatalogName());
           
            // get primary keys
            if (!header.hasPrimaryKey()) {
                PrimaryKey pk = lookupPrimaryKey(dba, conn, catalog, schema, table);
                if (pk != null) header.setPrimaryKeyColumns(pk.getColumns());
            }
        }
        finally {
            DAOUtil.closeResultSet(rs);
            DAOUtil.closeResultSet(rs2);
View Full Code Here

        String[] s3 = dba.resolveCatalogAndSchemaAndTable(connName, tableName);
        String catalog = s3[0];
        String schema = s3[1];
        String table = s3[2];
       
        PrimaryKey pk = DBStore.getInstance().getPrimaryKey(connName, catalog, schema, table);
        if (pk != null) return pk;
       
        String errorMessage = "Failed to get primary key for table '" + tableName +
            "' with database connection '" + connName + "'.";
       
View Full Code Here

       
        String fullTableName = DatabaseConfig.getInstance().getFullTableName(table);
       
        List<String> pkNames = new ArrayList<String>();
        ResultSet rs = null;
        PrimaryKey pk = null;
        try {
            catalog = toUpperCaseIfAllowed(dba, catalog);
            schema = toUpperCaseIfAllowed(dba, schema);
            fullTableName = toUpperCaseIfAllowed(dba, fullTableName);
            DatabaseMetaData dbmd = conn.getMetaData();
            rs = dbmd.getPrimaryKeys(catalog, schema, fullTableName);
            while (rs.next()) {
                String _catalog = rs.getString("TABLE_CAT");
                if (catalog == null) catalog = _catalog;
               
                String _schema = rs.getString("TABLE_SCHEM");
                if (schema == null) schema = _schema;
               
                //table = rs.getString("TABLE_NAME");
                String column = rs.getString("COLUMN_NAME");
                pkNames.add(column);
            }
            if (pkNames.size() > 0) pk = new PrimaryKey(catalog, schema, table, pkNames);
        }
        catch(Exception ex) {
            throw new LookupFailureException(ex);
        }
        finally {
View Full Code Here

     
        if (tableName == null) return null;
       
        String fullTableName = getFullTableName(connName, catalog, schema, tableName);
        String pkKey = getPKKey(connName, fullTableName);
        PrimaryKey pk = null;
        if (DatabaseConfig.getInstance().isInDevelopmentEnvironment()) {
          pk = (PrimaryKey)CurrentThreadCache.get(pkKey);
            return pk;
        }
       
View Full Code Here

      }
     
        if (tableName == null) return null;
       
        String pkKey = getPKKey(connName, tableName);
        PrimaryKey pk = null;
        if (DatabaseConfig.getInstance().isInDevelopmentEnvironment()) {
          pk = (PrimaryKey)CurrentThreadCache.get(pkKey);
            return pk;
        }
       
View Full Code Here

  static String getOrderByClauseFromPK(Map<String, Object> inputs) {
    String connName = getConnectionName(inputs);
    String table = getTableOrViewName(inputs);
    if (table == null) return null;
   
    PrimaryKey pk = SqlExpressUtil.lookupPrimaryKey(connName, table);
    if (pk == null) return null;
    List<String> columns = pk.getColumns();
    return StringUtil.flattenArray(columns.toArray());
  }
View Full Code Here

TOP

Related Classes of com.scooterframework.orm.sqldataexpress.object.PrimaryKey

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.