Interface Dao<T>
public interface Dao<T>
Runtime contract a build-time-generated @Entity data access object
implements. Application code rarely references Dao by name -- the typed
dao is reached through EntityManager.dao(EntityClass.class).
All methods throw IOException for the same reasons com.codename1.db
does: the underlying SQLite driver propagates IO failures, locking
failures, and constraint violations through IOException.
-
Method Summary
Modifier and TypeMethodDescriptionvoidConnects this dao to aDatabaseinstance.voidCREATE TABLE IF NOT EXISTS ....voidDELETE ... WHERE id = ?.voidDROP TABLE IF EXISTS ....Free-form WHERE clause;whereis appended verbatim afterWHEREandparamsfills the?placeholders.findAll()SELECT * FROM ....SELECT ... WHERE id = ?.voidINSERT INTO ....The SQL table name.type()The entity class this dao handles.voidUPDATE ... WHERE id = ?.
-
Method Details
-
type
-
tableName
String tableName()The SQL table name. Defaults to the simple class name; an explicit@Entity(table="...")wins. -
attach
Connects this dao to aDatabaseinstance. Called byEntityManager.dao(Class); the same dao is reused for the lifetime of the entity manager. -
createTable
void createTable() throws java.io.IOExceptionCREATE TABLE IF NOT EXISTS .... Idempotent.- Throws:
java.io.IOException
-
dropTable
void dropTable() throws java.io.IOExceptionDROP TABLE IF EXISTS ....- Throws:
java.io.IOException
-
insert
INSERT INTO .... When the entity has an auto-increment@Id, the generated id is written back into the instance viaSELECT last_insert_rowid().- Throws:
java.io.IOException
-
update
UPDATE ... WHERE id = ?.- Throws:
java.io.IOException
-
delete
DELETE ... WHERE id = ?.- Throws:
java.io.IOException
-
findById
-
findAll
-
find
-