Skip to content

Commit

Permalink
define order on annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Jul 2, 2022
1 parent b7d65d9 commit e2bdf5b
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions spec/src/main/asciidoc/annotations.adoc
Expand Up @@ -29,8 +29,8 @@ The annotation model converts the entity model into the entity on communication,
* Id
* Embeddable
* Convert
* Inheritance
* MappedSuperclass
* Inheritance
* DiscriminatorColumn
* DiscriminatorValue

Expand Down Expand Up @@ -118,36 +118,6 @@ public class Person {
}
----

===== @MappedSuperclass

The class with the `@MapperSuperclass` annotation will have all attributes considered as an extension of this subclass with an `@Entity` annotation. In this case, all attributes are going to be stored, even the attributes inside the super class.

This means, that this annotation causes fields annotated with `@Column` in a parent class to be persisted together with the child class' fields.


[source,java]
----
@Entity
public class Dog extends Animal {
@Column
private String name;
}
@MappedSuperclass
public class Animal {
@Column
private String race;
@Column
private Integer age;
}
----

On the example above, when saving a Dog instance, Animal class' fields are saved too: `name`, `race`, and `age` are saved in a single instance.


===== @Id

This annotation defines which attribute is the entity's ID, or the Key in Key-Value databases. In such a case, the Value is the remaining information. It has a single attribute (like `@Column`) to define the native name. Unlike `@Column`, the default value is `_id`.
Expand Down Expand Up @@ -314,6 +284,38 @@ The above classes are mapped to:
]
}
----


===== @MappedSuperclass

The class with the `@MapperSuperclass` annotation will have all attributes considered as an extension of this subclass with an `@Entity` annotation. In this case, all attributes are going to be stored, even the attributes inside the super class.

This means, that this annotation causes fields annotated with `@Column` in a parent class to be persisted together with the child class' fields.


[source,java]
----
@Entity
public class Dog extends Animal {
@Column
private String name;
}
@MappedSuperclass
public class Animal {
@Column
private String race;
@Column
private Integer age;
}
----

On the example above, when saving a Dog instance, Animal class' fields are saved too: `name`, `race`, and `age` are saved in a single instance.


==== @Database

This annotation allows programmers to specialize `@Inject` annotations to choose which specific resource should be injected.
Expand Down

0 comments on commit e2bdf5b

Please sign in to comment.