@Transient (jpa)
The @Transient
annotation is part of the Jakarta Persistence API (JPA) and is used to indicate that a field or property of an entity should not be persisted to the database.
Fields marked with @Transient
are ignored by the JPA provider during persistence operations.
Such fields are useful for temporary, calculated, or helper fields that should not be stored.
In particular, injected services should be annotated with @Transient
Although this annotation is recognised by Causeway, its metadata is currently unused.
Usage
Annotate a field or getter in your entity class with @Transient
to exclude it from persistence:
import jakarta.persistence.Entity;
import jakarta.persistence.Transient;
@Entity
public class Product {
@Column(length=100)
private String name;
// ...
@Transient (1)
@Inject
private RepositoryService repositoryService;
}
1 | indicates that this injected service should be ignored so far as persistence goes. |
See Also
-
@Transient (JPA API javadoc)