Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Inheriting....

...

Entity and Table Annotations For Class

Code Block

@Entity

...


@Table(name = "lams_learning_activity")

If the object is the root of an inheritance hierachy then add

Code Block

@Inheritance(strategy = InheritanceType.SINGLE_TABLE)

...


@DiscriminatorColumn(name = "learning_activity_type_id", discriminatorType = DiscriminatorType.INTEGER)

Then in the subclass add the Discriminator

Code Block

@DiscriminatorValue("2")

Id field

Code Block
@Id
@Column
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long uid;

...

Add a @Column annotations for all other persistent fields. Just use name and columnDefinition options. Name is required (and should be omitted) if the name of the field is identical to the name of the column. If you want to note anything special about the column use the columnDefinition option. The column definition and the other options (length, type, etc) are only for DDL so no point meticulously recording them all when we maintain the database manually - we just risk the definitions in the code getting out of sync with the database.

If the field is the DiscriminatorColumn (see above) then use:

Code Block

@Column(name = "learning_activity_type_id", insertable = false, updatable = false)

Transient Annotation

Every non-static and non-transient property are assumed persistent so any temporary values (and some POJOs are used in the web layer) must be marked as @Transient.

...