input
stringlengths
10
828
output
stringlengths
5
107
protected index descriptor normalize index string normal table name index descriptor id return id
override this method if the database has special requirements
public int get max column name length return this max column name length
gets the maximum column name length supported by the
protected boolean types match int type1 int type2 if type1 type2 return true if is text type1 is text type2 return true if is long type1 is long type2 return true if is decimal type1 is decimal type2 return true if is blob type1 is blob type2 return true if is tiny type1 is tiny type2 return true return false
checks whether two sql types match when trying to determine
protected string get field name store info sinfo string property name throws store exception property descriptor pd sinfo get property descriptor property name if pd null throw new store exception no property named property name field descriptor fd sinfo get field descriptor this pd if fd null throw new store exception property named property name is not persistent return fd get name
gets the field name into which a java bean property name is mapped
public int get memory object count synchronized this objects monitor return this object infos by object size
gets the number of objects currently in main memory maps
protected prepared statement get create table statement connection c string table name field descriptor fd boolean auto increment requested string engine string default charset throws sqlexception return c prepare statement create table table name fd get name get type declaration fd fd is nullable null not null
gets a statement that creates a table with a single field
protected prepared statement get remove field statement connection c string table name string column name throws sqlexception prepared statement ps c prepare statement alter table table name drop column name return ps
gets a statement that removes a field
protected boolean requires key length return false
determines whether the database requires a key length
protected boolean supports auto increment return false
determines if the database supports auto increment primary keys
public void put string name object obj throws store exception persistent map string object map get root map map put object name obj
associates a persistent object with a name
protected string auto increment declaration return auto increment
override to provide field declaration qualifier
public object get string name throws store exception check weak references persistent map string object map get root map return map get object name
gets a persistent object previously associated with a name
protected int auto increment column number return 1
returns the column number of the auto increment value
public void remove string name throws store exception persistent map string object map get root map map remove object name
removes an association of a name with a persistent object
protected void set parameter prepared statement ps int index object obj val throws sqlexception if obj val instanceof string ps set string index string obj val else if obj val instanceof integer ps set int index integer obj val else if obj val instanceof long ps set long index long obj val else if obj val instanceof boolean ps set boolean index boolean obj val else if obj val instanceof byte ps set bytes index byte obj val else ps set object index obj val
sets a code preparted statement code parameter
public object get object global persistent id global id throws store exception object obj this get cached object global id if obj null this does not require synchronization and performs i o obj this lookup stored object global id null return obj
gets a persistent object given its unique id
public object get object global persistent id global id class loader class loader throws store exception object obj this get cached object global id if obj null this does not require synchronization and performs i o obj this lookup stored object global id class loader return obj
gets a persistent object given its unique id
public object get object persistent id object id class bean class throws store exception global persistent id global id new global persistent id object id bean class object obj this get cached object global id if obj null this does not require synchronization and performs i o obj this lookup stored object object id bean class return obj
obtains an object given a
protected object get result set value int i string name int type result set result set throws sqlexception if is decimal type double value result set get double i return result set was null null new double value else if is long type long value result set get long i return result set was null null new long value else return result set get object i
gets an object from the result set
public object get cached object global persistent id global id synchronized objects monitor return this get cached object impl global id
gets a persistent object from main memory if available
public boolean should close connection after transaction return true
determines if the database connection should be closed
private object lookup stored object global persistent id global id class loader class loader throws store exception persistent id object id global id get object id string class name global id get class name try class bean class class loader null this lookup class class name class loader load class class name return lookup stored object object id bean class catch class not found exception cnf throw new store exception cnf
loads a persistent object from storage
protected string get table name class bean class throws store exception store info sinfo this get store info bean class return sinfo get table name this max table name length
gets the table name used for a given class
private object lookup stored object persistent id object id class bean class throws store exception store info sinfo get store info bean class bean factory factory new simple bean factory bean class string table name sinfo get table name this max table name length string sql string select from table name where sinfo get id field object id results iterator results this select sinfo get bean class sql string new object 0 factory true try if results has next return results next else return null finally results close
retrieves an object from the database
public void reload object pers object throws store exception persistent id object id this get persistent id pers object class bean class pers object get class this lookup stored object object id bean class
repopulates persistent object properties with stored data
public void save object pers object throws store exception this save pers object false false
updates the database record previously created
public void save object pers object boolean force boolean reload throws store exception check weak references object info oi get object info pers object try oi save force catch store exception err if reload if logger is loggable level info logger info save operation failed reloading record this reload pers object throw err
saves an object in the database
public void insert object pers object throws store exception check weak references object info oi synchronized this objects monitor oi this object infos by object get pers object if oi null throw new store exception object already known by store a new bean must be created before invoking insert this insert bean transac pers object
attempts to insert a new persistent object in its underlying database table
public void register object pers object throws store exception check weak references get object info pers object
informs this store about a new persistent object
public void delete object pers object throws store exception this delete pers object false
removes a persistent object from storage
public void delete object pers object boolean forget throws store exception object info oi get object info pers object oi delete forget
deletes an objects database representation
public persistent id get persistent id object pers object throws store exception object info oi get object info pers object return oi get object id
gets the persistent id associated with a persistent object
public void begin transaction throws store exception this begin transaction connection transaction read committed
begins a database transaction with isolation level
public void begin transaction int transaction isolation level throws store exception try this database begin transaction transaction isolation level catch sqlexception err throw new store exception err
begins a database transaction with a given transaction isolation
public void end transaction throws store exception this end transaction false
ends a transaction previously begun by a call to
public void end transaction boolean rollback throws store exception try this database end transaction rollback catch sqlexception err throw new store exception err
ends a transaction previously begun by a call to
public boolean in transaction return this database in transaction
determines whether the current thread execution point
public void request lock class bean class string data name throws store exception interrupted exception this request lock bean class data name connection transaction read committed
requests a lock with a transaction isolation level
public void request lock class bean class string data name int transaction isolation level throws store exception interrupted exception string lock name bean class get name data name try this database request lock lock name transaction isolation level catch sqlexception se throw new store exception se
requests entrance to a critical section of code for both
public void relinquish lock throws store exception this relinquish lock false
relinquishes a lock previously obtained with
public void relinquish lock boolean rollback throws store exception try this database relinquish lock rollback catch sqlexception se throw new store exception se
relinquishes a lock previously obtained with
public results iterator select final class inbean class throws store exception return select inbean class null
gets an iterator of all stored instances of the given class
public object select single final class bean class map values throws store exception results iterator i select bean class values try if i has next return i next finally i close return null
finds a stored instance matching the property values given
public object select single final class bean class map values string order by boolean descending throws store exception results iterator i select bean class values order by descending new integer 1 try if i has next return i next finally i close return null
finds a stored instance matching the property values given
public results iterator select final class bean class map values throws store exception return select bean class values null false null
finds all stored instances matching the property values given
public results iterator select final class bean class map values string order by property boolean descending integer limit throws store exception bean factory bean factory new simple bean factory bean class return this select bean class values order by property descending limit bean factory
finds stored instances matching the property values given
public results iterator select final class bean class map property values string order by property boolean descending integer limit bean factory bean factory throws store exception return this select bean class property values order by property descending limit null bean factory
finds stored instances matching the property values given
public results iterator select class bean class string sql query object parameters throws store exception bean factory factory new simple bean factory bean class return this select bean class sql query parameters factory this modify object on query
general purpose method for arbitrary sql
public boolean delete class bean class map values throws store exception store info sinfo get store info bean class string table name get table name bean class map m values marshall criteria values bean class sinfo values if m values size 0 throw new store exception no marshalled condition values found from map provided make sure property names used in query exist are not capitalized and are persistent try return delete records table name m values catch sqlexception se throw new store exception se
deletes all database records that match the given criteria
public void set title string title this title label set text title
set title of panel
public void set content widget widget content panel clear content widget if widget null content panel add content else content panel set size 0px 0px
set content of panel
public void set content size string width string height content panel set size width height title label set width width
set size of content
public boolean is collapsed return content panel is visible
returns true if panel is collapsed
public void indent string width indent panel set width width
indent panel for given width
public void set title style name string style this title label set style name style
sets style name of the title
public void add title style name string style this title label add style name style
adds style name of the title
public destination dto to destination dto destination dto result new destination dto result id id result name name return result
returns dto representation of this instance
public void update destination dto dto todo not all fields are included into dto object this id dto id this name dto name
update this destination with values from given dto object
public void update sezona dto sezona this set active sezona active this set id sezona id this set name sezona name this set order sezona order
update values of this sezona with values from sezona dto
public void test do initialization throws exception idatabase connection connection null try connection new database connection connection factory get connection idata set db data set connection create data set database operation delete all execute connection db data set idata set generator table ds new flat xml data set new file xml database operation clean insert execute connection generator table ds catch exception ex ex print stack trace throw ex finally if connection null try connection close catch exception ex ex print stack trace
initialize empty database
public void test get destinations throws exception try destination dao destination dao new destination dao session s hibernate util get session sezona sezona sezona s get sezona class 1 list destination dests destination dao get destinations sezona assert not null dests assert true dests size 3 sezona sezona s get sezona class 2 dests destination dao get destinations sezona assert not null dests assert true dests size 1 finally hibernate util commit transaction hibernate util close session
test method for
public void test get travel agencies try travel agency dao dao new travel agency dao list travel agency list dao get travel agencies assert not null list assert true list size 2 catch exception ex ex print stack trace finally try hibernate util commit transaction catch exception ex ex print stack trace hibernate util close session
test method for
public void test should return aranzman with id1 throws exception search for aranzman in kotor aranzman destination search condition condition new aranzman destination search condition 2 aranzman search add search condition condition list result dao search aranzman search assert not null result assert equals wrong number of results 1 result size aranzman a aranzman result get 0 assert equals wrong aranzman found new integer 1 a get id
search for aranzman in kotor
public expectations get specific expectations throws exception return new expectations
override to provide test case specific jmock expectations
public void after business method throws exception
override to perform specific behavior immediately after the business
public void verify exception exception e e print stack trace fail business method should not throw exceptions
handles an exception thrown from the business method
private object align value to validations object value field field if value instanceof string null field size size extract annotation field get annotations size class null if null size string s value string value int length s value length int max size max if length max value s value substring length max length return value
read jsr 303 validation annotations of the field and align the generated
private string extract property name string method name return method name substring 3 4 to lower case method name substring 4
extract the name of the property from the setter method name
private calendar create calendar object base value int index calendar c new gregorian calendar 1950 0 1 2 3 4 c add calendar millisecond pretty int get offset base value index c add calendar second pretty int get offset base value index c add calendar minute pretty int get offset base value index c add calendar day of month pretty int get offset base value index c add calendar month pretty int get offset base value index return c
create a test value of type calendar
private int get offset object value int i return math abs repeatable hash code value i 1000000
calculate new offset from a base value and previous offset
private int repeatable hash code object value string s string value of value int h 0 for int i 0 i s length i h 31 h s char at i return h
re implement string hash code to ensure consistent results in future
private int pretty int int i return math abs i 1000
cut an int to a pretty value
private string pretty int as string int i int r pretty int i string builder sb new string builder if r 100 sb append 0 if r 10 sb append 0 sb append r return sb to string
cut an int to a pretty string value
public void add property string name object value if first property first property false else b append b append name b append append value value
add a property to the builder
public void enumerate object bean property visitor visitor log debug enumerating properties of bean bean property value extractor pve new property value extractor bean property descriptor property descriptors property utils get property descriptors bean for property descriptor property descriptor property descriptors string name property descriptor get name class type property descriptor get property type object value try value pve extract property value name catch illegal argument exception e continue log trace visiting property of type with value new object name type value visitor visit bean name type value
enumerate all properties of a bean visiting each one using a
private void append array class clazz object items append array clazz items length items
append array of items to the builder
private void append array class clazz int display length object items b append clazz get name b append b append display length b append for int i 0 i items length i b append items i if i items length 1 b append b append
append array of items to the builder
public int number excl int min int max double r math random return int r max min min
generate random number with value between minimum and maximum
public int number incl int min int max return number excl min max 1
generate random number with value between minimum and maximum
public long number int length int from 1 string builder sb new string builder for int i 0 i length i int code number incl from 9 if 1 from from 0 sb append char code 0 return long value of sb to string
generate random number with the specified length
public long number int min int max return number number incl min max
generate random number with length in the specified interval inclusive
public string phone return number 3 4 number 3 4 number 3 4
generate random phone number
public calendar date int year int month int day number incl 1 28 return new gregorian calendar year month day
generate random date with the given year and month
public calendar date int year int month number incl 0 11 return date year month
generate random date with the given year
public calendar date int current year gregorian calendar get instance get gregorian calendar year int year number incl 1950 current year return date year
generate random date with the given year
public calendar time string text number incl 0 23 number incl 0 59 simple date format formatter new simple date format h mm parse position pos new parse position 0 date time value formatter parse text pos calendar cal gregorian calendar get instance cal set time time value return cal
generate random time
public int english letter code double r math random for int i 0 i letter freqs length i if r letter freqs i return i return letter freqs length
generate random letter 0 based index using the letter frequencies of
public string word int length string builder sb new string builder for int i 0 i length i char ch char english letter code a if 0 i ch character to upper case ch sb append ch return sb to string
generate random word with the specified length
public string word int min int max return word number incl min max
generate random word with length in the specified interval inclusive
public string sentence int min int max string builder sb new string builder int word length min 3 word length max 8 int len number incl min max while sb length len string word word word length min word length max if 0 sb length word word to lower case sb append word sb append if sb length max sb set length max return sb to string
generate random sentence of the specified length in characters
public void set property p property this property property
default setter for property property
private boolean is char object value return value instanceof character
returns true is value is character
private boolean is string object value return value instanceof string
returns true if value is string
private boolean is hash map entry object value return value instanceof entry
returns true if value is map
private boolean is base type object value return value get class is primitive value instanceof string value instanceof number value instanceof boolean value instanceof character
returns true if value is directly convertible to string
public hibernate criteria builder get criteria builder return criteria builder
returns the current hibernate criteria builder
public void set criteria builder hibernate criteria builder criteria builder this criteria builder criteria builder
sets the hibernate criteria builder to be used
public void set criteria factory criteria factory criteria factory this criteria factory criteria factory
set factory for criteria
public void refresh entity extends serializable entity new refresher refresh entity
refresh all code table properties of an instance of entity recursing to
public customer dao get dao return dao
standard getter for the customer dao