All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.mapping.PrimaryKey Maven / Gradle / Ivy

There is a newer version: 3.6.0.Beta2
Show newest version
//$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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy