TRIMM JPA supported UML Stereotypes and Tagged Values

See here for the TRIMM Java supported UML Stereotypes and Tagged Values

Generic JPA stereotypes and Tagged Values

Name (case insensitive) Type Applies to Decription
Embedded Stereotype UML Class Any class marked with this stereotype will be transformed into a @Embedded JPA class
Lob Stereotype UML Property Marks a property as a @Lob candidate – other options for Lob candidates are:

  • String with an upper bound larger than 4000
  • byte[]
  • char[]
  • java.sql.Blob
  • java.sql.Clob
Transient Stereotype UML Property Can be applied to a property to indicate that the property is @Transient (ie. shouldn’t be persisted)
Id Stereotype UML Property Stereotype value that can be applied to a Simple property to specify the property is the JPA @Id property
Eager Stereotype UML Association/Role Stereotype value that can be applied to associations and/or Association Roles/Ends to specify the this association should be loaded Eagerly
Lazy Stereotype UML Association/Role Stereotype value that can be applied to Associations and/or Association Roles/Ends to specify the this association should be loaded Lazily.
Cascade Tagged value UML Association Cascade option tagged value name, which can be used on association to specify different cascading values than the default (which is CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH).
Note: The Value must contain fully qualified class names (FQCN’s)
Orderby Tagged Value UML Property Tagged value that can be applied to One-To-Many Associations (that are transformed to contain @ElementCollection) which already have Embedded and Ordered stereotypes applied. Will transform the association to have an @OrderBy annotation (with the value of the Orderby tagged value as parameter)

Hibernate specific Stereotypes and Tagged values

Name (case insensitive) Type Applies to EventListener Decription
unique_index Tagged value UML Property HibernateIndexingListener Applies a “uniqueConstraints” annotation attribute to all classes with the JPA @Table annotation and which has properties with the tagged value unique_index**
index Tagged value UML Property HibernateIndexingListener Applies the Hibernate specific @Table annotation to specify Indexes for each class carrying the JPA @Table annotation and which has properties with the index tagged value. **
History / Audit Stereotype UML Class / Property / Association HibernateEnversListener Applies an Envers @Audited annotation to the Class or Java field that maps the Property/Association
NoHistory / NoAudit Stereotype UML Class / Property / Association HibernateEnversListener Applies an Envers @NotAudited annotation to the Class or Java field that maps the Property/Association
FetchMode Tagged value UML Property / Association Role HibernateFetchOptimizationListener Controls the Hibernate FetchMode or LazyCollection annotations. This tagged value can have a value among these options:

Value Decription
SubSelect Can be placed on One-to-Many and Many-to-Many property/association role. Is transformed into a Hibernate @Fetch annotation with FetchMode.SUBSELECT
Select Can be placed on all properties/association roles. Is transformed into a Hibernate @Fetch annotation with FetchMode.SELECT
Join Can be placed on all properties/association roles. Is transformed into a Hibernate @Fetch annotation with FetchMode.JOIN
ExtraLazy Can be placed on One-to-Many and Many-to-Many property/association role. Is transformed into a Hibernate @LazyCollection annotation with LazyCollectionOption.EXTRA
BatchSize Tagged value UML Class / UML Property / Association Role HibernateFetchOptimizationListener Can be placed on the Class, One-to-Many and Many-to-Many property/association role. Applies a Hibernate @BatchSize annotation with the “size” attribute set to the value of the tagged value.
NotNull Stereotype UML Property / Association role HibernateValidatorNotNullListener Support for Hibernate Validator @NotNull annotation
Supports @NotNull (specified using Stereotypes in order to avoid the Hibernate bug specified at
https://hibernate.onjira.com/browse/HHH-3544) and by specifically applying NotNull to required xToOne properties in subclasses where the @InheritanceType doesn’t support making properties required
 

In order to use this @NotNull feature, you have to make sure that the NotNull’s AREN’T transformed to the SQL Schema. This is done by running Hibernate with the following setting: hibernate.validator.apply_to_ddl=falsePlease check https://hibernate.onjira.com/browse/HHH-3544 for details

** Rules for the index and unique_index tagged values value:
The value of the index/unique_index tagged value must adhere to the following pattern: Name[,Order in the Index]. (Note: Name isn’t supported by Hibernate for Unique indexes, but must still be applied in the tagged value)

The optional “Order in the Index” tells in which order the columns should be listed, when defining the index (the order is 1-based).

If there are more than one property with the same index name, you MUST apply “Order in the Index”.

Value Examples:

EstateNumber_ix
EstateNumber_ix,1
EstateNumber_ix,2