Package net.sf.hajdbc

Examples of net.sf.hajdbc.UniqueConstraint


  @Test
  public void getCreateUniqueConstraintSQL() throws SQLException
  {
    QualifiedName table = mock(QualifiedName.class);
    UniqueConstraint constraint = mock(UniqueConstraint.class);
   
    when(table.getDDLName()).thenReturn("table");
    when(constraint.getName()).thenReturn("name");
    when(constraint.getTable()).thenReturn(table);
    when(constraint.getColumnList()).thenReturn(Arrays.asList("column1", "column2"));
   
    String result = this.dialect.getCreateUniqueConstraintSQL(constraint);
   
    assertEquals("ALTER TABLE table ADD CONSTRAINT name UNIQUE (column1, column2)", result);
  }
View Full Code Here


  @Test
  public void getDropUniqueConstraintSQL() throws SQLException
  {
    QualifiedName table = mock(QualifiedName.class);
    UniqueConstraint constraint = mock(UniqueConstraint.class);
   
    when(table.getDDLName()).thenReturn("table");
    when(constraint.getName()).thenReturn("name");
    when(constraint.getTable()).thenReturn(table);
    when(constraint.getColumnList()).thenReturn(Arrays.asList("column1", "column2"));
   
    String result = this.dialect.getDropUniqueConstraintSQL(constraint);
   
    assertEquals("ALTER TABLE table DROP CONSTRAINT name", result);
  }
View Full Code Here

  {
    ResultSet resultSet = metaData.getPrimaryKeys(getCatalog(metaData), table.getSchema(), table.getName());
   
    try
    {
      UniqueConstraint constraint = null;

      while (resultSet.next())
      {
        if (constraint == null)
        {
          constraint = factory.createUniqueConstraint(resultSet.getString("PK_NAME"), table);
        }
       
        constraint.getColumnList().add(resultSet.getString("COLUMN_NAME"));
      }
     
      return constraint;
    }
    finally
View Full Code Here

      {
        if (resultSet.getShort("TYPE") == DatabaseMetaData.tableIndexHashed)
        {
          String name = resultSet.getString("INDEX_NAME");
         
          UniqueConstraint key = keyMap.get(name);
         
          if (key == null)
          {
            key = factory.createUniqueConstraint(name, table);
           
            // Don't include the primary key
            if (key.equals(primaryKey)) continue;
           
            keyMap.put(name, key);
          }
         
          key.getColumnList().add(resultSet.getString("COLUMN_NAME"));
        }
      }
      return keyMap.values();
    }
    finally
View Full Code Here

TOP

Related Classes of net.sf.hajdbc.UniqueConstraint

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.