Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javatools.db
Class DbDeleter  view DbDeleter download DbDeleter.java

java.lang.Object
  extended byjavatools.db.DbDeleter
Direct Known Subclasses:
DbReferencedDeleter

public class DbDeleter
extends java.lang.Object

A class used to delete records from SQL tables. The constructor is not public. To obtain a DbDeleter call DbTable.deleter(); Example: To delete all the people who are (younger than 18 or older than 80) and whose name is "Fred"...

 DbDatabase db = ...;
 DbTable people = db.getTable("PEOPLE");
 DbDeleter deleter = people.deleter();
 deleter.setWhere(people.getColumn("AGE").lessThan(new Integer(18)).or(
  people.getColumn("AGE").greaterThan(new Integer(80))).and(
  people.getColumn("NAME").equal("FRED"));
 int numberOfPeopleDeleted = deleter.execute();
 
This is equivilent to...
 DELETE FROM PEOPLE WHERE (AGE < 18 OR AGE > 80 ) AND NAME='Fred'
 
Note the use of equal(), NOT equals().

Version:
0.2.0

Field Summary
(package private)  DbAbstractTable table
          The table for this operation.
(package private)  DbExpr where
          The where clause to select rows for deletion.
 
Constructor Summary
(package private) DbDeleter(DbAbstractTable table)
          Builds a new DbDeleter object.
 
Method Summary
 int execute()
          Execute this command on the default connection.
 int execute(DbConnection dbcon)
          Execute this delete command on a specific connection.
(package private)  java.lang.String getQueryString()
          Returns the query string related to this deleter.
 void setWhere(DbExpr where)
          Set the where condition for this delete operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

DbAbstractTable table
The table for this operation.


where

DbExpr where
The where clause to select rows for deletion.

Constructor Detail

DbDeleter

DbDeleter(DbAbstractTable table)
Builds a new DbDeleter object.

Method Detail

setWhere

public void setWhere(DbExpr where)
Set the where condition for this delete operation.


execute

public int execute(DbConnection dbcon)
            throws DbException
Execute this delete command on a specific connection.


execute

public int execute()
            throws DbException
Execute this command on the default connection.


getQueryString

java.lang.String getQueryString()
                          throws DbException
Returns the query string related to this deleter.