Questions tagged [jpa]
The Jakarta Persistence API (formerly Java Persistence API) (JPA) is a Java specification for accessing, persisting, and managing data between Java objects/classes and a relational database. JPA was defined as part of the EJB 3.0 specification as a replacement for the EJB 2 CMP Entity Beans specification. JPA is now considered the standard industry approach for Object to Relational Mapping (ORM) in the Java Industry.
52,181
questions
-1
votes
2
answers
39
views
any scenario's to use @Transactional annotation at Repository delete method?
I am reveiewing the code for one of the senior member for the first peer review so he added @Transactional annotation at custom repository with delete method. The custom Repository delete method is ...
-1
votes
0
answers
22
views
JPA Unit Test Error: Table not found During ALTER TABLE Execution
I am encountering an error in a simple JPA unit test where it attempts to execute an ALTER TABLE command on a table that it claims does not exist. Here is the relevant error message:
INFO: Property ...
0
votes
0
answers
31
views
Issuse with relationship mapping MapKeyEnumerated with an Entity List as values
I have this Entity
@Entity
public class MealPlanADay {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonIgnore
private Long id;
//@OneToMany(cascade = CascadeType.ALL,...
0
votes
0
answers
24
views
Hibernate seems to ignore the dialect I specify
I'm using Olingo JPA for producing an OData API.
The database I'm connecting to doesn't support the 'LOCATE' function; instead it implements 'POSITION'.
This seems to be true of a few databases: ...
0
votes
0
answers
28
views
How to Convert a Complex SQL Query to Hibernate Criteria API
I'm learning about Hibernate's Criteria API and would like to know how to convert this particular SQL query to Criteria API. Here is the SQL query I’m working with:
select s1.score as score,count(s1....
0
votes
1
answer
26
views
Can i customize result of @ManyToMany of entity?
Here is 2 entity obj:
import jakarta.persistence.*;
import lombok.*;
import java.util.Set;
@Entity
@Table(name = "category"
, uniqueConstraints = {
@UniqueConstraint(...
0
votes
1
answer
65
views
IntelliJ IDE Cannot Find javax.annotation.processing.Generated Symbol While mvn test Works Correctly
I am having a problem with my project configuration and running the program and unit test. When running with mvn test the JUnit test executes propertly, but when executing from within the IntelliJ IDE,...
0
votes
1
answer
13
views
JPA, removing parent cannot remove all children
I have a @OneToOne relation between Parent and Child tables , I need to delete all child if happen delete on parent because children doesn't have meaning without parent !
Parent Entity :
@Entity(name =...
0
votes
0
answers
21
views
Impossible to use DATEDIFF in java JPA criteria queries?
For the life of me, I cannot figure this out.
I want to select entities from my H2 database, and get the difference between an entities timestamp column and a passed parameter.
trying
var dateDiff = ...
-1
votes
0
answers
168
views
java: cannot find symbol - symbol: class Generated location: package javax.annotation.processing during build
What are the possible errors that are causing this:
/home/api/target/generated-sources/annotations/org/example/core/user/model/User_.java:3:35
java: cannot find symbol
symbol: class Generated
...
0
votes
0
answers
15
views
Handling Date comparisons in MYSQL 8 and Spring boot without Milliseconds
We are upgrading our project from Mysql 5 to Mysql 8. there is weird issue coming in db queries in date handling.
On MySQL 5, while saving data to db, the date used to be saved with 'yyyy-MM-dd HH:mm:...
-1
votes
1
answer
47
views
Why does VsCode generate classes with both jakarta.data.metamodel and jakarta.persistence.metamodel?
For some time now, I've had a problem in VsCode where I end up with duplicate generated sources.
For example, let's take the SiteEntity entity.
In /target/generated-sources/annotations/com/.../sites, ...
0
votes
0
answers
29
views
Hibernate generating N(N+1) Updates for each Insert
On Hibernate 6.4.4 and 6.4.9, I am observing the following odd behavior.
In a loop, I am doing the following:
for (loop control) {
SomeObject object = new SomeObject(contents);
repository....
-2
votes
0
answers
127
views
Unable to open JDBC Connection for DDL execution ["encrypt" property is set to "true" and "trustServerCertifi
10:12:20 PM: Executing ':ReportingApplication.main()'...
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :ReportingApplication.main()
...
-1
votes
0
answers
18
views
How do i switch between different schemas in spring jpa and hibernate dynamically
i have a multi tenancy application written with spring boot, keycloak, flyway and postgres, i have been finding it difficult to switch from one schema to another, note i have done a lot of research ...