JDBaccess API 1.0

com.jdbaccess.da
Interface Insert

All Superinterfaces:
DataAccess

public interface Insert
extends DataAccess

Interface for inserting objects: with Insert you insert of one or more rows into a database table. To do that you normally define transfer objects, set some fields of them as modified set them with "setTOs" and execute the insert object. But you can also do an insert without transfer objects and set the single values with "setParameters". A batch insert is done if more than one transfer object is set (with better performance than single inserts). For a better performance there also exists special methods for getting sequence ids.

Example:
   Insert insert = DAReader.getInsert(t);
   Row row1 = new Row();
   row1.setValueModified(“id”, new Long(4711));
   row1.setValueModified(“name”, “yourName”);
   Row row2 = new Row();
   row2.setValueModified(“id”, new Long(4712));
   row2.setValueModified(“name”, “yourName”);
   ArrayList transferObjects = new ArrayList();
   transferObjects.add(row1);
   transferObjects.add(row2);
   insert.setPackage(„yourPackage“);
   insert.setName(“yourName”);
   insert.setTOs(transferObjects);
   ArrayList createdTransferObjects = insert.execute();
   insert.end();
 
Example with transfer objects: Employee emp = new Employee(); emp1.setValueModified("name", "tim"); BigDecimal timSal = BigDecimal.valueOf(5000002, 2); emp.setValueModified("salary", timSal); emp.setValueModified("description", "description ....."); emp.setValueModified("picture", picture); emp.setValueModified("creation", now); emp.setValueModified("modification", now); Insert insert = DAReader.getInsert(t); insert.setTO(emp); insert.execute(); insert.end();


Method Summary
 void end()
          Ends this data access, so that it can be moved to the internal cache (in statement pool) for reuse
 java.lang.Object execute()
          Execute the given Insert-object.
 void setTO(TransferObject to)
          Set one transfer object which should be inserted.
 void setTOs(java.util.ArrayList tos)
          Set the transfer objects which should be inserted.
 
Methods inherited from interface com.jdbaccess.da.DataAccess
getName, getObjectType, getPackageName, getSize, getSql, setName, setObjectType, setPackageName, setParameters, setSql, toString
 

Method Detail

execute

java.lang.Object execute()
                         throws ApplicationException
Execute the given Insert-object.

Returns:
update count as Long if no transfer objects are set else return inserted transfer objects as ArrayList
Throws:
ApplicationException

end

void end()
         throws ApplicationException
Ends this data access, so that it can be moved to the internal cache (in statement pool) for reuse

Specified by:
end in interface DataAccess
Throws:
ApplicationException

setTOs

void setTOs(java.util.ArrayList tos)
            throws ApplicationException
Set the transfer objects which should be inserted. They all must be of the same type.

Parameters:
tos - transfer objects as an ArrayList
Throws:
ApplicationException

setTO

void setTO(TransferObject to)
           throws ApplicationException
Set one transfer object which should be inserted.

Parameters:
to - transfer object
Throws:
ApplicationException

JDBaccess API 1.0

Copyright © 2005-2006 JDBaccess.com, Königsweg 210, D-14129 Berlin, Germany. All Rights Reserved.