org.hibernate.mapping.PrimaryKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate Show documentation
Show all versions of hibernate Show documentation
Relational Persistence for Java
//$Id: PrimaryKey.java 5685 2005-02-12 07:19:50Z steveebersole $
package org.hibernate.mapping;
import java.util.Iterator;
import org.hibernate.dialect.Dialect;
/**
* A primary key constraint
* @author Gavin King
*/
public class PrimaryKey extends Constraint {
public String sqlConstraintString(Dialect dialect) {
StringBuffer buf = new StringBuffer("primary key (");
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
buf.append( ( (Column) iter.next() ).getQuotedName(dialect) );
if ( iter.hasNext() ) buf.append(", ");
}
return buf.append(')').toString();
}
public String sqlConstraintString(Dialect dialect, String constraintName, String defaultCatalog, String defaultSchema) {
StringBuffer buf = new StringBuffer(
dialect.getAddPrimaryKeyConstraintString(constraintName)
).append('(');
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
buf.append( ( (Column) iter.next() ).getQuotedName(dialect) );
if ( iter.hasNext() ) buf.append(", ");
}
return buf.append(')').toString();
}
}