Package org.hibernate.cfg

Examples of org.hibernate.cfg.JDBCBinderException


          dependentTables.put(fkName, fkTable);
        }
        else {
          Object previousTable = dependentTables.get(fkName);
          if(fkTable != previousTable) {
            throw new JDBCBinderException("Foreign key name (" + fkName + ") mapped to different tables! previous: " + previousTable + " current:" + fkTable);
          }
        }
       
        Column column = new Column(fkColumnName);
        Column existingColumn = fkTable.getColumn(column);
View Full Code Here


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

        Column column = new Column();
        column.setName(quote(columnName));
        Column existing = table.getColumn(column);
        if(existing!=null) {
          // TODO: should we just pick it up and fill it up with whatever we get from the db instead ?
          throw new JDBCBinderException(column + " already exists in " + qualify);
        }
               
        //TODO: column.setSqlType(sqlTypeName); //this does not work 'cos the precision/scale/length are not retured in TYPE_NAME
        //column.setSqlType(sqlTypeName);
        column.setComment(comment);
View Full Code Here

                table.addUniqueKey(key);             
                uniquekeys.put(indexName, key);
              }
         
              if(indexes.containsKey(indexName) ) {
                throw new JDBCBinderException("UniqueKey exists also as Index! ");
              }
              Column column = getColumn(table, columnName);
              key.addColumn(column);
             
              if (unique && key.getColumnSpan()==1) {
                // make list of columns that has the chance of being unique
                List l = (List) uniqueColumns.get(column);
                if (l == null) {
                  l = new ArrayList();
                  uniqueColumns.put(column, l);
                }
                l.add(key);
              }
            }
            else {
              Index index = (Index) indexes.get(indexName);
              if(index==null) {
                index = new Index();
                index.setName(indexName);
                index.setTable(table);
                table.addIndex(index);
                indexes.put(indexName, index);         
              }
             
              if(uniquekeys.containsKey(indexName) ) {
                throw new JDBCBinderException("Index exists also as Unique! ");
              }
              Column column = getColumn(table, columnName);
              index.addColumn(column);
            }
           
View Full Code Here

          dependentTables.put(fkName, fkTable);
        }
        else {
          Object previousTable = dependentTables.get(fkName);
          if(fkTable != previousTable) {
            throw new JDBCBinderException("Foreign key name (" + fkName + ") mapped to different tables! previous: " + previousTable + " current:" + fkTable);
          }
        }
       
        Column column = new Column(fkColumnName);
        Column existingColumn = fkTable.getColumn(column);
View Full Code Here

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

        Column column = new Column();
        column.setName(quote(columnName));
        Column existing = table.getColumn(column);
        if(existing!=null) {
          // TODO: should we just pick it up and fill it up with whatever we get from the db instead ?
          throw new JDBCBinderException(column + " already exists in " + qualify);
        }
               
        //TODO: column.setSqlType(sqlTypeName); //this does not work 'cos the precision/scale/length are not retured in TYPE_NAME
        //column.setSqlType(sqlTypeName);
        column.setComment(comment);
View Full Code Here

                table.addUniqueKey(key);             
                uniquekeys.put(indexName, key);
              }
         
              if(indexes.containsKey(indexName) ) {
                throw new JDBCBinderException("UniqueKey exists also as Index! ");
              }
              Column column = getColumn(table, columnName);
              key.addColumn(column);
             
              if (unique && key.getColumnSpan()==1) {
                // make list of columns that has the chance of being unique
                List l = (List) uniqueColumns.get(column);
                if (l == null) {
                  l = new ArrayList();
                  uniqueColumns.put(column, l);
                }
                l.add(key);
              }
            }
            else {
              Index index = (Index) indexes.get(indexName);
              if(index==null) {
                index = new Index();
                index.setName(indexName);
                index.setTable(table);
                table.addIndex(index);
                indexes.put(indexName, index);         
              }
             
              if(uniquekeys.containsKey(indexName) ) {
                throw new JDBCBinderException("Index exists also as Unique! ");
              }
              Column column = getColumn(table, columnName);
              index.addColumn(column);
            }
           
View Full Code Here

          dependentTables.put(fkName, fkTable);
        }
        else {
          Object previousTable = dependentTables.get(fkName);
          if(fkTable != previousTable) {
            throw new JDBCBinderException("Foreign key name (" + fkName + ") mapped to different tables! previous: " + previousTable + " current:" + fkTable);
          }
        }
       
        Column column = new Column(fkColumnName);
        Column existingColumn = fkTable.getColumn(column);
View Full Code Here

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

TOP

Related Classes of org.hibernate.cfg.JDBCBinderException

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.