Examples of PrimaryKey


Examples of org.exolab.castor.xml.schema.annotations.jdo.PrimaryKey

                            cNature.setTableName(table.getName());
                            cNature.setAccessMode(AccessMode.valueOf("shared"));
                            cNature.setDetachable(table.isDetachable());
                         // TODO: Uncomment next line as soon as Annotation Classes have been updated!
//                            cNature.setAccessMode(AccessMode.valueOf(table.getAccessMode().toString()));
                            PrimaryKey pk = table.getPrimaryKey();
                            Iterator<String> pIt = pk.iterateKey();
                            while (pIt.hasNext()) {
                                cNature.addPrimaryKey(pIt.next());
                            }
                        }
                    }
View Full Code Here

Examples of org.geotools.jdbc.PrimaryKey

        }

        if (columns.isEmpty()) {
            return null;
        } else {
            return new PrimaryKey(table, columns);
        }
    }
View Full Code Here

Examples of org.hibernate.mapping.PrimaryKey

    Iterator<Table> tableMappings = configuration.getTableMappings();
    while ( tableMappings.hasNext() ) {
      Table table = tableMappings.next();
      if ( table.isPhysicalTable() ) {
        Label label = label( table.getName() );
        PrimaryKey primaryKey = table.getPrimaryKey();
        createConstraint( neo4jDb, table, label, primaryKey );
        @SuppressWarnings("unchecked")
        Iterator<Column> columnIterator = table.getColumnIterator();
        while ( columnIterator.hasNext() ) {
          Column column = columnIterator.next();
View Full Code Here

Examples of org.hibernate.mapping.PrimaryKey

   * @throws SQLException
   */
  private void processPrimaryKey(DatabaseCollector dbs, Table table) {
       
    List columns = new ArrayList();
    PrimaryKey key = null;
    Iterator primaryKeyIterator = null;
    try {
      Map primaryKeyRs = null
      primaryKeyIterator = getMetaDataDialect().getPrimaryKeys(getCatalogForDBLookup(table.getCatalog()), getSchemaForDBLookup(table.getSchema()), table.getName() );   
   
      while (primaryKeyIterator.hasNext() ) {
        primaryKeyRs = (Map) primaryKeyIterator.next();
       
        /*String ownCatalog = primaryKeyRs.getString("TABLE_CAT");
         String ownSchema = primaryKeyRs.getString("TABLE_SCHEM");
         String ownTable = primaryKeyRs.getString("TABLE_NAME");*/
       
        String columnName = (String) primaryKeyRs.get("COLUMN_NAME");
        short seq = ((Short)primaryKeyRs.get("KEY_SEQ")).shortValue();
        String name = (String) primaryKeyRs.get("PK_NAME");
       
        if(key==null) {
          key = new PrimaryKey();
          key.setName(name);
          key.setTable(table);
          if(table.getPrimaryKey()!=null) {
            throw new JDBCBinderException(table + " already has a primary key!"); //TODO: ignore ?
          }
          table.setPrimaryKey(key);
        }
        else {
          if(!(name==key.getName() ) && name!=null && !name.equals(key.getName() ) ) {
            throw new JDBCBinderException("Duplicate names found for primarykey. Existing name: " + key.getName() + " JDBC name: " + name + " on table " + table);
          }           
        }
       
        columns.add(new Object[] { new Short(seq), columnName});
      }
    } finally {
      if (primaryKeyIterator!=null) {
        try {
          getMetaDataDialect().close(primaryKeyIterator);
        } catch(JDBCException se) {
          log.warn("Exception when closing resultset for reading primary key information",se);
        }
      }
    }
       
        // sort the columns accoring to the key_seq.
        Collections.sort(columns,new Comparator() {
      public boolean equals(Object obj) {
        return super.equals(obj);
      }

      public int compare(Object o1, Object o2) {
        Short left = (Short) ( (Object[]) o1)[0];
        Short right = (Short) ( (Object[]) o2)[0];
        return left.compareTo(right);
      }
     
      public int hashCode() {
        return super.hashCode();
      }
        });
       
        List t = new ArrayList(columns.size());
        Iterator cols = columns.iterator();
        while (cols.hasNext() ) {
      Object[] element = (Object[]) cols.next();
      t.add(element[1]);
        }
        columns = t;
       
        if(key==null) {
          log.warn("The JDBC driver didn't report any primary key columns in " + table.getName() + ". Asking rev.eng. strategy" );
          List userPrimaryKey = revengStrategy.getPrimaryKeyColumnNames(TableIdentifier.create(table));
          if(userPrimaryKey!=null && !userPrimaryKey.isEmpty()) {
            key = new PrimaryKey();
            key.setName(new Alias(15, "PK").toAliasString( table.getName()));
            key.setTable(table);
            if(table.getPrimaryKey()!=null) {
              throw new JDBCBinderException(table + " already has a primary key!"); //TODO: ignore ?
            }
            table.setPrimaryKey(key);
            columns = new ArrayList(userPrimaryKey);
          } else {
            log.warn("Rev.eng. strategy did not report any primary key columns for " + table.getName());
          }         
        }

        Iterator suggestedPrimaryKeyStrategyName = getMetaDataDialect().getSuggestedPrimaryKeyStrategyName( getCatalogForDBLookup(table.getCatalog()), getSchemaForDBLookup(table.getSchema()), table.getName() );
        try {
        if(suggestedPrimaryKeyStrategyName.hasNext()) {
          Map m = (Map) suggestedPrimaryKeyStrategyName.next();
          String suggestion = (String) m.get( "HIBERNATE_STRATEGY" );
          if(suggestion!=null) {
            dbs.addSuggestedIdentifierStrategy( table.getCatalog(), table.getSchema(), table.getName(), suggestion );
          }
        }
        } finally {
          if(suggestedPrimaryKeyStrategyName!=null) {
          try {
            getMetaDataDialect().close(suggestedPrimaryKeyStrategyName);
          } catch(JDBCException se) {
            log.warn("Exception while closing iterator for suggested primary key strategy name",se);
          }
        }         
        }
               
        if(key!=null) {
          cols = columns.iterator();
          while (cols.hasNext() ) {
            String name = (String) cols.next();
            // should get column from table if it already exists!
            Column col = getColumn(table, name);
            key.addColumn(col);
          }
          log.debug("primary key for " + table + " -> "  + key);
        }
              
  }
View Full Code Here

Examples of org.hibernate.mapping.PrimaryKey

  public boolean isManyToManyTable(Table table) {
    if(settings.getDetectManyToMany()) {
     
      // if the number of columns in the primary key is different
      // than the total number of columns then it can't be a middle table
      PrimaryKey pk = table.getPrimaryKey();
      if ( pk==null || pk.getColumns().size() != table.getColumnSpan() )
        return false;
     
      Iterator foreignKeyIterator = table.getForeignKeyIterator();
      List foreignKeys = new ArrayList();
     
View Full Code Here

Examples of org.jboss.dna.common.jdbc.model.api.PrimaryKey

        // check
        assertSame("Unable to find column", column, bean.findColumnByName(COLUMN_NAME));
    }

    public void testSetPrimaryKey() {
        PrimaryKey primaryKey = factory.createPrimaryKey();
        // set
        bean.setPrimaryKey(primaryKey);
        // check
        assertSame("Unable to set primary key", primaryKey, bean.getPrimaryKey());
    }
View Full Code Here

Examples of org.jdbf.engine.basic.PrimaryKey

    public static void main(String[] args) {
      try{
     
        CompositePrimaryKeySample sample = new CompositePrimaryKeySample();
        PrimaryKey pk = new PrimaryKey();
        pk.setValueKey("OID",new Integer(1));
        pk.setValueKey("lineId",new Integer(0));
      QueryResults results = sample.selectByPrimaryKey("orderline",pk);
      sample.printQueryResults(results);
      }
      catch(Exception e){
        e.printStackTrace();
View Full Code Here

Examples of org.jpox.store.rdbms.key.PrimaryKey

     * to add on any specification of PK name in the metadata.
     * @return The primary key.
     */
    public PrimaryKey getPrimaryKey()
    {
        PrimaryKey pk = super.getPrimaryKey();
        if (joinMetaData == null)
        {
            // TODO Localise this message
            throw new JPOXUserException("A relationship to a secondary table requires a <join> specification. " +
                "The secondary table is " + this.getDatastoreIdentifierFullyQualified() +
                " and the primary table is " + this.getPrimaryDatastoreContainerObject() +
                ". The fields mapped to this secondary table are: " + fieldMappingsMap.keySet().toString());
        }
        PrimaryKeyMetaData pkmd = joinMetaData.getPrimaryKeyMetaData();
        if (pkmd != null && pkmd.getName() != null)
        {
            pk.setName(pkmd.getName());
        }

        return pk;
    }
View Full Code Here

Examples of org.makersoft.shards.annotation.PrimaryKey

      System.arraycopy(second, 0, fields, first.length, second.length);

      for (Field field : fields) {
        field.setAccessible(true);
       
        PrimaryKey primaryKey = field.getAnnotation(PrimaryKey.class);
        if (primaryKey != null) {
          try {
            //去除0的情况
            Object result = field.get(object);
            if(result != null && "0".equals(result.toString())){
View Full Code Here

Examples of org.qdao.annotation.PrimaryKey

        new ArrayList<TableDescriptor.ColumnDescription>();

    List<String> primaryKeys = new ArrayList<String>();
    List<TableDescriptor.ColumnDescription> pks = new ArrayList<TableDescriptor.ColumnDescription>();
    Column co;
    PrimaryKey pk;
    TableDescriptor.ColumnDescription cd;
/*    TableDescriptor.FkDescription fkd;
    String fkTableName;
    ForeignKey fk;
*/    for (int i = 0; i < fields.length; i++) {
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.