idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
147,100
public Where < T , ID > raw ( String rawStatement , ArgumentHolder ... args ) { for ( ArgumentHolder arg : args ) { String columnName = arg . getColumnName ( ) ; if ( columnName == null ) { if ( arg . getSqlType ( ) == null ) { throw new IllegalArgumentException ( "Either the column name or SqlType must be set on each ...
Add a raw statement as part of the where that can be anything that the database supports . Using more structured methods is recommended but this gives more control over the query and allows you to utilize database specific features .
147,101
public Where < T , ID > rawComparison ( String columnName , String rawOperator , Object value ) throws SQLException { addClause ( new SimpleComparison ( columnName , findColumnFieldType ( columnName ) , value , rawOperator ) ) ; return this ; }
Make a comparison where the operator is specified by the caller . It is up to the caller to specify an appropriate operator for the database and that it be formatted correctly .
147,102
public Where < T , ID > reset ( ) { for ( int i = 0 ; i < clauseStackLevel ; i ++ ) { clauseStack [ i ] = null ; } clauseStackLevel = 0 ; return this ; }
Reset the Where object so it can be re - used .
147,103
public String getStatement ( ) throws SQLException { StringBuilder sb = new StringBuilder ( ) ; appendSql ( null , sb , new ArrayList < ArgumentHolder > ( ) ) ; return sb . toString ( ) ; }
Returns the associated SQL WHERE statement .
147,104
public int execute ( DatabaseConnection databaseConnection , T data , ID newId , ObjectCache objectCache ) throws SQLException { try { Object [ ] args = new Object [ ] { convertIdToFieldObject ( newId ) , extractIdToFieldObject ( data ) } ; int rowC = databaseConnection . update ( statement , args , argFieldTypes ) ; i...
Update the id field of the object in the database .
147,105
public static DatabaseFieldConfig fromReader ( BufferedReader reader ) throws SQLException { DatabaseFieldConfig config = new DatabaseFieldConfig ( ) ; boolean anything = false ; while ( true ) { String line ; try { line = reader . readLine ( ) ; } catch ( IOException e ) { throw SqlExceptionUtil . create ( "Could not ...
Load a configuration in from a text file .
147,106
public static void write ( BufferedWriter writer , DatabaseFieldConfig config , String tableName ) throws SQLException { try { writeConfig ( writer , config , tableName ) ; } catch ( IOException e ) { throw SqlExceptionUtil . create ( "Could not write config to writer" , e ) ; } }
Write the configuration to a buffered writer .
147,107
public UpdateBuilder < T , ID > updateColumnValue ( String columnName , Object value ) throws SQLException { FieldType fieldType = verifyColumnName ( columnName ) ; if ( fieldType . isForeignCollection ( ) ) { throw new SQLException ( "Can't update foreign colletion field: " + columnName ) ; } addUpdateColumnToList ( c...
Add a column to be set to a value for UPDATE statements . This will generate something like columnName = value with the value escaped if necessary .
147,108
public UpdateBuilder < T , ID > updateColumnExpression ( String columnName , String expression ) throws SQLException { FieldType fieldType = verifyColumnName ( columnName ) ; if ( fieldType . isForeignCollection ( ) ) { throw new SQLException ( "Can't update foreign colletion field: " + columnName ) ; } addUpdateColumn...
Add a column to be set to a value for UPDATE statements . This will generate something like columnName = expression where the expression is built by the caller .
147,109
public void initialize ( ) { if ( dataClass == null ) { throw new IllegalStateException ( "dataClass was never set on " + getClass ( ) . getSimpleName ( ) ) ; } if ( tableName == null ) { tableName = extractTableName ( databaseType , dataClass ) ; } }
Initialize the class if this is being called with Spring .
147,110
public void extractFieldTypes ( DatabaseType databaseType ) throws SQLException { if ( fieldTypes == null ) { if ( fieldConfigs == null ) { fieldTypes = extractFieldTypes ( databaseType , dataClass , tableName ) ; } else { fieldTypes = convertFieldConfigs ( databaseType , tableName , fieldConfigs ) ; } } }
Extract the field types from the fieldConfigs if they have not already been configured .
147,111
public static < T > DatabaseTableConfig < T > fromClass ( DatabaseType databaseType , Class < T > clazz ) throws SQLException { String tableName = extractTableName ( databaseType , clazz ) ; if ( databaseType . isEntityNamesMustBeUpCase ( ) ) { tableName = databaseType . upCaseEntityName ( tableName ) ; } return new Da...
Extract the DatabaseTableConfig for a particular class by looking for class and field annotations . This is used by internal classes to configure a class .
147,112
public static < T > String extractTableName ( DatabaseType databaseType , Class < T > clazz ) { DatabaseTable databaseTable = clazz . getAnnotation ( DatabaseTable . class ) ; String name = null ; if ( databaseTable != null && databaseTable . tableName ( ) != null && databaseTable . tableName ( ) . length ( ) > 0 ) { n...
Extract and return the table name for a class .
147,113
public static void openLogFile ( String logPath ) { if ( logPath == null ) { printStream = System . out ; } else { try { printStream = new PrintStream ( new File ( logPath ) ) ; } catch ( FileNotFoundException e ) { throw new IllegalArgumentException ( "Log file " + logPath + " was not found" , e ) ; } } }
Reopen the associated static logging stream . Set to null to redirect to System . out .
147,114
public long queryForCountStar ( DatabaseConnection databaseConnection ) throws SQLException { if ( countStarQuery == null ) { StringBuilder sb = new StringBuilder ( 64 ) ; sb . append ( "SELECT COUNT(*) FROM " ) ; databaseType . appendEscapedEntityName ( sb , tableInfo . getTableName ( ) ) ; countStarQuery = sb . toStr...
Return a long value which is the number of rows in the table .
147,115
public long queryForLong ( DatabaseConnection databaseConnection , PreparedStmt < T > preparedStmt ) throws SQLException { CompiledStatement compiledStatement = preparedStmt . compile ( databaseConnection , StatementType . SELECT_LONG ) ; DatabaseResults results = null ; try { results = compiledStatement . runQuery ( n...
Return a long value from a prepared query .
147,116
public SelectIterator < T , ID > buildIterator ( BaseDaoImpl < T , ID > classDao , ConnectionSource connectionSource , int resultFlags , ObjectCache objectCache ) throws SQLException { prepareQueryForAll ( ) ; return buildIterator ( classDao , connectionSource , preparedQueryForAll , objectCache , resultFlags ) ; }
Create and return a SelectIterator for the class using the default mapped query for all statement .
147,117
public int updateRaw ( DatabaseConnection connection , String statement , String [ ] arguments ) throws SQLException { logger . debug ( "running raw update statement: {}" , statement ) ; if ( arguments . length > 0 ) { logger . trace ( "update arguments: {}" , ( Object ) arguments ) ; } CompiledStatement compiledStatem...
Return the number of rows affected .
147,118
public int create ( DatabaseConnection databaseConnection , T data , ObjectCache objectCache ) throws SQLException { if ( mappedInsert == null ) { mappedInsert = MappedCreate . build ( dao , tableInfo ) ; } int result = mappedInsert . insert ( databaseType , databaseConnection , data , objectCache ) ; if ( dao != null ...
Create a new entry in the database from an object .
147,119
public int updateId ( DatabaseConnection databaseConnection , T data , ID newId , ObjectCache objectCache ) throws SQLException { if ( mappedUpdateId == null ) { mappedUpdateId = MappedUpdateId . build ( dao , tableInfo ) ; } int result = mappedUpdateId . execute ( databaseConnection , data , newId , objectCache ) ; if...
Update an object in the database to change its id to the newId parameter .
147,120
public int update ( DatabaseConnection databaseConnection , PreparedUpdate < T > preparedUpdate ) throws SQLException { CompiledStatement compiledStatement = preparedUpdate . compile ( databaseConnection , StatementType . UPDATE ) ; try { int result = compiledStatement . runUpdate ( ) ; if ( dao != null && ! localIsInB...
Update rows in the database .
147,121
public int refresh ( DatabaseConnection databaseConnection , T data , ObjectCache objectCache ) throws SQLException { if ( mappedRefresh == null ) { mappedRefresh = MappedRefresh . build ( dao , tableInfo ) ; } return mappedRefresh . executeRefresh ( databaseConnection , data , objectCache ) ; }
Does a query for the object s Id and copies in each of the field values from the database to refresh the data parameter .
147,122
public int delete ( DatabaseConnection databaseConnection , T data , ObjectCache objectCache ) throws SQLException { if ( mappedDelete == null ) { mappedDelete = MappedDelete . build ( dao , tableInfo ) ; } int result = mappedDelete . delete ( databaseConnection , data , objectCache ) ; if ( dao != null && ! localIsInB...
Delete an object from the database .
147,123
public int deleteById ( DatabaseConnection databaseConnection , ID id , ObjectCache objectCache ) throws SQLException { if ( mappedDelete == null ) { mappedDelete = MappedDelete . build ( dao , tableInfo ) ; } int result = mappedDelete . deleteById ( databaseConnection , id , objectCache ) ; if ( dao != null && ! local...
Delete an object from the database by id .
147,124
public int delete ( DatabaseConnection databaseConnection , PreparedDelete < T > preparedDelete ) throws SQLException { CompiledStatement compiledStatement = preparedDelete . compile ( databaseConnection , StatementType . DELETE ) ; try { int result = compiledStatement . runUpdate ( ) ; if ( dao != null && ! localIsInB...
Delete rows that match the prepared statement .
147,125
public < CT > CT callBatchTasks ( ConnectionSource connectionSource , Callable < CT > callable ) throws SQLException { if ( connectionSource . isSingleConnection ( tableInfo . getTableName ( ) ) ) { synchronized ( this ) { return doCallBatchTasks ( connectionSource , callable ) ; } } else { return doCallBatchTasks ( co...
Call batch tasks inside of a connection which may or may not have been saved .
147,126
public static SQLException create ( String message , Throwable cause ) { SQLException sqlException ; if ( cause instanceof SQLException ) { sqlException = new SQLException ( message , ( ( SQLException ) cause ) . getSQLState ( ) ) ; } else { sqlException = new SQLException ( message ) ; } sqlException . initCause ( cau...
Convenience method to allow a cause . Grrrr .
147,127
public void initialize ( ) throws SQLException { if ( initialized ) { return ; } if ( connectionSource == null ) { throw new IllegalStateException ( "connectionSource was never set on " + getClass ( ) . getSimpleName ( ) ) ; } databaseType = connectionSource . getDatabaseType ( ) ; if ( databaseType == null ) { throw n...
Initialize the various DAO configurations after the various setters have been called .
147,128
static < T , ID > Dao < T , ID > createDao ( ConnectionSource connectionSource , Class < T > clazz ) throws SQLException { return new BaseDaoImpl < T , ID > ( connectionSource , clazz ) { } ; }
Helper method to create a Dao object without having to define a class . Dao classes are supposed to be convenient but if you have a lot of classes they can seem to be a pain .
147,129
private Constructor < T > findNoArgConstructor ( Class < T > dataClass ) { Constructor < T > [ ] constructors ; try { @ SuppressWarnings ( "unchecked" ) Constructor < T > [ ] consts = ( Constructor < T > [ ] ) dataClass . getDeclaredConstructors ( ) ; constructors = consts ; } catch ( Exception e ) { throw new IllegalA...
Locate the no arg constructor for the class .
147,130
public static Method findGetMethod ( Field field , DatabaseType databaseType , boolean throwExceptions ) throws IllegalArgumentException { Method fieldGetMethod = findMethodFromNames ( field , true , throwExceptions , methodFromField ( field , "get" , databaseType , true ) , methodFromField ( field , "get" , databaseTy...
Find and return the appropriate getter method for field .
147,131
public static Method findSetMethod ( Field field , DatabaseType databaseType , boolean throwExceptions ) throws IllegalArgumentException { Method fieldSetMethod = findMethodFromNames ( field , false , throwExceptions , methodFromField ( field , "set" , databaseType , true ) , methodFromField ( field , "set" , databaseT...
Find and return the appropriate setter method for field .
147,132
public void postProcess ( ) { if ( foreignColumnName != null ) { foreignAutoRefresh = true ; } if ( foreignAutoRefresh && maxForeignAutoRefreshLevel == NO_MAX_FOREIGN_AUTO_REFRESH_LEVEL_SPECIFIED ) { maxForeignAutoRefreshLevel = DatabaseField . DEFAULT_MAX_FOREIGN_AUTO_REFRESH_LEVEL ; } }
Process the settings when we are going to consume them .
147,133
public static Enum < ? > findMatchingEnumVal ( Field field , String unknownEnumName ) { if ( unknownEnumName == null || unknownEnumName . length ( ) == 0 ) { return null ; } for ( Enum < ? > enumVal : ( Enum < ? > [ ] ) field . getType ( ) . getEnumConstants ( ) ) { if ( enumVal . name ( ) . equals ( unknownEnumName ) ...
Internal method that finds the matching enum for a configured field that has the name argument .
147,134
public int executeRefresh ( DatabaseConnection databaseConnection , T data , ObjectCache objectCache ) throws SQLException { @ SuppressWarnings ( "unchecked" ) ID id = ( ID ) idField . extractJavaFieldValue ( data ) ; T result = super . execute ( databaseConnection , id , null ) ; if ( result == null ) { return 0 ; } f...
Execute our refresh query statement and then update all of the fields in data with the fields from the result .
147,135
public QueryBuilder < T , ID > selectColumns ( String ... columns ) { for ( String column : columns ) { addSelectColumnToList ( column ) ; } return this ; }
Add columns to be returned by the SELECT query . If no columns are selected then all columns are returned by default . For classes with id columns the id column is added to the select list automagically . This can be called multiple times to add more columns to select .
147,136
public QueryBuilder < T , ID > groupBy ( String columnName ) { FieldType fieldType = verifyColumnName ( columnName ) ; if ( fieldType . isForeignCollection ( ) ) { throw new IllegalArgumentException ( "Can't groupBy foreign collection field: " + columnName ) ; } addGroupBy ( ColumnNameOrRawSql . withColumnName ( column...
Add GROUP BY clause to the SQL query statement . This can be called multiple times to add additional GROUP BY clauses .
147,137
public QueryBuilder < T , ID > groupByRaw ( String rawSql ) { addGroupBy ( ColumnNameOrRawSql . withRawSql ( rawSql ) ) ; return this ; }
Add a raw SQL GROUP BY clause to the SQL query statement . This should not include the GROUP BY .
147,138
public QueryBuilder < T , ID > orderBy ( String columnName , boolean ascending ) { FieldType fieldType = verifyColumnName ( columnName ) ; if ( fieldType . isForeignCollection ( ) ) { throw new IllegalArgumentException ( "Can't orderBy foreign collection field: " + columnName ) ; } addOrderBy ( new OrderBy ( columnName...
Add ORDER BY clause to the SQL query statement . This can be called multiple times to add additional ORDER BY clauses . Ones earlier are applied first .
147,139
public QueryBuilder < T , ID > orderByRaw ( String rawSql ) { addOrderBy ( new OrderBy ( rawSql , ( ArgumentHolder [ ] ) null ) ) ; return this ; }
Add raw SQL ORDER BY clause to the SQL query statement .
147,140
public QueryBuilder < T , ID > join ( QueryBuilder < ? , ? > joinedQueryBuilder ) throws SQLException { addJoinInfo ( JoinType . INNER , null , null , joinedQueryBuilder , JoinWhereOperation . AND ) ; return this ; }
Join with another query builder . This will add into the SQL something close to INNER JOIN other - table ... . Either the object associated with the current QueryBuilder or the argument QueryBuilder must have a foreign field of the other one . An exception will be thrown otherwise .
147,141
private void addJoinInfo ( JoinType type , String localColumnName , String joinedColumnName , QueryBuilder < ? , ? > joinedQueryBuilder , JoinWhereOperation operation ) throws SQLException { JoinInfo joinInfo = new JoinInfo ( type , joinedQueryBuilder , operation ) ; if ( localColumnName == null ) { matchJoinedFields (...
Add join info to the query . This can be called multiple times to join with more than one table .
147,142
public String objectToString ( T object ) { StringBuilder sb = new StringBuilder ( 64 ) ; sb . append ( object . getClass ( ) . getSimpleName ( ) ) ; for ( FieldType fieldType : fieldTypes ) { sb . append ( ' ' ) . append ( fieldType . getColumnName ( ) ) . append ( '=' ) ; try { sb . append ( fieldType . extractJavaFi...
Return a string representation of the object .
147,143
private static void logVersionWarnings ( String label1 , String version1 , String label2 , String version2 ) { if ( version1 == null ) { if ( version2 != null ) { warning ( null , "Unknown version" , " for {}, version for {} is '{}'" , new Object [ ] { label1 , label2 , version2 } ) ; } } else { if ( version2 == null )...
Log error information
147,144
protected MappedPreparedStmt < T , ID > prepareStatement ( Long limit , boolean cacheStore ) throws SQLException { List < ArgumentHolder > argList = new ArrayList < ArgumentHolder > ( ) ; String statement = buildStatementString ( argList ) ; ArgumentHolder [ ] selectArgs = argList . toArray ( new ArgumentHolder [ argLi...
Prepare our statement for the subclasses .
147,145
public String prepareStatementString ( ) throws SQLException { List < ArgumentHolder > argList = new ArrayList < ArgumentHolder > ( ) ; return buildStatementString ( argList ) ; }
Build and return a string version of the query . If you change the where or make other calls you will need to re - call this method to re - prepare the query for execution .
147,146
protected boolean appendWhereStatement ( StringBuilder sb , List < ArgumentHolder > argList , WhereOperation operation ) throws SQLException { if ( where == null ) { return operation == WhereOperation . FIRST ; } operation . appendBefore ( sb ) ; where . appendSql ( ( addTableName ? getTableName ( ) : null ) , sb , arg...
Append the WHERE part of the statement to the StringBuilder .
147,147
private static < T , ID > MappedDeleteCollection < T , ID > build ( Dao < T , ID > dao , TableInfo < T , ID > tableInfo , int dataSize ) throws SQLException { FieldType idField = tableInfo . getIdField ( ) ; if ( idField == null ) { throw new SQLException ( "Cannot delete " + tableInfo . getDataClass ( ) + " because it...
This is private because the execute is the only method that should be called here .
147,148
public T next ( ) { SQLException sqlException = null ; try { T result = nextThrow ( ) ; if ( result != null ) { return result ; } } catch ( SQLException e ) { sqlException = e ; } last = null ; closeQuietly ( ) ; throw new IllegalStateException ( "Could not get next result for " + dataClass , sqlException ) ; }
Returns the next object in the table .
147,149
public static < T > int createTable ( ConnectionSource connectionSource , Class < T > dataClass ) throws SQLException { Dao < T , ? > dao = DaoManager . createDao ( connectionSource , dataClass ) ; return doCreateTable ( dao , false ) ; }
Issue the database statements to create the table associated with a class .
147,150
public static < T > int createTable ( ConnectionSource connectionSource , DatabaseTableConfig < T > tableConfig ) throws SQLException { Dao < T , ? > dao = DaoManager . createDao ( connectionSource , tableConfig ) ; return doCreateTable ( dao , false ) ; }
Issue the database statements to create the table associated with a table configuration .
147,151
public static < T , ID > int dropTable ( ConnectionSource connectionSource , Class < T > dataClass , boolean ignoreErrors ) throws SQLException { Dao < T , ID > dao = DaoManager . createDao ( connectionSource , dataClass ) ; return dropTable ( dao , ignoreErrors ) ; }
Issue the database statements to drop the table associated with a class .
147,152
public static < T , ID > int dropTable ( Dao < T , ID > dao , boolean ignoreErrors ) throws SQLException { ConnectionSource connectionSource = dao . getConnectionSource ( ) ; Class < T > dataClass = dao . getDataClass ( ) ; DatabaseType databaseType = connectionSource . getDatabaseType ( ) ; if ( dao instanceof BaseDao...
Issue the database statements to drop the table associated with a dao .
147,153
public static < T , ID > int dropTable ( ConnectionSource connectionSource , DatabaseTableConfig < T > tableConfig , boolean ignoreErrors ) throws SQLException { DatabaseType databaseType = connectionSource . getDatabaseType ( ) ; Dao < T , ID > dao = DaoManager . createDao ( connectionSource , tableConfig ) ; if ( dao...
Issue the database statements to drop the table associated with a table configuration .
147,154
private static < T , ID > void addDropTableStatements ( DatabaseType databaseType , TableInfo < T , ID > tableInfo , List < String > statements , boolean logDetails ) { List < String > statementsBefore = new ArrayList < String > ( ) ; List < String > statementsAfter = new ArrayList < String > ( ) ; for ( FieldType fiel...
Generate and return the list of statements to drop a database table .
147,155
private static < T , ID > void addCreateTableStatements ( DatabaseType databaseType , TableInfo < T , ID > tableInfo , List < String > statements , List < String > queriesAfter , boolean ifNotExists , boolean logDetails ) throws SQLException { StringBuilder sb = new StringBuilder ( 256 ) ; if ( logDetails ) { logger . ...
Generate and return the list of statements to create a database table and any associated features .
147,156
public void assignField ( ConnectionSource connectionSource , Object data , Object val , boolean parentObject , ObjectCache objectCache ) throws SQLException { if ( logger . isLevelEnabled ( Level . TRACE ) ) { logger . trace ( "assiging from data {}, val {}: {}" , ( data == null ? "null" : data . getClass ( ) ) , ( va...
Assign to the data object the val corresponding to the fieldType .
147,157
public Object assignIdValue ( ConnectionSource connectionSource , Object data , Number val , ObjectCache objectCache ) throws SQLException { Object idVal = dataPersister . convertIdNumber ( val ) ; if ( idVal == null ) { throw new SQLException ( "Invalid class " + dataPersister + " for sequence-id " + this ) ; } else {...
Assign an ID value to this field .
147,158
public < FV > FV extractRawJavaFieldValue ( Object object ) throws SQLException { Object val ; if ( fieldGetMethod == null ) { try { val = field . get ( object ) ; } catch ( Exception e ) { throw SqlExceptionUtil . create ( "Could not get field value for " + this , e ) ; } } else { try { val = fieldGetMethod . invoke (...
Return the value from the field in the object that is defined by this FieldType .
147,159
public Object extractJavaFieldValue ( Object object ) throws SQLException { Object val = extractRawJavaFieldValue ( object ) ; if ( foreignRefField != null && val != null ) { val = foreignRefField . extractRawJavaFieldValue ( val ) ; } return val ; }
Return the value from the field in the object that is defined by this FieldType . If the field is a foreign object then the ID of the field is returned instead .
147,160
public Object convertJavaFieldToSqlArgValue ( Object fieldVal ) throws SQLException { if ( fieldVal == null ) { return null ; } else { return fieldConverter . javaToSqlArg ( this , fieldVal ) ; } }
Convert a field value to something suitable to be stored in the database .
147,161
public Object convertStringToJavaField ( String value , int columnPos ) throws SQLException { if ( value == null ) { return null ; } else { return fieldConverter . resultStringToJava ( this , value , columnPos ) ; } }
Convert a string value into the appropriate Java field value .
147,162
public Object moveToNextValue ( Object val ) throws SQLException { if ( dataPersister == null ) { return null ; } else { return dataPersister . moveToNextValue ( val ) ; } }
Move the SQL value to the next one for version processing .
147,163
public < FT , FID > BaseForeignCollection < FT , FID > buildForeignCollection ( Object parent , FID id ) throws SQLException { if ( foreignFieldType == null ) { return null ; } @ SuppressWarnings ( "unchecked" ) Dao < FT , FID > castDao = ( Dao < FT , FID > ) foreignDao ; if ( ! fieldConfig . isForeignCollectionEager (...
Build and return a foreign collection based on the field settings that matches the id argument . This can return null in certain circumstances .
147,164
public < FV > FV getFieldValueIfNotDefault ( Object object ) throws SQLException { @ SuppressWarnings ( "unchecked" ) FV fieldValue = ( FV ) extractJavaFieldValue ( object ) ; if ( isFieldValueDefault ( fieldValue ) ) { return null ; } else { return fieldValue ; } }
Return the value of field in the data argument if it is not the default value for the class . If it is the default then null is returned .
147,165
public boolean isObjectsFieldValueDefault ( Object object ) throws SQLException { Object fieldValue = extractJavaFieldValue ( object ) ; return isFieldValueDefault ( fieldValue ) ; }
Return whether or not the data object has a default value passed for this field of this type .
147,166
public Object getJavaDefaultValueDefault ( ) { if ( field . getType ( ) == boolean . class ) { return DEFAULT_VALUE_BOOLEAN ; } else if ( field . getType ( ) == byte . class || field . getType ( ) == Byte . class ) { return DEFAULT_VALUE_BYTE ; } else if ( field . getType ( ) == char . class || field . getType ( ) == C...
Return whether or not the field value passed in is the default value for the type of the field . Null will return true .
147,167
private < FT , FID > FT createForeignShell ( ConnectionSource connectionSource , Object val , ObjectCache objectCache ) throws SQLException { @ SuppressWarnings ( "unchecked" ) Dao < FT , FID > castDao = ( Dao < FT , FID > ) foreignDao ; FT foreignObject = castDao . createObjectInstance ( ) ; foreignIdField . assignFie...
Create a shell object and assign its id field .
147,168
private FieldType findForeignFieldType ( Class < ? > clazz , Class < ? > foreignClass , Dao < ? , ? > foreignDao ) throws SQLException { String foreignColumnName = fieldConfig . getForeignCollectionForeignFieldName ( ) ; for ( FieldType fieldType : foreignDao . getTableInfo ( ) . getFieldTypes ( ) ) { if ( fieldType . ...
If we have a class Foo with a collection of Bar s then we go through Bar s DAO looking for a Foo field . We need this field to build the query that is able to find all Bar s that have foo_id that matches our id .
147,169
public T execute ( DatabaseConnection databaseConnection , ID id , ObjectCache objectCache ) throws SQLException { if ( objectCache != null ) { T result = objectCache . get ( clazz , id ) ; if ( result != null ) { return result ; } } Object [ ] args = new Object [ ] { convertIdToFieldObject ( id ) } ; Object result = d...
Query for an object in the database which matches the id argument .
147,170
protected void appendStringType ( StringBuilder sb , FieldType fieldType , int fieldWidth ) { if ( isVarcharFieldWidthSupported ( ) ) { sb . append ( "VARCHAR(" ) . append ( fieldWidth ) . append ( ')' ) ; } else { sb . append ( "VARCHAR" ) ; } }
Output the SQL type for a Java String .
147,171
private void appendDefaultValue ( StringBuilder sb , FieldType fieldType , Object defaultValue ) { if ( fieldType . isEscapedDefaultValue ( ) ) { appendEscapedWord ( sb , defaultValue . toString ( ) ) ; } else { sb . append ( defaultValue ) ; } }
Output the SQL type for the default value for the type .
147,172
private void addSingleUnique ( StringBuilder sb , FieldType fieldType , List < String > additionalArgs , List < String > statementsAfter ) { StringBuilder alterSb = new StringBuilder ( ) ; alterSb . append ( " UNIQUE (" ) ; appendEscapedEntityName ( alterSb , fieldType . getColumnName ( ) ) ; alterSb . append ( ')' ) ;...
Add SQL to handle a unique = true field . THis is not for uniqueCombo = true .
147,173
public static void registerDataPersisters ( DataPersister ... dataPersisters ) { List < DataPersister > newList = new ArrayList < DataPersister > ( ) ; if ( registeredPersisters != null ) { newList . addAll ( registeredPersisters ) ; } for ( DataPersister persister : dataPersisters ) { newList . add ( persister ) ; } r...
Register a data type with the manager .
147,174
public static DataPersister lookupForField ( Field field ) { if ( registeredPersisters != null ) { for ( DataPersister persister : registeredPersisters ) { if ( persister . isValidForField ( field ) ) { return persister ; } for ( Class < ? > clazz : persister . getAssociatedClasses ( ) ) { if ( field . getType ( ) == c...
Lookup the data - type associated with the class .
147,175
public int update ( DatabaseConnection databaseConnection , T data , ObjectCache objectCache ) throws SQLException { try { if ( argFieldTypes . length <= 1 ) { return 0 ; } Object [ ] args = getFieldObjects ( data ) ; Object newVersion = null ; if ( versionFieldType != null ) { newVersion = versionFieldType . extractJa...
Update the object in the database .
147,176
protected Object [ ] getFieldObjects ( Object data ) throws SQLException { Object [ ] objects = new Object [ argFieldTypes . length ] ; for ( int i = 0 ; i < argFieldTypes . length ; i ++ ) { FieldType fieldType = argFieldTypes [ i ] ; if ( fieldType . isAllowGeneratedIdInsert ( ) ) { objects [ i ] = fieldType . getFie...
Return the array of field objects pulled from the data object .
147,177
private CompiledStatement assignStatementArguments ( CompiledStatement stmt ) throws SQLException { boolean ok = false ; try { if ( limit != null ) { stmt . setMaxRows ( limit . intValue ( ) ) ; } Object [ ] argValues = null ; if ( logger . isLevelEnabled ( Level . TRACE ) && argHolders . length > 0 ) { argValues = new...
Assign arguments to the statement .
147,178
protected DatabaseConnection getSavedConnection ( ) { NestedConnection nested = specialConnection . get ( ) ; if ( nested == null ) { return null ; } else { return nested . connection ; } }
Returns the connection that has been saved or null if none .
147,179
protected boolean isSavedConnection ( DatabaseConnection connection ) { NestedConnection currentSaved = specialConnection . get ( ) ; if ( currentSaved == null ) { return false ; } else if ( currentSaved . connection == connection ) { return true ; } else { return false ; } }
Return true if the connection being released is the one that has been saved .
147,180
protected boolean clearSpecial ( DatabaseConnection connection , Logger logger ) { NestedConnection currentSaved = specialConnection . get ( ) ; boolean cleared = false ; if ( connection == null ) { } else if ( currentSaved == null ) { logger . error ( "no connection has been saved when clear() called" ) ; } else if ( ...
Clear the connection that was previously saved .
147,181
protected boolean isSingleConnection ( DatabaseConnection conn1 , DatabaseConnection conn2 ) throws SQLException { conn1 . setAutoCommit ( true ) ; conn2 . setAutoCommit ( true ) ; try { conn1 . setAutoCommit ( false ) ; if ( conn2 . isAutoCommit ( ) ) { return false ; } else { return true ; } } finally { conn1 . setAu...
Return true if the two connections seem to one one connection under the covers .
147,182
public static List < DatabaseTableConfig < ? > > loadDatabaseConfigFromReader ( BufferedReader reader ) throws SQLException { List < DatabaseTableConfig < ? > > list = new ArrayList < DatabaseTableConfig < ? > > ( ) ; while ( true ) { DatabaseTableConfig < ? > config = DatabaseTableConfigLoader . fromReader ( reader ) ...
Load in a number of database configuration entries from a buffered reader .
147,183
public static < T > DatabaseTableConfig < T > fromReader ( BufferedReader reader ) throws SQLException { DatabaseTableConfig < T > config = new DatabaseTableConfig < T > ( ) ; boolean anything = false ; while ( true ) { String line ; try { line = reader . readLine ( ) ; } catch ( IOException e ) { throw SqlExceptionUti...
Load a table configuration in from a text - file reader .
147,184
public static < T > void write ( BufferedWriter writer , DatabaseTableConfig < T > config ) throws SQLException { try { writeConfig ( writer , config ) ; } catch ( IOException e ) { throw SqlExceptionUtil . create ( "Could not write config to writer" , e ) ; } }
Write the table configuration to a buffered writer .
147,185
private static < T > void writeConfig ( BufferedWriter writer , DatabaseTableConfig < T > config ) throws IOException , SQLException { writer . append ( CONFIG_FILE_START_MARKER ) ; writer . newLine ( ) ; if ( config . getDataClass ( ) != null ) { writer . append ( FIELD_NAME_DATA_CLASS ) . append ( '=' ) . append ( co...
Write the config to the writer .
147,186
private static < T > void readTableField ( DatabaseTableConfig < T > config , String field , String value ) { if ( field . equals ( FIELD_NAME_DATA_CLASS ) ) { try { @ SuppressWarnings ( "unchecked" ) Class < T > clazz = ( Class < T > ) Class . forName ( value ) ; config . setDataClass ( clazz ) ; } catch ( ClassNotFou...
Read a field into our table configuration for field = value line .
147,187
private static < T > void readFields ( BufferedReader reader , DatabaseTableConfig < T > config ) throws SQLException { List < DatabaseFieldConfig > fields = new ArrayList < DatabaseFieldConfig > ( ) ; while ( true ) { String line ; try { line = reader . readLine ( ) ; } catch ( IOException e ) { throw SqlExceptionUtil...
Read all of the fields information from the configuration file .
147,188
private Object readKey ( FieldDescriptor field , JsonParser parser , DeserializationContext context ) throws IOException { if ( parser . getCurrentToken ( ) != JsonToken . FIELD_NAME ) { throw reportWrongToken ( JsonToken . FIELD_NAME , context , "Expected FIELD_NAME token" ) ; } String fieldName = parser . getCurrentN...
Specialized version of readValue just for reading map keys because the StdDeserializer methods like _parseIntPrimitive blow up when the current JsonToken is FIELD_NAME
147,189
public static void populateSubject ( final LinkedHashMap < String , CommonProfile > profiles ) { if ( profiles != null && profiles . size ( ) > 0 ) { final List < CommonProfile > listProfiles = ProfileHelper . flatIntoAProfileList ( profiles ) ; try { if ( IS_FULLY_AUTHENTICATED_AUTHORIZER . isAuthorized ( null , listP...
Populate the authenticated user profiles in the Shiro subject .
147,190
public String getName ( ) { CommonProfile profile = this . getProfile ( ) ; if ( null == principalNameAttribute ) { return profile . getId ( ) ; } Object attrValue = profile . getAttribute ( principalNameAttribute ) ; return ( null == attrValue ) ? null : String . valueOf ( attrValue ) ; }
Returns a name for the principal based upon one of the attributes of the main CommonProfile . The attribute name used to query the CommonProfile is specified in the constructor .
147,191
public static void showBooks ( final ListOfBooks booksList ) { if ( booksList != null && booksList . getBook ( ) != null && ! booksList . getBook ( ) . isEmpty ( ) ) { List < BookType > books = booksList . getBook ( ) ; System . out . println ( "\nNumber of books: " + books . size ( ) ) ; int cnt = 0 ; for ( BookType b...
Show books .
147,192
public void contextInitialized ( ServletContextEvent event ) { this . context = event . getServletContext ( ) ; System . out . println ( "The Simple Web App. Is Ready" ) ; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext ( "/client.xml" ) ; LocatorService client = ( LocatorService ) context ....
is ready to service requests
147,193
private void serializeEPR ( EndpointReferenceType wsAddr , Node parent ) throws ServiceLocatorException { try { JAXBElement < EndpointReferenceType > ep = WSA_OBJECT_FACTORY . createEndpointReference ( wsAddr ) ; createMarshaller ( ) . marshal ( ep , parent ) ; } catch ( JAXBException e ) { if ( LOG . isLoggable ( Leve...
Inserts a marshalled endpoint reference to a given DOM tree rooted by parent .
147,194
private static EndpointReferenceType createEPR ( String address , SLProperties props ) { EndpointReferenceType epr = WSAEndpointReferenceUtils . getEndpointReference ( address ) ; if ( props != null ) { addProperties ( epr , props ) ; } return epr ; }
Creates an endpoint reference from a given adress .
147,195
private static EndpointReferenceType createEPR ( Server server , String address , SLProperties props ) { EndpointReferenceType sourceEPR = server . getEndpoint ( ) . getEndpointInfo ( ) . getTarget ( ) ; EndpointReferenceType targetEPR = WSAEndpointReferenceUtils . duplicate ( sourceEPR ) ; WSAEndpointReferenceUtils . ...
Creates an endpoint reference by duplicating the endpoint reference of a given server .
147,196
private static void addProperties ( EndpointReferenceType epr , SLProperties props ) { MetadataType metadata = WSAEndpointReferenceUtils . getSetMetadata ( epr ) ; ServiceLocatorPropertiesType jaxbProps = SLPropertiesConverter . toServiceLocatorPropertiesType ( props ) ; JAXBElement < ServiceLocatorPropertiesType > slp...
Adds service locator properties to an endpoint reference .
147,197
private static QName getServiceName ( Server server ) { QName serviceName ; String bindingId = getBindingId ( server ) ; EndpointInfo eInfo = server . getEndpoint ( ) . getEndpointInfo ( ) ; if ( JAXRS_BINDING_ID . equals ( bindingId ) ) { serviceName = eInfo . getName ( ) ; } else { ServiceInfo serviceInfo = eInfo . g...
Extracts the service name from a Server .
147,198
private static String getBindingId ( Server server ) { Endpoint ep = server . getEndpoint ( ) ; BindingInfo bi = ep . getBinding ( ) . getBindingInfo ( ) ; return bi . getBindingId ( ) ; }
Extracts the bindingId from a Server .
147,199
private static BindingType map2BindingType ( String bindingId ) { BindingType type ; if ( SOAP11_BINDING_ID . equals ( bindingId ) ) { type = BindingType . SOAP11 ; } else if ( SOAP12_BINDING_ID . equals ( bindingId ) ) { type = BindingType . SOAP12 ; } else if ( JAXRS_BINDING_ID . equals ( bindingId ) ) { type = Bindi...
Maps a bindingId to its corresponding BindingType .