Java Doc for Persist.java in  » Database-ORM » Persist » net » sf » persist » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » Persist » net.sf.persist 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sf.persist.Persist

Persist
final public class Persist (Code)
The main class for the persistence engine.

A Persist instance is bound to a java.sql.Connection object. Internally, Persist caches table-object mappings under cache names that allow for different mappings (most likely from different database schemas) to coexist. The default cache name is used if no cache name is specified in the constructor.

Persist instances are not thread safe, in particular because java.sql.Connection objects are not thread safe.

Persist instances are created with the following defaults:

  • closePreparedStatementsAfterRead=true This will work for most reads (select queries) that do not return long-lasting objects, such as streams or LOB handlers. If a query returns InputStream, Reader, Blob or Clob objects, closePreparedStatementsAfterRead should be set to false, and closing the PreparedStatement must be controlled manually. This is because those datatypes stream data from database after the PreparedStatement execution.
  • updateAutoGeneratedKeys=false This means that objects that are inserted either using insert() or executeUpdate() (with autoGeneratedKeys option) will not have their primary keys automatically updated against the generated keys in the database. Please consult your JDBC driver support for querying auto-generated keys in java.sql.PreparedStatement
  • DefaultNameGuesser which will take names in the form CompoundName (for classes) or compoundName (for fields) and return a set of guessed names such as [compound_name, compound_names, compoundname, compoundnames].

See Also:   TableMapping



Constructor Summary
public  Persist(Connection connection)
     Creates a Persist instance that will use the default cache for table-object mappings.
public  Persist(String cacheName, Connection connection)
     Creates a Persist instance that will use the given cache name for table-object mappings.

Method Summary
public  voidcloseLastPreparedStatement()
     Closes the last java.sql.PreparedStatement used by the engine.
public  voidclosePreparedStatement(PreparedStatement statement)
     Closes a java.sql.PreparedStatement .
public  voidcommit()
     Commits the java.sql.Connection Connection associated with this Persist instance.
public  intdelete(Object object)
     Deletes an object in the database.
public  int[]deleteBatch(Object... objects)
     Updates a batch of objects in the database.
public  ResultexecuteUpdate(Class objectClass, String sql, String[] autoGeneratedKeys, Object... parameters)
     Executes an update and return a Result object containing the number of rows modified and auto-generated keys produced.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
Parameters:
  objectClass - Class of the object related with the query.

public  intexecuteUpdate(String sql, Object... parameters)
     Executes an update and returns the number of rows modified.
public  ConnectiongetConnection()
     Returns the java.sql.Connection Connection associated with this Persist instance.
public  PreparedStatementgetLastPreparedStatement()
     Returns the last java.sql.PreparedStatement used by the engine.
public  MappinggetMapping(Class objectClass)
     Returns the mapping for the given object class.
public  PreparedStatementgetPreparedStatement(String sql, String[] autoGeneratedKeys)
     Creates a java.sql.PreparedStatement , setting the names of the auto-generated keys to be retrieved.
public  PreparedStatementgetPreparedStatement(String sql)
     Creates a java.sql.PreparedStatement with no parameters.
public static  ObjectgetValueFromResultSet(ResultSet resultSet, int column, Class type)
     Reads a column from the current row in the provided java.sql.ResultSet and returns an instance of the specified Java java.lang.Class containing the values read.

This method is used while converting java.sql.ResultSet rows to objects.

public static  ObjectgetValueFromResultSet(ResultSet resultSet, int column, int type)
     Reads a column from the current row in the provided java.sql.ResultSet and return a value correspondent to the SQL type provided (as defined in java.sql.Types java.sql.Types ).

This method is used while converting results sets to maps.

public  intinsert(Object object)
     Inserts an object into the database.
public  int[]insertBatch(Object... objects)
     Inserts a batch of objects into the database.
public  booleanisClosePreparedStatementsAfterRead()
     Returns true if java.sql.PreparedStatement instances are automatically closed after read (select or otherwise) queries.
public  booleanisUpdateAutoGeneratedKeys()
     Returns true if updating auto-generated keys is enabled.
public static  Map<String, Object>loadMap(ResultSet resultSet)
     Reads a row from the provided java.sql.ResultSet and converts it to a map having the column names as keys and results as values.
public  ObjectloadObject(Class objectClass, ResultSet resultSet)
     Reads a row from the provided java.sql.ResultSet and converts it to an object instance of the given class.
public  Tread(Class<T> objectClass, String sql)
     Reads a single object from the database by mapping the results of the SQL query into an instance of the given object class.
public  Tread(Class<T> objectClass, String sql, Object... parameters)
     Reads a single object from the database by mapping the results of the parameterized SQL query into an instance of the given object class.
public  Tread(Class<T> objectClass, PreparedStatement statement, Object... parameters)
     Reads a single object from the database by mapping the results of the execution of the given PreparedStatement into an instance of the given object class.
public  Tread(Class<T> objectClass, ResultSet resultSet)
     Reads a single object from the database by mapping the content of the ResultSet current row into an instance of the given object class.
public  TreadByPrimaryKey(Class<T> objectClass, Object... primaryKeyValues)
     Reads an object from the database by its primary keys.
public  Iterator<T>readIterator(Class<T> objectClass, ResultSet resultSet)
     Returns an java.util.Iterator for a list of objects from the database that map the contents of the ResultSet into instances of the given object class.
public  Iterator<T>readIterator(Class<T> objectClass, PreparedStatement statement, Object... parameters)
     Returns an java.util.Iterator for a list of objects from the database that map the contents of the execution of the given PreparedStatement into instances of the given object class.
public  Iterator<T>readIterator(Class<T> objectClass, String sql, Object... parameters)
     Returns an java.util.Iterator for a list of objects from the database that map the contents of the execution of the given SQL query into instances of the given object class.
public  Iterator<T>readIterator(Class<T> objectClass, String sql)
     Returns an java.util.Iterator for a list of objects from the database that map the contents of the execution of the given SQL query into instances of the given object class.
public  Iterator<T>readIterator(Class<T> objectClass)
     Returns an java.util.Iterator for a list of all objects in the database mapped to the given object class.
public  List<T>readList(Class<T> objectClass, ResultSet resultSet)
     Reads a list of objects from the database by mapping the content of the ResultSet into instances of the given object class.
public  List<T>readList(Class<T> objectClass, PreparedStatement statement, Object... parameters)
     Reads a list of objects from the database by mapping the results of the execution of the given PreparedStatement into instances of the given object class.
public  List<T>readList(Class<T> objectClass, String sql, Object... parameters)
     Reads a list of objects from the database by mapping the results of the parameterized SQL query into instances of the given object class.
public  List<T>readList(Class<T> objectClass, String sql)
     Reads a list of objects from the database by mapping the results of the SQL query into instances of the given object class.
public  List<T>readList(Class<T> objectClass)
     Reads a list of all objects in the database mapped to the given object class.
public  Map<String, Object>readMap(String sql)
     Reads a single object from the database by mapping the results of the SQL query into an instance of java.util.Map .
public  Map<String, Object>readMap(String sql, Object... parameters)
     Reads a single object from the database by mapping the results of the SQL query into an instance of java.util.Map .
public  Map<String, Object>readMap(PreparedStatement statement, Object... parameters)
     Reads a single object from the database by mapping the results of the PreparedStatement execution into an instance of java.util.Map .
public  Map<String, Object>readMap(ResultSet resultSet)
     Reads a single object from the database by mapping the results of the current ResultSet row into an instance of java.util.Map .
public  IteratorreadMapIterator(ResultSet resultSet)
     Returns an java.util.Iterator for a list of java.util.Map instances containing data from the provided ResultSet rows.
public  IteratorreadMapIterator(PreparedStatement statement, Object... parameters)
     Returns an java.util.Iterator for a list of java.util.Map instances containing data from the execution of the provided PreparedStatement.
public  IteratorreadMapIterator(String sql, Object... parameters)
     Returns an java.util.Iterator for a list of java.util.Map instances containing data from the execution of the provided parametrized SQL.
public  IteratorreadMapIterator(String sql)
     Returns an java.util.Iterator for a list of java.util.Map instances containing data from the execution of the provided SQL.
public  List<Map<String, Object>>readMapList(ResultSet resultSet)
     Reads a list of objects from the database by mapping the ResultSet rows to instances of java.util.Map .
public  List<Map<String, Object>>readMapList(PreparedStatement statement, Object... parameters)
     Reads a list of objects from the database by mapping the PreparedStatement execution results to instances of java.util.Map .
public  List<Map<String, Object>>readMapList(String sql, Object... parameters)
     Reads a list of objects from the database by mapping the SQL execution results to instances of java.util.Map .
public  List<Map<String, Object>>readMapList(String sql)
     Reads a list of all objects in the database mapped to the given object class and return each result as an instance of java.util.Map .
public  voidrollback()
     Rolls back the java.sql.Connection Connection associated with this Persist instance.
public  voidsetAutoCommit(boolean autoCommit)
     Sets the auto commit behavior for the java.sql.Connection Connection associated with this Persist instance.
public  voidsetAutoGeneratedKeys(Object object, Result result)
     Set auto-generated keys (returned from an insert operation) into an object.
public  voidsetClosePreparedStatementsAfterRead(boolean closePreparedStatementsAfterRead)
     Sets the behavior for closing java.sql.PreparedStatement instances after execution.
public static  voidsetNameGuesser(String cacheName, NameGuesser nameGuesser)
     Sets the NameGuesser for a given mappings cache.
public static  voidsetNameGuesser(NameGuesser nameGuesser)
     Sets the name guesser for the default mappings cache.
public static  voidsetParameters(PreparedStatement stmt, Object[] parameters)
     Sets parameters in the given prepared statement.
public  voidsetUpdateAutoGeneratedKeys(boolean updateAutoGeneratedKeys)
     Sets the behavior for updating auto-generated keys.
public  intupdate(Object object)
     Updates an object in the database.
public  int[]updateBatch(Object... objects)
     Updates a batch of objects in the database.


Constructor Detail
Persist
public Persist(Connection connection)(Code)
Creates a Persist instance that will use the default cache for table-object mappings.
Parameters:
  connection - java.sql.Connection object to be used
since:
   1.0



Persist
public Persist(String cacheName, Connection connection)(Code)
Creates a Persist instance that will use the given cache name for table-object mappings.
Parameters:
  cacheName - Name of the cache to be used
Parameters:
  connection - java.sql.Connection object to be used
since:
   1.0




Method Detail
closeLastPreparedStatement
public void closeLastPreparedStatement()(Code)
Closes the last java.sql.PreparedStatement used by the engine.
See Also:   java.sql.PreparedStatement.close
since:
   1.0



closePreparedStatement
public void closePreparedStatement(PreparedStatement statement)(Code)
Closes a java.sql.PreparedStatement .
Parameters:
  statement - java.sql.PreparedStatement to be closed
See Also:   java.sql.PreparedStatement.close
since:
   1.0



commit
public void commit()(Code)
Commits the java.sql.Connection Connection associated with this Persist instance.
See Also:   java.sql.Connection.commit
since:
   1.0



delete
public int delete(Object object)(Code)
Deletes an object in the database. The object will be identified using its mapped table's primary key. If no primary keys are defined in the mapped table, a PersistException will be thrown.
since:
   1.0



deleteBatch
public int[] deleteBatch(Object... objects)(Code)
Updates a batch of objects in the database. The objects will be identified using their matched table's primary keys. If no primary keys are defined in a given object, a PersistException will be thrown.
since:
   1.0



executeUpdate
public Result executeUpdate(Class objectClass, String sql, String[] autoGeneratedKeys, Object... parameters)(Code)
Executes an update and return a Result object containing the number of rows modified and auto-generated keys produced.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
Parameters:
  objectClass - Class of the object related with the query. Used todetermine the types of the auto-incremented keys. Only important ifautoGeneratedKeys contains values.
Parameters:
  sql - SQL code to be executed.
Parameters:
  autoGeneratedKeys - List of columns that are going to beauto-generated during the query execution.
Parameters:
  parameters - Parameters to be used in the PreparedStatement.
since:
   1.0




executeUpdate
public int executeUpdate(String sql, Object... parameters)(Code)
Executes an update and returns the number of rows modified.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
Parameters:
  sql - SQL code to be executed.
Parameters:
  parameters - Parameters to be used in the PreparedStatement.
since:
   1.0




getConnection
public Connection getConnection()(Code)
Returns the java.sql.Connection Connection associated with this Persist instance.
since:
   1.0



getLastPreparedStatement
public PreparedStatement getLastPreparedStatement()(Code)
Returns the last java.sql.PreparedStatement used by the engine.
since:
   1.0



getMapping
public Mapping getMapping(Class objectClass)(Code)
Returns the mapping for the given object class.
Parameters:
  objectClass - java.lang.Class object to get aTableMapping for
since:
   1.0



getPreparedStatement
public PreparedStatement getPreparedStatement(String sql, String[] autoGeneratedKeys)(Code)
Creates a java.sql.PreparedStatement , setting the names of the auto-generated keys to be retrieved.
Parameters:
  sql - SQL statement to create the java.sql.PreparedStatementfrom
Parameters:
  autoGeneratedKeys - names of the columns that will haveauto-generated values produced during the execution of thejava.sql.PreparedStatement
since:
   1.0



getPreparedStatement
public PreparedStatement getPreparedStatement(String sql)(Code)
Creates a java.sql.PreparedStatement with no parameters.
Parameters:
  sql - SQL statement to create the java.sql.PreparedStatementfrom
since:
   1.0



getValueFromResultSet
public static Object getValueFromResultSet(ResultSet resultSet, int column, Class type)(Code)
Reads a column from the current row in the provided java.sql.ResultSet and returns an instance of the specified Java java.lang.Class containing the values read.

This method is used while converting java.sql.ResultSet rows to objects. The class type is the field type in the target bean.

Correspondence between class types and ResultSet.get methods is as follows:

  • Boolean/boolean: getBoolean
  • Byte/byte: getByte
  • Short/short: getShort
  • Integer/int: getInt
  • Long/long: getLong
  • Float/float: getFloat
  • Double/double: getDouble
  • Character/char: getString
  • Character[]/char[]: getString
  • Byte[]/byte[]: setBytes
  • String: setString
  • java.math.BigDecimal: getBigDecimal
  • java.io.Reader: getCharacterStream
  • java.io.InputStream: getBinaryStream
  • java.util.Date: getTimestamp
  • java.sql.Date: getDate
  • java.sql.Time: getTime
  • java.sql.Timestamp: getTimestamp
  • java.sql.Clob: getClob
  • java.sql.Blob: getBlob

null's will be respected for any non-native types. This means that if a field is of type Integer it will be able to receive a null value from the ResultSet; on the other hand, if a field is of type int it will receive 0 for a null value from the java.sql.ResultSet .
Parameters:
  resultSet - java.sql.ResultSet (positioned in the row to beprocessed)
Parameters:
  column - column index in the result set (starting with 1)
Parameters:
  type - java.lang.Class of the object to be returned
since:
   1.0




getValueFromResultSet
public static Object getValueFromResultSet(ResultSet resultSet, int column, int type)(Code)
Reads a column from the current row in the provided java.sql.ResultSet and return a value correspondent to the SQL type provided (as defined in java.sql.Types java.sql.Types ).

This method is used while converting results sets to maps. The SQL type comes from the java.sql.ResultSetMetaData ResultSetMetaData for a given column.

Correspondence between java.sql.Types java.sql.Types and ResultSet.get methods is as follows:

  • ARRAY: getArray
  • BIGINT: getLong
  • BIT: getBoolean
  • BLOB: getBytes
  • BOOLEAN: getBoolean
  • CHAR: getString
  • CLOB: getString
  • DATALINK: getBinaryStream
  • DATE: getDate
  • DECIMAL: getBigDecimal
  • DOUBLE: getDouble
  • FLOAT: getFloat
  • INTEGER: getInt
  • JAVA_OBJECT: getObject
  • LONGVARBINARY: getBytes
  • LONGVARCHAR: getString
  • NULL: getNull
  • NCHAR: getString
  • NUMERIC: getBigDecimal
  • OTHER: getObject
  • REAL: getDouble
  • REF: getRef
  • SMALLINT: getInt
  • TIME: getTime
  • TIMESTAMP: getTimestamp
  • TINYINT: getInt
  • VARBINARY: getBytes
  • VARCHAR: getString
  • [Oracle specific] 100: getFloat
  • [Oracle specific] 101: getDouble

null's are respected for all types. This means that if a column is of type LONG and its value comes from the database as null, this method will return null for it.
Parameters:
  resultSet - java.sql.ResultSet (positioned in the row to beprocessed)
Parameters:
  column - Column index in the result set (starting with 1)
Parameters:
  type - type of the column (as defined injava.sql.Types java.sql.Types)
since:
   1.0




insert
public int insert(Object object)(Code)
Inserts an object into the database.
since:
   1.0



insertBatch
public int[] insertBatch(Object... objects)(Code)
Inserts a batch of objects into the database.
since:
   1.0



isClosePreparedStatementsAfterRead
public boolean isClosePreparedStatementsAfterRead()(Code)
Returns true if java.sql.PreparedStatement instances are automatically closed after read (select or otherwise) queries.
since:
   1.0



isUpdateAutoGeneratedKeys
public boolean isUpdateAutoGeneratedKeys()(Code)
Returns true if updating auto-generated keys is enabled.



loadMap
public static Map<String, Object> loadMap(ResultSet resultSet) throws SQLException(Code)
Reads a row from the provided java.sql.ResultSet and converts it to a map having the column names as keys and results as values.

See Persist.getValueFromResultSet(ResultSet,int,int) for details on the mappings between ResultSet.get methods and java.sql.Types java.sql.Types types
Parameters:
  resultSet - java.sql.ResultSet (positioned in the row to beprocessed)
since:
   1.0




loadObject
public Object loadObject(Class objectClass, ResultSet resultSet) throws SQLException(Code)
Reads a row from the provided java.sql.ResultSet and converts it to an object instance of the given class.

See Persist.getValueFromResultSet(ResultSet,int,Class) for details on the mappings between ResultSet.get methods and Java types.
Parameters:
  objectClass - type of the object to be returned
Parameters:
  resultSet - java.sql.ResultSet (positioned in the row to beprocessed)
See Also:   Persist.isNativeType(Class)
See Also:   Persist.getValueFromResultSet(ResultSet,int,Class)
since:
   1.0




read
public T read(Class<T> objectClass, String sql)(Code)
Reads a single object from the database by mapping the results of the SQL query into an instance of the given object class. Only the columns returned from the SQL query will be set into the object instance. If a given column can't be mapped to the target object instance, a PersistException will be thrown.
since:
   1.0



read
public T read(Class<T> objectClass, String sql, Object... parameters)(Code)
Reads a single object from the database by mapping the results of the parameterized SQL query into an instance of the given object class. Only the columns returned from the SQL query will be set into the object instance. If a given column can't be mapped to the target object instance, a PersistException will be thrown.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




read
public T read(Class<T> objectClass, PreparedStatement statement, Object... parameters)(Code)
Reads a single object from the database by mapping the results of the execution of the given PreparedStatement into an instance of the given object class. Only the columns returned from the PreparedStatement execution will be set into the object instance. If a given column can't be mapped to the target object instance, a PersistException will be thrown.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




read
public T read(Class<T> objectClass, ResultSet resultSet)(Code)
Reads a single object from the database by mapping the content of the ResultSet current row into an instance of the given object class. Only columns contained in the ResultSet will be set into the object instance. If a given column can't be mapped to the target object instance, a PersistException will be thrown.
since:
   1.0



readByPrimaryKey
public T readByPrimaryKey(Class<T> objectClass, Object... primaryKeyValues)(Code)
Reads an object from the database by its primary keys.
since:
   1.0



readIterator
public Iterator<T> readIterator(Class<T> objectClass, ResultSet resultSet)(Code)
Returns an java.util.Iterator for a list of objects from the database that map the contents of the ResultSet into instances of the given object class. Only columns contained in the ResultSet will be set into the object instances. If a given column can't be mapped to a target object instance, a PersistException will be thrown.
since:
   1.0



readIterator
public Iterator<T> readIterator(Class<T> objectClass, PreparedStatement statement, Object... parameters)(Code)
Returns an java.util.Iterator for a list of objects from the database that map the contents of the execution of the given PreparedStatement into instances of the given object class. Only columns contained in the ResultSet will be set into the object instances. If a given column can't be mapped to a target object instance, a PersistException will be thrown.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




readIterator
public Iterator<T> readIterator(Class<T> objectClass, String sql, Object... parameters)(Code)
Returns an java.util.Iterator for a list of objects from the database that map the contents of the execution of the given SQL query into instances of the given object class. Only columns contained in the ResultSet will be set into the object instances. If a given column can't be mapped to a target object instance, a PersistException will be thrown.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




readIterator
public Iterator<T> readIterator(Class<T> objectClass, String sql)(Code)
Returns an java.util.Iterator for a list of objects from the database that map the contents of the execution of the given SQL query into instances of the given object class. Only columns contained in the ResultSet will be set into the object instances. If a given column can't be mapped to a target object instance, a PersistException will be thrown.
since:
   1.0



readIterator
public Iterator<T> readIterator(Class<T> objectClass)(Code)
Returns an java.util.Iterator for a list of all objects in the database mapped to the given object class.
since:
   1.0



readList
public List<T> readList(Class<T> objectClass, ResultSet resultSet)(Code)
Reads a list of objects from the database by mapping the content of the ResultSet into instances of the given object class. Only columns contained in the ResultSet will be set into the object instances. If a given column can't be mapped to a target object instance, a PersistException will be thrown.
since:
   1.0



readList
public List<T> readList(Class<T> objectClass, PreparedStatement statement, Object... parameters)(Code)
Reads a list of objects from the database by mapping the results of the execution of the given PreparedStatement into instances of the given object class. Only the columns returned from the PreparedStatement execution will be set into the object instances. If a given column can't be mapped to a target object instance, a PersistException will be thrown.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




readList
public List<T> readList(Class<T> objectClass, String sql, Object... parameters)(Code)
Reads a list of objects from the database by mapping the results of the parameterized SQL query into instances of the given object class. Only the columns returned from the SQL query will be set into the object instance. If a given column can't be mapped to the target object instance, a PersistException will be thrown.

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




readList
public List<T> readList(Class<T> objectClass, String sql)(Code)
Reads a list of objects from the database by mapping the results of the SQL query into instances of the given object class. Only the columns returned from the SQL query will be set into the object instance. If a given column can't be mapped to the target object instance, a PersistException will be thrown.
since:
   1.0



readList
public List<T> readList(Class<T> objectClass)(Code)
Reads a list of all objects in the database mapped to the given object class.
since:
   1.0



readMap
public Map<String, Object> readMap(String sql)(Code)
Reads a single object from the database by mapping the results of the SQL query into an instance of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .
since:
   1.0




readMap
public Map<String, Object> readMap(String sql, Object... parameters)(Code)
Reads a single object from the database by mapping the results of the SQL query into an instance of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatementint[]Object[])
since:
   1.0




readMap
public Map<String, Object> readMap(PreparedStatement statement, Object... parameters)(Code)
Reads a single object from the database by mapping the results of the PreparedStatement execution into an instance of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatementint[]Object[])
since:
   1.0




readMap
public Map<String, Object> readMap(ResultSet resultSet)(Code)
Reads a single object from the database by mapping the results of the current ResultSet row into an instance of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .
since:
   1.0




readMapIterator
public Iterator readMapIterator(ResultSet resultSet)(Code)
Returns an java.util.Iterator for a list of java.util.Map instances containing data from the provided ResultSet rows.

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .
since:
   1.0




readMapIterator
public Iterator readMapIterator(PreparedStatement statement, Object... parameters)(Code)
Returns an java.util.Iterator for a list of java.util.Map instances containing data from the execution of the provided PreparedStatement.

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatementint[]Object[])
since:
   1.0




readMapIterator
public Iterator readMapIterator(String sql, Object... parameters)(Code)
Returns an java.util.Iterator for a list of java.util.Map instances containing data from the execution of the provided parametrized SQL.

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




readMapIterator
public Iterator readMapIterator(String sql)(Code)
Returns an java.util.Iterator for a list of java.util.Map instances containing data from the execution of the provided SQL.

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .
since:
   1.0




readMapList
public List<Map<String, Object>> readMapList(ResultSet resultSet)(Code)
Reads a list of objects from the database by mapping the ResultSet rows to instances of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .
since:
   1.0




readMapList
public List<Map<String, Object>> readMapList(PreparedStatement statement, Object... parameters)(Code)
Reads a list of objects from the database by mapping the PreparedStatement execution results to instances of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




readMapList
public List<Map<String, Object>> readMapList(String sql, Object... parameters)(Code)
Reads a list of objects from the database by mapping the SQL execution results to instances of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .

Parameters will be set according with the correspondence defined in Persist.setParameters(PreparedStatement,int[],Object[])
since:
   1.0




readMapList
public List<Map<String, Object>> readMapList(String sql)(Code)
Reads a list of all objects in the database mapped to the given object class and return each result as an instance of java.util.Map .

Types returned from the database will be converted to Java types in the map according with the correspondence defined in Persist.getValueFromResultSet(ResultSet,int,int) .
since:
   1.0




rollback
public void rollback()(Code)
Rolls back the java.sql.Connection Connection associated with this Persist instance.
See Also:   java.sql.Connection.rollback
since:
   1.0



setAutoCommit
public void setAutoCommit(boolean autoCommit)(Code)
Sets the auto commit behavior for the java.sql.Connection Connection associated with this Persist instance.
See Also:   java.sql.Connection.setAutoCommit(boolean)
since:
   1.0



setAutoGeneratedKeys
public void setAutoGeneratedKeys(Object object, Result result)(Code)
Set auto-generated keys (returned from an insert operation) into an object.
Parameters:
  object - java.lang.Object to have fields mapped toauto-generated keys set
Parameters:
  result - Result containing auto-generated keys
since:
   1.0



setClosePreparedStatementsAfterRead
public void setClosePreparedStatementsAfterRead(boolean closePreparedStatementsAfterRead)(Code)
Sets the behavior for closing java.sql.PreparedStatement instances after execution. This will only affect reads, since any update operations (insert, delete, update) will always have their java.sql.PreparedStatement instances automatically closed.

If a query returns InputStream, Reader, Blob or Clob objects, this should be set to false, and closing the PreparedStatement must be controlled manually. This is because those datatypes stream data from database after the PreparedStatement execution.
Parameters:
  closePreparedStatementsAfterRead - if true,java.sql.PreparedStatement instances for read queries will beautomatically closed
since:
   1.0




setNameGuesser
public static void setNameGuesser(String cacheName, NameGuesser nameGuesser)(Code)
Sets the NameGuesser for a given mappings cache.
Parameters:
  cacheName - Name of the cache to be used
Parameters:
  nameGuesser - NameGuesser implementation
since:
   1.0



setNameGuesser
public static void setNameGuesser(NameGuesser nameGuesser)(Code)
Sets the name guesser for the default mappings cache.
Parameters:
  nameGuesser - NameGuesser implementation
since:
   1.0



setParameters
public static void setParameters(PreparedStatement stmt, Object[] parameters)(Code)
Sets parameters in the given prepared statement.

Parameters will be set using PreparedStatement set methods related with the Java types of the parameters, according with the following table:

  • Boolean/boolean: setBoolean
  • Byte/byte: setByte
  • Short/short: setShort
  • Integer/integer: setInt
  • Long/long: setLong
  • Float/float: setFloat
  • Double/double: setDouble
  • Character/char: setString
  • Character[]/char[]: setString
  • Byte[]/byte[]: setBytes
  • String: setString
  • java.math.BigDecimal: setBigDecimal
  • java.io.Reader: setCharacterStream
  • java.io.InputStream: setBinaryStream
  • java.util.Date: setTimestamp
  • java.sql.Date: setDate
  • java.sql.Time: setTime
  • java.sql.Timestamp: setTimestamp
  • java.sql.Clob : setClob
  • java.sql.Blob: setBlob

Parameters:
  stmt - java.sql.PreparedStatement to have parameters setinto
Parameters:
  parameters - varargs or Object[] with parameters values
throws:
  RuntimeSQLException - if a database access error occurs or thismethod is called on a closed PreparedStatement; if a parameter type doesnot have a matching set method (as outlined above)
throws:
  RuntimeIOException - if an error occurs while reading data from aReader or InputStream parameter
since:
   1.0



setUpdateAutoGeneratedKeys
public void setUpdateAutoGeneratedKeys(boolean updateAutoGeneratedKeys)(Code)
Sets the behavior for updating auto-generated keys.
Parameters:
  updateAutoGeneratedKeys - if set to true, auto-generated keys willbe updated after the execution of insert or executeUpdate operations thatmay trigger auto-generation of keys in the database
since:
   1.0



update
public int update(Object object)(Code)
Updates an object in the database. The object will be identified using its mapped table's primary key. If no primary keys are defined in the mapped table, a PersistException will be thrown.
since:
   1.0



updateBatch
public int[] updateBatch(Object... objects)(Code)
Updates a batch of objects in the database. The objects will be identified using their mapped table's primary keys. If no primary keys are defined in the mapped table, a PersistException will be thrown.
since:
   1.0



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.