Annotation Type Entity


@Retention(CLASS) @Target(TYPE) public @interface Entity

Marks a POJO or PropertyBusinessObject as a target for the SQLite ORM processor.

At build time the Codename One Maven plugin generates a reflection-free Dao next to the class with createTable, insert, update, delete, findById, findAll, and find(where, params) methods. Application code reaches the generated dao through com.codename1.orm.EntityManager:

@Entity(table="users")
public class User {
    @Id(autoIncrement=true) public long id;
    @Column(name="full_name") public String name;
    public int age;
}

EntityManager em = EntityManager.open("MyDB");
Dao<User> users = em.dao(User.class);
users.createTable();
users.insert(new User());

The dao uses the same prepared-statement protocol as the existing com.codename1.db.Database; no Class.forName lookups, so the binding survives ParparVM rename / R8 obfuscation in shipped builds.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    SQL table name.
  • Element Details

    • table

      String table
      SQL table name. Defaults to the simple class name when blank.
      Default:
      ""