Stereotypes of the UML-to-JPA transformation profile

The UML-to-JPA transformation profile contains stereotypes that you can apply to parameters, properties, documentation, specific relationships, classes, packages, and models. The transformation transforms only the stereotypes that are applied to elements in classes that have the «Entity» stereotype applied.
The following table lists the stereotypes of the profile, their related properties and types, and the code that the transformation generates.
Note: In the transformation configuration, if you set the Generate deployment descriptor property to true, the transformation generates equivalent annotations in the persistence.xml file instead of in the Java code.
Stereotype Applies to Properties Constraints Generated code
«Entity» Classes name

catalog
schema

Generated bean does not specify the final keyword, is not a nested class, and has an ID. Java class with the following characteristics:
  • @Entity annotation
  • Other Java bean requirements such as an ID and default constructor
  • If you specify values for the stereotype properties, a @Table annotation that has corresponding attributes and the values that you specify
«Inheritance» Classes with the «Entity» stereotype applied. This stereotype identifies how other Entity classes inherit from this Entity class. discriminatorColumn: Identifies the discriminator column. This property is used only if the strategy property is set to SINGLE_TABLE.

discriminatorType: Identifies the column type that is used as a discriminator.
strategy: This property is of type InheritanceStrategy.

Generated single tables contain a discriminator value and discriminator type.

Other inheritance strategies do not have discriminator values and discriminator types.

 
«DiscriminatorValue» Classes with the following characteristics:
  • «Entity» stereotype applied
  • Single Table inheritance strategy, or inherits from a class with a Single Table inheritance strategy
This stereotype identifies how other Entity classes inherit from this Entity class.
Value   Entity classes with a @DiscriminatorValue annotation that contains the value that is specified in the value property
«SequenceGenerator» Classes with the «Entity» stereotype applied, or a property in a class that has the «Entity» stereotype applied. allocationSize

initialValue
name
sequenceName

  @SequenceGenerator annotation for the generated class or field
«TableGenerator»   @TableGenerator annotation for the generated class or field
«Relationship Options» Associations between two classes that have the «Entity» stereotype applied. cascade

fetch
optional

  Entity relationship between the generated classes
«JoinColumn» Associations other than many-to-many or directional one-to-many associations between two classes that have the «Entity» stereotype applied. columnDefinition

insertable
name
nullable
primaryKey
referencedColumnName
table
unique
updatable

 
  • If the primaryKey property is set to true, the transformation generates a @PrimaryKeyJoinColumn or @PrimaryKeyJoinColumns annotation that has corresponding attributes and the values that you specify
  • If the primaryKey property is set to false, the transformation generates a @JoinColumn or @JoinColumns annotation that has corresponding attributes and the values that you specify
  • The transformation also generates an annotation that corresponds to the type of association between the classes, as in this example: @OneToOne
«JoinColumn», «JoinTable», or both Many-to-many or directional one-to-many associations between two classes that have the «Entity» stereotype applied.

catalog
inverseJoinColumns_columnDefinition
inverseJoinColumns_insertable
inverseJoinColumns_name
inverseJoinColumns_nullable
inverseJoinColumns_referencedColumnName
inverseJoinColumns_table
inverseJoinColumns_unique
inverseJoinColumns_updatable
name
schema

 
  • Annotation that corresponds to the type of association between the classes, as in this example: @ManyToMany
  • @JoinTable annotation that contains the following information:
    • Attributes that correspond to the stereotype properties and the values that you specify for the properties
    • Attributes that correspond to the properties of the «JoinColumn» stereotype, and the values that you specify for the properties
«Id» Properties     Java field with an @Id annotation. The transformation also generates code for the equals and hashCode operation.

The transformation ignores the stereotype if the «Entity» stereotype is not applied to the class that contains the property.

If more than one «Id» stereotype exists in the same entity class, the transformation creates the following things:
  • A primary key class named beannamePK. This class has an @Embeddable notation and contains the generated Java fields.
  • In the bean class, a property named pk that is of type primary key class. This property has an @EmbeddedID notation.

The hashCode and equals operations reference the hashCode and equals operations in the Embeddable class.

«Basic» Properties in classes that have the «Entity» stereotype applied fetch

optional

  @Basic annotation on the properties that specify values for all of the properties in the stereotype
«Column» columnDefinition

insertable
length
name
nullable
precision
scale
table
unique
updatable

  @Column annotation on the properties that specify values for all the properties of the stereotype
«Enumerated» Value   @Enumerated annotation on the properties that specify values for all the properties of the stereotype
«GeneratedValue» generated

strategy

  @GeneratedValue annotation for the generated field, and corresponding attributes with the values that you specify in the stereotype properties
«Lob»     @Lob annotation for the generated field

If the «Basic» stereotype is not applied to the property in the model, the transformation adds the @Basic annotation and sets the type of the property to FetchTypeLazy

«Temporal» Value   @Temporal annotation on generated field
«Callback» Operations in classes that have the «Entity» stereotype applied Value, which specifies an array of Callback types   Annotation that corresponds to the values that you select for the operation
«Datasource» Actors     References from message-driven beans and session beans to the data source that the stereotype specifies

Feedback