Devender Yadav edited this page May 24, 2016 · 9 revisions
Clone this wiki locally

Basic Rules

  • Entity classes must be annotated with  @Entity
  • Entity and embeddable classes must have a default no-argument constructor.
  • Each entity must have a field annotated with @Id. This will be persisted as row key.
  • There must be 1 and only 1 @Id per entity.
  • Primary Key and Column fields type must be according to supported data types.
  • All fields annotated with @Embedded and @ElementCollection are stored within the table. e.g. Super column(s)/User Defined Type(s) in cassandra and nested document(s) in MongoDB.
  • Fields annotated with @Embedded and @ElementCollection must be a class annotated with @Embeddable with their class definition. (The JPA way!)
  • Relationship entities annotated with @OneToOne, @OneToMany etc must be another entity class. (All above rules apply to them). They are stored as separate tables and foreign keys are maintained by kundera. (we'll get to that later)


Kundera does not add any new annotation to the JPA set of annotations. Rather, it gives new meaning to existing ones so that:

  • The time to get started with Kundera is very less and you can journey ahead with Kundera, the usual JPA-way.
  • There is a uniformity in annotation set across all data-stores
  • Some major annotations used by Kundera:

    1. javax.persistence.Entity
    2. javax.persistence.Table
    3. javax.persistence.Id
    4. javax.persistence.Column
    5. javax.persistence.Embedded
    6. javax.persistence.ElementCollection
    7. javax.persistence.CollectionTable
    8. javax.persistence.Embeddable
    9. javax.persistence.OneToOne
    10. javax.persistence.OneToMany
    11. javax.persistence.ManyToOne
    12. javax.persistence.ManyToMany
    13. javax.persistence.JoinColumn

      ...and so on.

  • Here is a graphical representation of what different annotations map to your datastore terminology. Annotation Table