|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sequalite.session.Session
public class Session
Session is the facade to SeQuaLite.
Method Summary | |
---|---|
java.util.List |
clone(java.util.List list)
Clones a list of objects. |
java.lang.Object |
clone(java.lang.Object base)
Clones an Object |
java.lang.Object[] |
clone(java.lang.Object[] array)
Clones an ObjectArray |
void |
close()
closes the session, takes care of closing the database connection if created by sequalite |
void |
commit()
commit the session |
SeQuaLitePageModel |
createPageModel(java.lang.Class voClass,
java.lang.String sqlName,
java.lang.Object[] values,
int recordsPerPage)
Creates a pagination model using a predefined query. |
SeQuaLitePageModel |
createPageModel(java.lang.Class voClass,
java.lang.String criteria,
java.lang.Object[] values,
java.lang.String sortBy,
int recordsPerPage)
Creates a pagination model. |
int |
delete(java.lang.Class voClass,
java.lang.String criteria,
java.lang.Object[] values)
deletes rows from database depending on the criteria |
void |
delete(java.util.List objectList)
deletes a set of objects from database and deletes children if on-delete-cascade is true |
void |
delete(java.lang.Object object)
deletes an object from database and deletes children if on-delete-cascade=true |
void |
delete(java.lang.Object[] objectArray)
deletes a set of objects from database and deletes children |
java.util.List |
executeCall(java.lang.Class voClass,
java.lang.String namedProcedure,
java.lang.Object[] inParams,
java.util.List<java.lang.String> outParams)
Executes a database stored procedure and a) populates the OUT parameters into outParams b) if the stored procedure returns resultsets, this method will return them Assumption, the parameters Order is IN first and then the OUT, the exception being for functions where they have a return value. |
java.util.List |
executeCall(java.lang.String procSQL,
java.lang.Object[] inParams,
java.util.List<java.lang.String> outParams)
Executes a database stored procedure and a) populates the OUT parameters into outParams b) if the stored procedure returns resultsets, this method will return them Assumption, the Paramaters Order is IN first and then the OUT, the exception being for functions where they have a return value. |
java.util.List |
executeQuery(java.lang.Class voClass,
java.lang.String sqlName,
java.lang.Object[] values)
Returns a List of voClass Objects executing the sql identified by sqlName |
java.util.List |
executeQuery(java.lang.String query,
java.lang.Object[] values,
SeQuaLiteResultMapper mapper)
Returns a List of objects executing the query. |
int |
executeUpdate(java.lang.Class voClass,
java.lang.String sqlName,
java.lang.Object[] values)
Executes a named DML defined in the O-R Map |
int |
executeUpdate(java.lang.String query,
java.lang.Object[] values)
Executes a native DML |
java.util.List |
find(java.lang.Class voClass,
java.lang.String criteria,
java.lang.Object[] values)
Returns a List of voClass Objects matching the criteria |
java.util.List |
find(java.lang.Class voClass,
java.lang.String criteria,
java.lang.Object[] values,
java.lang.String sortBy)
Returns a List of voClass Objects matching the criteria in the sortBy order |
java.util.List<SeQuaLiteModel> |
findAsProxy(java.lang.Class voClass,
java.lang.String criteria,
java.lang.Object[] values,
java.lang.String sortBy)
Returns a List of voClass ProxyObjects matching the criteria in the sortBy order |
java.util.List |
getChildren(SeQuaLiteModel base,
java.lang.String childName)
Gets the Children associated with the childName |
java.util.List |
paginate(SeQuaLitePageModel pageModel,
int page)
Retrieves a page using pagination |
void |
realize(java.util.List objectList)
Realizes a list of objects. |
void |
realize(java.lang.Object base)
Realizes an object. |
void |
realize(java.lang.Object[] objectArray)
Realizes an array of objects. |
void |
rollback()
rollback the session |
void |
save(java.util.List objectList)
inserts a set of objects to database and saves children if on-save-cascade is true. |
void |
save(java.lang.Object base)
saves an object to database and saves children if on-save-cascade is true. |
void |
save(java.lang.Object[] objectArray)
saves a set of objects to database and saves the children if on-save-cascade is true |
int |
update(java.lang.Class voClass,
java.lang.String setter,
java.lang.Object[] sValues,
java.lang.String criteria,
java.lang.Object[] cValues)
update database |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public java.util.List clone(java.util.List list) throws SeQuaLiteException
list
-
SeQuaLiteException
public java.lang.Object clone(java.lang.Object base) throws SeQuaLiteException
base
-
SeQuaLiteException
public java.lang.Object[] clone(java.lang.Object[] array) throws SeQuaLiteException
array
-
SeQuaLiteException
public void close() throws SeQuaLiteException
SeQuaLiteException
public void commit() throws SeQuaLiteException
SeQuaLiteException
public SeQuaLitePageModel createPageModel(java.lang.Class voClass, java.lang.String sqlName, java.lang.Object[] values, int recordsPerPage) throws SeQuaLiteException, SeQuaLiteFinderException
SeQuaLitePageModel pageModel = session.createPageModel(Invoice.class,
"findBySql", new Object[] { 5000, 10000 }, 100);
int pageCount = pageModel.getPageCount();
List list = pageModel.getPage(1);
for (Object o : list) {
Invoice invoice = (Invoice) o;
System.out.println("Invoice Number: " + invoice.getId() + ", Date: "
+ invoice.getInvoiceDate() + ", Amount: " + invoice.getAmount());
}
Where "findBySql" needs to be defined under Invoice class mapping in the O-R mapping file as below.
<sql name="findBySql" type="find">
SELECT * FROM INVOICE WHERE AMOUNT BETWEEN ? AND ? ORDER BY INVOICE_DATE DESC
</sql>
voClass
- sqlName
- values
- recordsPerPage
-
SeQuaLiteException
SeQuaLiteFinderException
public SeQuaLitePageModel createPageModel(java.lang.Class voClass, java.lang.String criteria, java.lang.Object[] values, java.lang.String sortBy, int recordsPerPage) throws SeQuaLiteException, SeQuaLiteFinderException
SeQuaLitePageModel pageModel = session.createPageModel(Invoice.class,
"amount > ? && amount <= ?", new Object[] { 5000, 10000 },
"invoiceDate DESC", 100);
int pageCount = pageModel.getPageCount();
List list = pageModel.getPage(1);
for (Object o : list) {
Invoice invoice = (Invoice) o;
System.out.println("Invoice Number: " + invoice.getId() + ", Date: "
+ invoice.getInvoiceDate() + ", Amount: " + invoice.getAmount());
}
voClass
- criteria
- values
- sortBy
- recordsPerPage
-
SeQuaLiteException
SeQuaLiteFinderException
public int delete(java.lang.Class voClass, java.lang.String criteria, java.lang.Object[] values) throws SeQuaLiteException
voClass
- criteria
- values
-
SeQuaLiteException
public void delete(java.util.List objectList) throws SeQuaLiteException
objectList
-
SeQuaLiteException
public void delete(java.lang.Object object) throws SeQuaLiteException
object
-
SeQuaLiteException
public void delete(java.lang.Object[] objectArray) throws SeQuaLiteException
objectArray
-
SeQuaLiteException
public java.util.List executeCall(java.lang.Class voClass, java.lang.String namedProcedure, java.lang.Object[] inParams, java.util.List<java.lang.String> outParams) throws SeQuaLiteException
Executes a database stored procedure and a) populates the OUT parameters into outParams b) if the stored procedure returns resultsets, this method will return them Assumption, the parameters Order is IN first and then the OUT, the exception being for functions where they have a return value. So the first parameter will be a OUT parameter there.
voClass
- namedProcedure
- inParams
- outParams
-
SeQuaLiteException
public java.util.List executeCall(java.lang.String procSQL, java.lang.Object[] inParams, java.util.List<java.lang.String> outParams) throws SeQuaLiteException
Executes a database stored procedure and a) populates the OUT parameters into outParams b) if the stored procedure returns resultsets, this method will return them Assumption, the Paramaters Order is IN first and then the OUT, the exception being for functions where they have a return value. So the first parameter will be a OUT parameter.
procSQL
- inParams
- outParams
-
SeQuaLiteException
public java.util.List executeQuery(java.lang.String query, java.lang.Object[] values, SeQuaLiteResultMapper mapper) throws SeQuaLiteException, SeQuaLiteFinderException
List list = session.executeQuery("SELECT ID,NAME FROM CUSTOMER WHERE ID=?", new OBJECT[]{1},
new SeQuaLiteResultMapper(){
public Object createAndPopulate(ResultSet rs){
Customer customer = new Customer();
customer.setId(rs.get("ID"));
customer.setName(rs.get("NAME"));
return customer;
}
});
query
- values
- mapper
-
SeQuaLiteException
SeQuaLiteFinderException
public java.util.List executeQuery(java.lang.Class voClass, java.lang.String sqlName, java.lang.Object[] values) throws SeQuaLiteException, SeQuaLiteFinderException
voClass
- sqlName
- values
-
SeQuaLiteException
SeQuaLiteFinderException
public int executeUpdate(java.lang.Class voClass, java.lang.String sqlName, java.lang.Object[] values) throws SeQuaLiteException
voClass
- sqlName
- values
-
SeQuaLiteException
public int executeUpdate(java.lang.String query, java.lang.Object[] values) throws SeQuaLiteException
query
- values
-
SeQuaLiteException
public java.util.List find(java.lang.Class voClass, java.lang.String criteria, java.lang.Object[] values) throws SeQuaLiteException, SeQuaLiteFinderException
voClass
- criteria
- values
-
SeQuaLiteException
SeQuaLiteFinderException
public java.util.List find(java.lang.Class voClass, java.lang.String criteria, java.lang.Object[] values, java.lang.String sortBy) throws SeQuaLiteException, SeQuaLiteFinderException
voClass
- criteria
- values
- sortBy
-
SeQuaLiteException
SeQuaLiteFinderException
public java.util.List<SeQuaLiteModel> findAsProxy(java.lang.Class voClass, java.lang.String criteria, java.lang.Object[] values, java.lang.String sortBy) throws SeQuaLiteException, SeQuaLiteFinderException
voClass
- criteria
- values
- sortBy
-
SeQuaLiteException
SeQuaLiteFinderException
public java.util.List getChildren(SeQuaLiteModel base, java.lang.String childName) throws SeQuaLiteException, SeQuaLiteFinderException
base
- childName
-
SeQuaLiteException
SeQuaLiteFinderException
public java.util.List paginate(SeQuaLitePageModel pageModel, int page) throws SeQuaLiteFinderException, SeQuaLiteException
pageModel
- page
-
SeQuaLiteException
SeQuaLiteFinderException
SeQuaLiteException
public void realize(java.util.List objectList) throws SeQuaLiteException, SeQuaLiteFinderException
objectList
-
SeQuaLiteException
SeQuaLiteFinderException
public void realize(java.lang.Object base) throws SeQuaLiteException, SeQuaLiteFinderException
Customer customer = new Customer();
customer.setId(10);
session.realize(customer);
System.out.println("Customer Name: " + customer.getName());
base
-
SeQuaLiteException
SeQuaLiteFinderException
public void realize(java.lang.Object[] objectArray) throws SeQuaLiteException, SeQuaLiteFinderException
objectArray
-
SeQuaLiteException
SeQuaLiteFinderException
public void rollback() throws SeQuaLiteException
SeQuaLiteException
public void save(java.lang.Object base) throws SeQuaLiteException
base
-
SeQuaLiteException
public void save(java.lang.Object[] objectArray) throws SeQuaLiteException
objectArray
-
SeQuaLiteException
public void save(java.util.List objectList) throws SeQuaLiteException
objectList
-
SeQuaLiteException
public int update(java.lang.Class voClass, java.lang.String setter, java.lang.Object[] sValues, java.lang.String criteria, java.lang.Object[] cValues) throws SeQuaLiteException
voClass
- setter
- sValues
- criteria
- cValues
-
SeQuaLiteException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |