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:
gavinking 2020-01-19 19:43:30 +01:00 committed by Sanne Grinovero
parent 12a8508e66
commit a2f21e12a4
7 changed files with 59 additions and 48 deletions

View File

@ -16,13 +16,13 @@ import java.util.Map;
*/
public class Delete {
private String tableName;
private String versionColumnName;
private String where;
protected String tableName;
protected String versionColumnName;
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) {
this.comment = comment;
return this;
@ -43,9 +43,9 @@ public class Delete {
buf.append( " where " );
}
boolean conditionsAppended = false;
Iterator iter = primaryKeyColumns.entrySet().iterator();
Iterator<Map.Entry<String,String>> iter = primaryKeyColumns.entrySet().iterator();
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() );
if ( iter.hasNext() ) {
buf.append( " and " );

View File

@ -25,8 +25,8 @@ public class InFragment {
public static final String NULL = "null";
public static final String NOT_NULL = "not null";
private String columnName;
private List<Object> values = new ArrayList<Object>();
protected String columnName;
protected List<Object> values = new ArrayList<Object>();
/**
* @param value an SQL literal, NULL, or NOT_NULL

View File

@ -19,10 +19,13 @@ import org.hibernate.type.LiteralType;
* @author Gavin King
*/
public class Insert {
protected String tableName;
protected String comment;
protected Map<String,String> columns = new LinkedHashMap<>();
private Dialect dialect;
private String tableName;
private String comment;
private Map columns = new LinkedHashMap();
public Insert(Dialect dialect) {
this.dialect = dialect;
@ -111,7 +114,7 @@ public class Insert {
}
else {
buf.append(" (");
Iterator iter = columns.keySet().iterator();
Iterator<String> iter = columns.keySet().iterator();
while ( iter.hasNext() ) {
buf.append( iter.next() );
if ( iter.hasNext() ) {

View File

@ -18,10 +18,13 @@ import org.hibernate.dialect.Dialect;
* @author Steve Ebersole
*/
public class InsertSelect {
private String tableName;
private String comment;
private List columnNames = new ArrayList();
private Select select;
protected String tableName;
protected String comment;
protected List<String> columnNames = new ArrayList<>();
protected Select select;
public InsertSelect(Dialect dialect) {
//This is no longer used. Deprecate & remove?
@ -70,7 +73,7 @@ public class InsertSelect {
buf.append( "insert into " ).append( tableName );
if ( !columnNames.isEmpty() ) {
buf.append( " (" );
Iterator itr = columnNames.iterator();
Iterator<String> itr = columnNames.iterator();
while ( itr.hasNext() ) {
buf.append( itr.next() );
if ( itr.hasNext() ) {

View File

@ -17,15 +17,17 @@ import org.hibernate.internal.util.StringHelper;
*/
public class Select {
private String selectClause;
private String fromClause;
private String outerJoinsAfterFrom;
private String whereClause;
private String outerJoinsAfterWhere;
private String orderByClause;
private String groupByClause;
private String comment;
private LockOptions lockOptions = new LockOptions();
protected String selectClause;
protected String fromClause;
protected String outerJoinsAfterFrom;
protected String whereClause;
protected String outerJoinsAfterWhere;
protected String orderByClause;
protected String groupByClause;
protected String comment;
protected LockOptions lockOptions = new LockOptions();
public final Dialect dialect;
private int guesstimatedBufferSize = 20;

View File

@ -31,15 +31,18 @@ public class SimpleSelect {
//private static final Alias DEFAULT_ALIAS = new Alias(10, null);
private String tableName;
private String orderBy;
private Dialect dialect;
private LockOptions lockOptions = new LockOptions( LockMode.READ );
private String comment;
protected String tableName;
protected String orderBy;
protected 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) {
for ( int i = 0; i < columnNames.length; i++ ) {

View File

@ -19,15 +19,15 @@ import org.hibernate.type.LiteralType;
*/
public class Update {
private String tableName;
private String versionColumnName;
private String where;
private String assignments;
private String comment;
protected String tableName;
protected String versionColumnName;
protected String where;
protected String assignments;
protected String comment;
private Map primaryKeyColumns = new LinkedHashMap();
private Map columns = new LinkedHashMap();
private Map whereColumns = new LinkedHashMap();
protected Map<String,String> primaryKeyColumns = new LinkedHashMap<>();
protected Map<String,String> columns = new LinkedHashMap<>();
protected Map<String,String> whereColumns = new LinkedHashMap<>();
private Dialect dialect;
@ -170,9 +170,9 @@ public class Update {
}
buf.append( "update " ).append( tableName ).append( " set " );
boolean assignmentsAppended = false;
Iterator iter = columns.entrySet().iterator();
Iterator<Map.Entry<String,String>> iter = columns.entrySet().iterator();
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() );
if ( iter.hasNext() ) {
buf.append( ", " );
@ -192,7 +192,7 @@ public class Update {
}
iter = primaryKeyColumns.entrySet().iterator();
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() );
if ( iter.hasNext() ) {
buf.append( " and " );
@ -208,7 +208,7 @@ public class Update {
}
iter = whereColumns.entrySet().iterator();
while ( iter.hasNext() ) {
final Map.Entry e = (Map.Entry) iter.next();
final Map.Entry<String,String> e = iter.next();
if ( conditionsAppended ) {
buf.append( " and " );
}