public class LitePalSupport
extends java.lang.Object
public class Person extends LitePalSupport {
private int id;
private String name;
private int age;
}
The Person class is automatically mapped to the table named "person",
which might look like this:
CREATE TABLE person (
id integer primary key autoincrement,
age integer,
name text
);
| 限定符和类型 | 字段和说明 |
|---|---|
protected static java.lang.String |
AES
Constant for AES encryption.
|
protected static java.lang.String |
MD5
Constant for MD5 encryption.
|
| 限定符 | 构造器和说明 |
|---|---|
protected |
LitePalSupport()
Disable developers to create instance of LitePalSupport directly.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
assignBaseObjId(long baseObjId)
Assigns value to baseObjId.
|
void |
clearSavedState()
It model is saved, clear the saved state and model becomes unsaved.
|
int |
delete()
Deletes the record in the database.
|
UpdateOrDeleteExecutor |
deleteAsync()
已过时。
|
protected long |
getBaseObjId()
Get the baseObjId of this model if it's useful for developers.
|
protected java.lang.String |
getClassName()
Get the full class name of self.
|
protected java.lang.String |
getTableName()
Get the corresponding table name of current model.
|
boolean |
isSaved()
Current model is saved or not.
|
boolean |
save()
Saves the model.
|
SaveExecutor |
saveAsync()
已过时。
|
boolean |
saveOrUpdate(java.lang.String... conditions)
Save the model if the conditions data not exist, or update the matching models if the conditions data exist.
|
SaveExecutor |
saveOrUpdateAsync(java.lang.String... conditions)
已过时。
|
void |
saveThrows()
Saves the model.
|
void |
setToDefault(java.lang.String fieldName)
When updating database with
update(long), you must
use this method to update a field into default value. |
int |
update(long id)
Updates the corresponding record by id.
|
int |
updateAll(java.lang.String... conditions)
Updates all records with details given if they match a set of conditions
supplied.
|
UpdateOrDeleteExecutor |
updateAllAsync(java.lang.String... conditions)
已过时。
|
UpdateOrDeleteExecutor |
updateAsync(long id)
已过时。
|
protected static final java.lang.String MD5
protected static final java.lang.String AES
protected LitePalSupport()
public int delete()
Person person;
....
if (person.isSaved()) {
person.delete();
}
@Deprecated public UpdateOrDeleteExecutor deleteAsync()
public int update(long id)
Person person = new Person();
person.setName("Jim");
person.update(1);
This means that the name of record 1 will be updated into Jim.setToDefault(String) to update
columns into default value. 2. This method couldn't update foreign key in
database. So do not use setXxx to set associations between models.id - Which record to update.@Deprecated public UpdateOrDeleteExecutor updateAsync(long id)
public int updateAll(java.lang.String... conditions)
Person person = new Person();
person.setName("Jim");
person.updateAll("name = ?", "Tom");
This means that all the records which name is Tom will be updated into
Jim.setToDefault(String) to update
columns into default value. 2. This method couldn't update foreign key in
database. So do not use setXxx to set associations between models.conditions - A string array representing the WHERE part of an SQL
statement. First parameter is the WHERE clause to apply when
updating. The way of specifying place holders is to insert one
or more question marks in the SQL. The first question mark is
replaced by the second element of the array, the next question
mark by the third, and so on. Passing empty string will update
all rows.@Deprecated public UpdateOrDeleteExecutor updateAllAsync(java.lang.String... conditions)
public boolean save()
Person person = new Person();
person.setName("Tom");
person.setAge(22);
person.save();
If the model is a new record gets created in the database, otherwise the
existing record gets updated.@Deprecated public SaveExecutor saveAsync()
public void saveThrows()
Person person = new Person();
person.setName("Tom");
person.setAge(22);
person.saveThrows();
If the model is a new record gets created in the database, otherwise the
existing record gets updated.LitePalSupportExceptionpublic boolean saveOrUpdate(java.lang.String... conditions)
Person person = new Person();
person.setName("Tom");
person.setAge(22);
person.saveOrUpdate("name = ?", "Tom");
If person table doesn't have a name with Tom, a new record gets created in the database,
otherwise all records which names are Tom will be updated.conditions - A string array representing the WHERE part of an SQL
statement. First parameter is the WHERE clause to apply when
updating. The way of specifying place holders is to insert one
or more question marks in the SQL. The first question mark is
replaced by the second element of the array, the next question
mark by the third, and so on. Passing empty string will update
all rows.@Deprecated public SaveExecutor saveOrUpdateAsync(java.lang.String... conditions)
public boolean isSaved()
public void clearSavedState()
public void setToDefault(java.lang.String fieldName)
update(long), you must
use this method to update a field into default value. Use setXxx with
default value of the model won't update anything. fieldName - The name of field to update into default value.public void assignBaseObjId(long baseObjId)
baseObjId - Assigns value to baseObjId.protected long getBaseObjId()
protected java.lang.String getClassName()
protected java.lang.String getTableName()