-
Notifications
You must be signed in to change notification settings - Fork 16
SQL Delete
To bind a DAO interface method to an DELETE SQL statement is necessary to decorate it with @BindSqlDelete. Like other SQL statement type, you can write the entire JQL statement or write only specific parts of the JQL statement. You can use the bean as the input parameter or method parameters like bean property, but you can not use mixed case. This annotation can be used only on DAO's interface methods.
For example, suppose we persist bean Person defined as follow:
@BindType
public class Person {
public long id;
public String name;
public String surname;
public String birthCity;
public Date birthDay;
}
The associated DAO interface is
@BindDao(Person.class)
public interface PersonDAO { }
It's possible to define a DELETE query with annotation BindSqlDelete
. It is possible to define query parameter simply using method parameter with the same name of the bean property.
@BindDao(Person.class)
public interface PersonDAO {
@BindDelete(where="name=${name} and surname=${surname}")
void deleteOne(String name, @BindSqlParam("surname") temp);
@BindDelete(where="name=${name} and surname=${surname}")
long deleteTwo(String name, @BindSqlParam("surname") temp);
}
Each method parameter will be used like input parameter for the query. The name of parameters will be used to map field bean and then the column name of the associated table. If you specify a return type for methods (like method insertTwo
), it has to be of type int, long, Integer, Long. In this case, the return value will be the id value of just inserted row.
The other way to define a DELETE SQL is using a bean as input parameter:
@BindDao(Person.class)
public interface PersonDAO {
@BindDelete(where = " id = ${bean.id} ")
void deleteThree(Person bean);
}
If you specify a return type for methods, it has to be of type int, long, Integer, Long and it will contain the number of deleted rows.
For more informations, consult @BindSqlDelete.
- Introduction
- Goals & Features
- Kotlin
- Immutable or Mutable Pojo
- Annotation Processor Args
- Credits
- Articles
- Benchmarks
- Setup
- Tutorial
- Usage
- Dependencies and inspirations
- Stackoverflow
- Documentation
- SQL logging
- Data source options
- Indices
- SQL Type adapter
- Global SQL Type adapter
- Constraints
- Live data: welcome Architectural components!!
- Paged Live data
- Dynamic parts
- Transactional and batch operations
- Async Transactional and batch operations
- Global transaction
- Support for immutable POJO
- Generate Content provider
- Generate Database schema generation
- Database migration
- BindSqlColumn
- BindContentProvider
- BindContentProviderEntry
- BindContentProviderPath
- BindDao
- BindDaoMany2Many
- BindDataSource
- BindDataSourceOptions
- BindDataSourceUpdateTask
- BindIndex
- BindSqlRelation
- BindSqlAdapter
- BindSqlChildSelect
- BindSqlDelete
- BindSqlDynamicOrderBy
- BindSqlDynamicWhere
- BindSqlDynamicWhereParams
- BindSqlInsert
- BindSqlPageSize
- BindSqlParam
- BindSqlSelect
- BindSqlUpdate
- BindSqlType
- BindSqlTransaction