addField(type, sql);
}
// add a pk constraint
if (entityMetaData.hasPrimaryKeyConstraint()) {
JDBCFunctionMappingMetaData pkConstraint = manager.getMetaData().getTypeMapping().getPkConstraintTemplate();
if (pkConstraint == null) {
throw new IllegalStateException("Primary key constraint is " +
"not allowed for this type of data source");
}
String defTableName = entity.getManager().getMetaData().getDefaultTableName();
String name = "pk_" + SQLUtil.unquote(defTableName, dataSource);
name = SQLUtil.fixConstraintName(name, dataSource);
String[] args = new String[]{
name,
SQLUtil.getColumnNamesClause(entity.getPrimaryKeyFields(), new StringBuffer(100)).toString()
};
sql.append(SQLUtil.COMMA);
pkConstraint.getFunctionSql(args, sql);
}
return sql.append(')').toString();
}