HHH-13823 Expose members of some SQL construction classes to subclasses
Allows hibernate-rx to more easily customize bind variable syntax.
This commit is contained in:
parent
12a8508e66
commit
a2f21e12a4
|
@ -16,13 +16,13 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class Delete {
|
public class Delete {
|
||||||
|
|
||||||
private String tableName;
|
protected String tableName;
|
||||||
private String versionColumnName;
|
protected String versionColumnName;
|
||||||
private String where;
|
protected String where;
|
||||||
|
protected String comment;
|
||||||
|
|
||||||
private Map primaryKeyColumns = new LinkedHashMap();
|
protected Map<String,String> primaryKeyColumns = new LinkedHashMap<>();
|
||||||
|
|
||||||
private String comment;
|
|
||||||
public Delete setComment(String comment) {
|
public Delete setComment(String comment) {
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
return this;
|
return this;
|
||||||
|
@ -43,9 +43,9 @@ public class Delete {
|
||||||
buf.append( " where " );
|
buf.append( " where " );
|
||||||
}
|
}
|
||||||
boolean conditionsAppended = false;
|
boolean conditionsAppended = false;
|
||||||
Iterator iter = primaryKeyColumns.entrySet().iterator();
|
Iterator<Map.Entry<String,String>> iter = primaryKeyColumns.entrySet().iterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
Map.Entry e = (Map.Entry) iter.next();
|
Map.Entry<String,String> e = iter.next();
|
||||||
buf.append( e.getKey() ).append( '=' ).append( e.getValue() );
|
buf.append( e.getKey() ).append( '=' ).append( e.getValue() );
|
||||||
if ( iter.hasNext() ) {
|
if ( iter.hasNext() ) {
|
||||||
buf.append( " and " );
|
buf.append( " and " );
|
||||||
|
|
|
@ -25,8 +25,8 @@ public class InFragment {
|
||||||
public static final String NULL = "null";
|
public static final String NULL = "null";
|
||||||
public static final String NOT_NULL = "not null";
|
public static final String NOT_NULL = "not null";
|
||||||
|
|
||||||
private String columnName;
|
protected String columnName;
|
||||||
private List<Object> values = new ArrayList<Object>();
|
protected List<Object> values = new ArrayList<Object>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param value an SQL literal, NULL, or NOT_NULL
|
* @param value an SQL literal, NULL, or NOT_NULL
|
||||||
|
|
|
@ -19,10 +19,13 @@ import org.hibernate.type.LiteralType;
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class Insert {
|
public class Insert {
|
||||||
|
|
||||||
|
protected String tableName;
|
||||||
|
protected String comment;
|
||||||
|
|
||||||
|
protected Map<String,String> columns = new LinkedHashMap<>();
|
||||||
|
|
||||||
private Dialect dialect;
|
private Dialect dialect;
|
||||||
private String tableName;
|
|
||||||
private String comment;
|
|
||||||
private Map columns = new LinkedHashMap();
|
|
||||||
|
|
||||||
public Insert(Dialect dialect) {
|
public Insert(Dialect dialect) {
|
||||||
this.dialect = dialect;
|
this.dialect = dialect;
|
||||||
|
@ -111,7 +114,7 @@ public class Insert {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf.append(" (");
|
buf.append(" (");
|
||||||
Iterator iter = columns.keySet().iterator();
|
Iterator<String> iter = columns.keySet().iterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
buf.append( iter.next() );
|
buf.append( iter.next() );
|
||||||
if ( iter.hasNext() ) {
|
if ( iter.hasNext() ) {
|
||||||
|
|
|
@ -18,10 +18,13 @@ import org.hibernate.dialect.Dialect;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class InsertSelect {
|
public class InsertSelect {
|
||||||
private String tableName;
|
|
||||||
private String comment;
|
protected String tableName;
|
||||||
private List columnNames = new ArrayList();
|
protected String comment;
|
||||||
private Select select;
|
|
||||||
|
protected List<String> columnNames = new ArrayList<>();
|
||||||
|
|
||||||
|
protected Select select;
|
||||||
|
|
||||||
public InsertSelect(Dialect dialect) {
|
public InsertSelect(Dialect dialect) {
|
||||||
//This is no longer used. Deprecate & remove?
|
//This is no longer used. Deprecate & remove?
|
||||||
|
@ -70,7 +73,7 @@ public class InsertSelect {
|
||||||
buf.append( "insert into " ).append( tableName );
|
buf.append( "insert into " ).append( tableName );
|
||||||
if ( !columnNames.isEmpty() ) {
|
if ( !columnNames.isEmpty() ) {
|
||||||
buf.append( " (" );
|
buf.append( " (" );
|
||||||
Iterator itr = columnNames.iterator();
|
Iterator<String> itr = columnNames.iterator();
|
||||||
while ( itr.hasNext() ) {
|
while ( itr.hasNext() ) {
|
||||||
buf.append( itr.next() );
|
buf.append( itr.next() );
|
||||||
if ( itr.hasNext() ) {
|
if ( itr.hasNext() ) {
|
||||||
|
|
|
@ -17,15 +17,17 @@ import org.hibernate.internal.util.StringHelper;
|
||||||
*/
|
*/
|
||||||
public class Select {
|
public class Select {
|
||||||
|
|
||||||
private String selectClause;
|
protected String selectClause;
|
||||||
private String fromClause;
|
protected String fromClause;
|
||||||
private String outerJoinsAfterFrom;
|
protected String outerJoinsAfterFrom;
|
||||||
private String whereClause;
|
protected String whereClause;
|
||||||
private String outerJoinsAfterWhere;
|
protected String outerJoinsAfterWhere;
|
||||||
private String orderByClause;
|
protected String orderByClause;
|
||||||
private String groupByClause;
|
protected String groupByClause;
|
||||||
private String comment;
|
protected String comment;
|
||||||
private LockOptions lockOptions = new LockOptions();
|
|
||||||
|
protected LockOptions lockOptions = new LockOptions();
|
||||||
|
|
||||||
public final Dialect dialect;
|
public final Dialect dialect;
|
||||||
|
|
||||||
private int guesstimatedBufferSize = 20;
|
private int guesstimatedBufferSize = 20;
|
||||||
|
|
|
@ -31,15 +31,18 @@ public class SimpleSelect {
|
||||||
|
|
||||||
//private static final Alias DEFAULT_ALIAS = new Alias(10, null);
|
//private static final Alias DEFAULT_ALIAS = new Alias(10, null);
|
||||||
|
|
||||||
private String tableName;
|
protected String tableName;
|
||||||
private String orderBy;
|
protected String orderBy;
|
||||||
private Dialect dialect;
|
protected String comment;
|
||||||
private LockOptions lockOptions = new LockOptions( LockMode.READ );
|
|
||||||
private String comment;
|
protected List<String> columns = new ArrayList<String>();
|
||||||
|
protected Map<String, String> aliases = new HashMap<String, String>();
|
||||||
|
protected List<String> whereTokens = new ArrayList<String>();
|
||||||
|
|
||||||
|
protected LockOptions lockOptions = new LockOptions( LockMode.READ );
|
||||||
|
|
||||||
|
private Dialect dialect;
|
||||||
|
|
||||||
private List<String> columns = new ArrayList<String>();
|
|
||||||
private Map<String, String> aliases = new HashMap<String, String>();
|
|
||||||
private List<String> whereTokens = new ArrayList<String>();
|
|
||||||
|
|
||||||
public SimpleSelect addColumns(String[] columnNames, String[] columnAliases) {
|
public SimpleSelect addColumns(String[] columnNames, String[] columnAliases) {
|
||||||
for ( int i = 0; i < columnNames.length; i++ ) {
|
for ( int i = 0; i < columnNames.length; i++ ) {
|
||||||
|
|
|
@ -19,15 +19,15 @@ import org.hibernate.type.LiteralType;
|
||||||
*/
|
*/
|
||||||
public class Update {
|
public class Update {
|
||||||
|
|
||||||
private String tableName;
|
protected String tableName;
|
||||||
private String versionColumnName;
|
protected String versionColumnName;
|
||||||
private String where;
|
protected String where;
|
||||||
private String assignments;
|
protected String assignments;
|
||||||
private String comment;
|
protected String comment;
|
||||||
|
|
||||||
private Map primaryKeyColumns = new LinkedHashMap();
|
protected Map<String,String> primaryKeyColumns = new LinkedHashMap<>();
|
||||||
private Map columns = new LinkedHashMap();
|
protected Map<String,String> columns = new LinkedHashMap<>();
|
||||||
private Map whereColumns = new LinkedHashMap();
|
protected Map<String,String> whereColumns = new LinkedHashMap<>();
|
||||||
|
|
||||||
private Dialect dialect;
|
private Dialect dialect;
|
||||||
|
|
||||||
|
@ -170,9 +170,9 @@ public class Update {
|
||||||
}
|
}
|
||||||
buf.append( "update " ).append( tableName ).append( " set " );
|
buf.append( "update " ).append( tableName ).append( " set " );
|
||||||
boolean assignmentsAppended = false;
|
boolean assignmentsAppended = false;
|
||||||
Iterator iter = columns.entrySet().iterator();
|
Iterator<Map.Entry<String,String>> iter = columns.entrySet().iterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
Map.Entry e = (Map.Entry) iter.next();
|
Map.Entry<String,String> e = iter.next();
|
||||||
buf.append( e.getKey() ).append( '=' ).append( e.getValue() );
|
buf.append( e.getKey() ).append( '=' ).append( e.getValue() );
|
||||||
if ( iter.hasNext() ) {
|
if ( iter.hasNext() ) {
|
||||||
buf.append( ", " );
|
buf.append( ", " );
|
||||||
|
@ -192,7 +192,7 @@ public class Update {
|
||||||
}
|
}
|
||||||
iter = primaryKeyColumns.entrySet().iterator();
|
iter = primaryKeyColumns.entrySet().iterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
Map.Entry e = (Map.Entry) iter.next();
|
Map.Entry<String,String> e = iter.next();
|
||||||
buf.append( e.getKey() ).append( '=' ).append( e.getValue() );
|
buf.append( e.getKey() ).append( '=' ).append( e.getValue() );
|
||||||
if ( iter.hasNext() ) {
|
if ( iter.hasNext() ) {
|
||||||
buf.append( " and " );
|
buf.append( " and " );
|
||||||
|
@ -208,7 +208,7 @@ public class Update {
|
||||||
}
|
}
|
||||||
iter = whereColumns.entrySet().iterator();
|
iter = whereColumns.entrySet().iterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
final Map.Entry e = (Map.Entry) iter.next();
|
final Map.Entry<String,String> e = iter.next();
|
||||||
if ( conditionsAppended ) {
|
if ( conditionsAppended ) {
|
||||||
buf.append( " and " );
|
buf.append( " and " );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue