org.hibernate.sql.Insert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
JPMS Module-Info's for a few of the Jakarta Libraries just until they add them in themselves
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.sql;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.LiteralType;
/**
* An SQL INSERT statement
*
* @author Gavin King
*/
public class Insert {
protected String tableName;
protected String comment;
protected Map columns = new LinkedHashMap<>();
private Dialect dialect;
public Insert(Dialect dialect) {
this.dialect = dialect;
}
protected Dialect getDialect() {
return dialect;
}
public Insert setComment(String comment) {
this.comment = comment;
return this;
}
public Insert addColumn(String columnName) {
return addColumn( columnName, "?" );
}
public Insert addColumns(String[] columnNames) {
for ( String columnName : columnNames ) {
addColumn( columnName );
}
return this;
}
public Insert addColumns(String[] columnNames, boolean[] insertable) {
for ( int i=0; i iter = columns.keySet().iterator();
while ( iter.hasNext() ) {
buf.append( iter.next() );
if ( iter.hasNext() ) {
buf.append( ", " );
}
}
buf.append(") values (");
iter = columns.values().iterator();
while ( iter.hasNext() ) {
buf.append( iter.next() );
if ( iter.hasNext() ) {
buf.append( ", " );
}
}
buf.append(')');
}
return buf.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy