jpa Basic mapping A very simple entity


Example

@Entity
class Note {
    @Id
    Integer id;
 
    @Basic
    String note;

    @Basic
    int count;
}

Getters, setters etc. are ommitted for brevity, but they are not needed for JPA anyway.

This Java class would map to the following table (depending on your database, here given in one possible Postgres mapping):

CREATE TABLE Note (
  id integer NOT NULL,
  note text,
  count integer NOT NULL
)

JPA providers may be used to generate the DDL, and will likely produce DDL different from the one shown here, but as long as the types are compatible, this will not cause problems at runtime. It is best not to rely on auto-generation of DDL.