addJPAAnnotations

Description

If you activate this configuration toggle via the builder method withJPAAnnotations the generator scans the selected classes for the following JPA Annotations:

  • class annotations

    • javax.persistence.Index

    • javax.persistence.UniqueConstraint

    • javax.persistence.Entity

    • javax.persistence.Table

    • javax.persistence.MappedSuperclass

    • jakarta.persistence.Index

    • jakarta.persistence.UniqueConstraint

    • jakarta.persistence.Entity

    • jakarta.persistence.Table

    • jakarta.persistence.MappedSuperclass

  • field annotations

    • javax.persistence.Column

    • javax.persistence.Id

    • javax.persistence.Transient

    • jakarta.persistence.Column

    • jakarta.persistence.Id

    • jakarta.persistence.Transient

  • relationship annotations

    • javax.persistence.OneToOne

    • javax.persistence.OneToMany

    • javax.persistence.ManyToMany

    • javax.persistence.ManyToOne

    • jakarta.persistence.OneToOne

    • jakarta.persistence.OneToMany

    • jakarta.persistence.ManyToMany

    • jakarta.persistence.ManyToOne

If class annotations are found the generator adds a separate compartment to the head of the PlantUML class with all informations found in these annotations.

If field annotations are found the generator adds them right before the field name in the PlantUML class.

If relationship annotations are found they are added to the relationships between the different classes in the PlantUML diagram.

Default value

The default value of this configuration toggle is false.

Example

In the following example there are three dependencies in the maven dependency hierarchy which build the classpath for all further generation:

	<dependencies>
		<dependency>
			<groupId>de.elnarion.util</groupId>
			<artifactId>plantuml-generator-util</artifactId>
			<version>@project.version@</version>
			<classifier>tests</classifier>
			<type>test-jar</type>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.16.1</version>
		</dependency>
		<dependency>
			<groupId>javax.persistence</groupId>
			<artifactId>javax.persistence-api</artifactId>
			<version>2.2</version>
		</dependency>	
	</dependencies>

From this classpath all classes of the package "de.elnarion.test.domain.t0021", which are also used by the JUnit-tests of the PlantUML generator utility, should be generated as class diagram with the following plugin configuration

			<plugin>
				<artifactId>plantuml-generator-maven-plugin</artifactId>
				<groupId>de.elnarion.maven</groupId>
				<version>@project.version@</version>
				<executions>
					<execution>
						<id>generate-simple-diagram</id>
						<goals>
							<goal>generate</goal>
						</goals>
						<phase>generate-test-sources</phase>
						<configuration>
							<outputFilename>testdiagram1.txt</outputFilename>
							<scanPackages>
								<scanPackage>de.elnarion.test.domain.t0021</scanPackage>
							</scanPackages>
							<addJPAAnnotations>true</addJPAAnnotations>
						</configuration>
					</execution>
				</executions>
			</plugin>

this configuration contains the addJPAAnnotations toggle with the value true. This configuration is rendered this way:

0021_jpa_annotations_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0021.Address <<Entity>>  {
}


class de.elnarion.test.domain.t0021.Employee <<MappedSuperclass>>  {
	{field} +@Id empId : Integer
	{field} #version : Integer
}


class de.elnarion.test.domain.t0021.FTEmployee <<Entity>>  <<Table>>  {
 {TableIndexes=\n\tIndex (columnList=[salaray,empId],unique=[true] )\n\tIndex (columnList=[version],unique=[false] )\n}
 {TableName=FTEmployee}
 {TableUniqueConstraints=\n\tUniqueConstraint (columnNames=[empId,version] )\n\tUniqueConstraint (columnNames=[empId] )\n}
--
	{field} +salary : Integer
}


class de.elnarion.test.domain.t0021.Family <<Entity>>  {
	{field} +description : String
	{field} +@Id id : int
}


class de.elnarion.test.domain.t0021.Job <<Entity>>  {
	{field} +@Id id : int
	{field} +jobDescr : String
	{field} +salery : double
}


class de.elnarion.test.domain.t0021.Person <<Entity>>  {
	{field} +firstName : String
	{field} +@Id id : String
	{field} +lastName : String
	{field} +@Transient nonsenseField : String
}


class de.elnarion.test.domain.t0021.Todo <<Entity>>  <<Table>>  {
 {TableName=TABLENAME}
 {TableSchema=SCHEMA}
--
	{field} +@Column("DESCR") description : String
	{field} +@Column("IDX") @Id id : Long
}


enum de.elnarion.test.domain.t0021.TodoStateEnum {
	{field} +CLOSED
	{field} +IN_PROGRESS
	{field} +OPEN
}




de.elnarion.test.domain.t0021.Employee -->  de.elnarion.test.domain.t0021.Address :  @ManyToOne\naddress
de.elnarion.test.domain.t0021.FTEmployee --|>  de.elnarion.test.domain.t0021.Employee
de.elnarion.test.domain.t0021.Family "1" o-- "0..*"  de.elnarion.test.domain.t0021.Person :  @OneToMany\nmembers
de.elnarion.test.domain.t0021.Person "1" o-- "0..*"  de.elnarion.test.domain.t0021.Job :  @OneToMany\njobList
de.elnarion.test.domain.t0021.Person -->  de.elnarion.test.domain.t0021.Family :  @ManyToOne\nfamily
de.elnarion.test.domain.t0021.Todo -->  de.elnarion.test.domain.t0021.TodoStateEnum :  @Column("STATE")\nstate


@enduml