A type of JPA (Java Persistence API) mapping configuration for applications. The other is, XML.
Questions tagged [jpa-annotations]
29 questions
160
votes
5 answers
Java - JPA - @Version annotation
How does @Version annotation work in JPA?
I found various answers whose extract is as follows:
JPA uses a version field in your entities to detect concurrent modifications to the same datastore record. When the JPA runtime detects an attempt to…

Amit
- 33,847
- 91
- 226
- 299
12
votes
1 answer
JPA/Hibernate @OrderBy annotation with multiple columns and ASC/DESC for each
I would like to sort a OneToMany field with the @OrderBy annotation with multiple columns and specify the sort order for each but I can't seem to find the info anywhere on whether how to or if it's impossible.
The specs for the annotation…

Sandy
- 547
- 3
- 9
- 20
5
votes
1 answer
Hibernate Sequence Generator is not Consistent
I have a table with promotion id annotated as
@SequenceGenerator(name="GEN_PROMID", sequenceName="SEQ_PROMOTIONID", allocationSize=1)
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="GEN_PROMID")
@Column(name="PROMOTIONID")
private…

abhihello123
- 1,668
- 1
- 22
- 38
4
votes
1 answer
Are these @Table(uniqueConstraints) and @Table(indexes) annotations the same?
When creating indexes in JPA / Hibernate, are these exactly the same?
@Table (uniqueConstraints = @UniqueConstraint (columnNames = {"series", "date"}))
And:
@Table (indexes = {@Index (name = "idx", columnList = "series, date", unique = true)})
And…

Marcelo Glasberg
- 29,013
- 23
- 109
- 133
4
votes
1 answer
Hibernate recursive mapping parent/child structure - StackOverflowError when retrieve data
I am using Hibernate 5.2.7.Final, and native Hibernate API.
I have an Employee entity with recursive relations:
@Entity
public class Employee {
@Id
@GeneratedValue
private Long employeeId;
@Column
private String firstname;
…

Dang Nguyen
- 43
- 1
- 1
- 4
4
votes
1 answer
EclipseLink - non Entity as target entity in the relationship attribute
I am using the Netbeans IDE 8.0.2 and eclipselink 2.5.2.
This occurring exception below when opening a connection, the problem is that this does not happen every time.
The entity described in exception "Departmento" exactly follows the pattern of…

João Eduardo Bertotti
- 63
- 1
- 7
2
votes
1 answer
Problem with saving foreign key with @OneToOne annotation. Saving as null
I have two entities (Project, OtherData) with one abstract entity. I'm using MySQL and Quarkus framework.
Problem: When I try to save Project entity field project_id remains null.
Table schemas:
On next picture there is shown, fk constraint in…

act_inGlasses
- 23
- 5
2
votes
2 answers
@oneToMany with @JoinTable have unique constraint in jpa?
I have a two tables which are USER entity have
@OneToMany
@JoinTable(name="user_roles")
private List roles;
Role Entity have User
@ManyToOne
private User user;
Desc of table user_role is
Name Null
USER_RECORD_ID …

Gopi Lal
- 417
- 5
- 23
2
votes
1 answer
Is it possible to override the Field constraint on a field in a child class
I have a parent class lets call it Parent
public class Parent {
@Basic(optional = false)
String stringOne;
@Basic(optional = false)
String stringTwo;
public String getStringOne() {
return stringOne;
}
public void…

Nick Div
- 5,338
- 12
- 65
- 127
2
votes
1 answer
Generating annotated ( @NamedPLSQLStoredFunctionQuery / @NamedPLSQLStoredProcedureQuery) queries
Environment
- JavaSE 6, Oracle 11, WebSphere 7, eclipseLink 2.5.2 / 2.6.0
Use Case
In our project we use (call from Java) lot of PL/SQL procedures, and functions.
We would like to generate annotated queries like
@NamedPLSQLStoredFunctionQuery(name…

Jan Horyna
- 21
- 1
1
vote
0 answers
Possible to retrieve selected children list from database only by using JPA/Hibernate-Annotation?
Guess this might be a difficult one. Well, at least for me. I need some help with JPA/Hibernate-Annotations and I was wondering, if there is a way to solve my problem. Unfortunately, my own skills seem too limited to solve that problem by myself.…

Tessaiga
- 11
- 2
1
vote
2 answers
@Version annotation does not work correctly
I use Java Persistence versioning in Spring Boot project for handling optimistic concurrency control.
I have 3 model: Process, Amazing and Contract.
Process
@Entity
@Table(name = "processes")
class Process(
...
...
@Version
private var version:…

mgh
- 921
- 3
- 9
- 37
1
vote
1 answer
Can I fetch existing data for JPA field that newly marked as @Transient?
I have a JPA column that Im GOING to mark as @Transient. But I do have some data in that field that I want to move later.
I know that @Transient won't persist. But, can I still load those existing data to the memory to the Java world?

ssdehero
- 786
- 1
- 11
- 26
1
vote
0 answers
In Hibernate 3.5, what are the annotation equivalents of constrained and outer-join?
I'm currently working to convert an application from using hibernate mapping files (.hbm.xml) to hibernate/jpa annotations (with a jpa annotation preference).
I am running into these two attributes in some of the hibernate mapping files on…

user3183769
- 13
- 3
0
votes
0 answers
Should @CreationTimestamp make the "created_at" fields of the object being updated after save has been done?
In the @Entity I have a field:
@CreationTimestamp
@Column(name = "created_at", updatable = false, nullable = false, columnDefinition = "TIMESTAMP")
private LocalDateTime createdAt;
in the @Service I have:
@Transaction
void someMethod()…

Eljah
- 4,188
- 4
- 41
- 85