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

org.hibernate.sql.Update Maven / Gradle / Ivy

There is a newer version: 3.6.0.Beta2
Show newest version
//$Id: Update.java 7825 2005-08-10 20:23:55Z oneovthafew $
package org.hibernate.sql;

import java.util.Iterator;
import java.util.Map;

import org.hibernate.dialect.Dialect;
import org.hibernate.type.LiteralType;
import org.hibernate.util.StringHelper;

import org.apache.commons.collections.SequencedHashMap;

/**
 * An SQL UPDATE statement
 *
 * @author Gavin King
 */
public class Update {

	private String tableName;
	private String[] primaryKeyColumnNames;
	private String versionColumnName;
	private String where;
	private String assignments;
	private String comment;

	private Map columns = new SequencedHashMap();
	private Map whereColumns = new SequencedHashMap();
	
	private Dialect dialect;
	
	public Update(Dialect dialect) {
		this.dialect = dialect;
	}

	public String getTableName() {
		return tableName;
	}

	public Update appendAssignmentFragment(String fragment) {
		if ( assignments == null ) {
			assignments = fragment;
		}
		else {
			assignments += ", " + fragment;
		}
		return this;
	}

	public Update setTableName(String tableName) {
		this.tableName = tableName;
		return this;
	}

	public Update setPrimaryKeyColumnNames(String[] primaryKeyColumnNames) {
		this.primaryKeyColumnNames = primaryKeyColumnNames;
		return this;
	}

	public Update setVersionColumnName(String versionColumnName) {
		this.versionColumnName = versionColumnName;
		return this;
	}


	public Update setComment(String comment) {
		this.comment = comment;
		return this;
	}

	public Update addColumns(String[] columnNames) {
		for ( int i=0; i


© 2015 - 2024 Weber Informatics LLC | Privacy Policy