|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.j256.ormlite.misc.BaseDaoEnabled<T,ID>
public abstract class BaseDaoEnabled<T,ID>
Base class that your data elements can extend which allow them to refresh, update, etc. themselves. ORMLite will
automagically set the appropriate Dao
on the class if it is received by a query but if you are trying to
create the class, you will need to either create it through the DAO or set the dao on it directly with
setDao(Dao)
.
NOTE: The default pattern is to use the Dao
classes to operate on your data classes. This will allow
your data classes to have their own hierarchy and isolates the database code in the Daos. However, you are free to
use this base class if you prefer this pattern.
NOTE: The internal Dao field has been marked with transient so that it won't be serialized (thanks jc). If you do de-serialize on these classes, you will need to refresh it with the Dao to get it to work again.
Field Summary | |
---|---|
protected Dao<T,ID> |
dao
|
Constructor Summary | |
---|---|
BaseDaoEnabled()
|
Method Summary | |
---|---|
int |
create()
A call through to the Dao.create(Object) . |
int |
delete()
A call through to the Dao.delete(Object) . |
ID |
extractId()
A call through to the Dao.extractId(Object) . |
Dao<T,ID> |
getDao()
Return the DAO object associated with this object. |
boolean |
objectsEqual(T other)
A call through to the Dao.objectsEqual(Object, Object) . |
String |
objectToString()
A call through to the Dao.objectToString(Object) . |
int |
refresh()
A call through to the Dao.refresh(Object) . |
void |
setDao(Dao<T,ID> dao)
Set the Dao on the object. |
int |
update()
A call through to the Dao.update(Object) . |
int |
updateId(ID newId)
A call through to the Dao.updateId(Object, Object) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient Dao<T,ID> dao
Constructor Detail |
---|
public BaseDaoEnabled()
Method Detail |
---|
public int create() throws SQLException
Dao.create(Object)
.
SQLException
public int refresh() throws SQLException
Dao.refresh(Object)
.
SQLException
public int update() throws SQLException
Dao.update(Object)
.
SQLException
public int updateId(ID newId) throws SQLException
Dao.updateId(Object, Object)
.
SQLException
public int delete() throws SQLException
Dao.delete(Object)
.
SQLException
public String objectToString()
Dao.objectToString(Object)
.
public ID extractId() throws SQLException
Dao.extractId(Object)
.
SQLException
public boolean objectsEqual(T other) throws SQLException
Dao.objectsEqual(Object, Object)
.
SQLException
public void setDao(Dao<T,ID> dao)
Dao
on the object. For the create()
call to work, this must be done beforehand by the
caller. If the object has been received from a query call to the Dao then this should have been set
automagically.
public Dao<T,ID> getDao()
setDao(Dao)
has already been called.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |