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.

jpa
Filter by
Sorted by
Tagged with
0 votes
2 answers
41 views

How can I stop the entity repeating itself in my JSON hibernate return?

I have this relationship between Aluno and Frequencia. One Aluno has multiple Frequencia's, and multiple Frequencia's can correspond to the same Aluno. Based on this, I created the following ...
João Vitor Garcia da Silva's user avatar
0 votes
0 answers
21 views

what happens when I use Spring deferred result API and a @Trasactional annotation for the connection during the wait for result?

We have a spring server which uses MySQL, HikariCP and JPA. we have an API called Foo which uses Spring deferred-result mechanism. in the API we have several DB calls, which why we needed to use @...
Shachar Levy's user avatar
0 votes
1 answer
34 views

How should one handle javax.persistence.OptimisticLockException in a legacy Spring Hibernate application

We have a legacy Spring Hibernate application that utilizes XML-based Hibernate configuration. Intermittently, when calling an operation concurrently, we encounter the javax.persistence....
unknown's user avatar
  • 691
0 votes
0 answers
31 views

Changes made to a managed JPA entity after it has been persisted are not saved on commit

If I instance a new entity and persist it then modify some of the attributes or relationships those changes are not saved to the database when the transaction is committed. I became aware of this ...
Joel Goldberger's user avatar
0 votes
1 answer
30 views

JPA/Hibernate: store EnumSets

I have a @Entity that stores in a DB (MariaDB) - JPA/Hibernate with Spring-Boot. @Entity public class MyFile { public static enum Type { DIR, FILE, SYS }; public static enum Rights { R, W,...
chris01's user avatar
  • 11.7k
0 votes
0 answers
28 views

EmbeddedId with MappedSuperclass: org.hibernate.MappingException: identifier mapping has wrong number of columns

I'm trying to implement a DB schema which involves @MappedSuperclass class having an @EmbeddedId id. Mappings are as follows: // BaseUser - contains common fields for all kinds of users @Getter @...
narendra-choudhary's user avatar
0 votes
0 answers
55 views

How to register dynamic JPA entities and repositories before Spring context loads using ByteBuddy?

I am attempting to dynamically create a JPA entity and its corresponding repository using ByteBuddy before the Spring context is fully loaded. My goal is to use the dynamically generated entity and ...
Luca Pascal's user avatar
0 votes
0 answers
36 views

Can't generate QueryDSL's QClass with querydsl-spatial

I'm setting up a spring boot project with querydsl-spatial. This is the list of dependencies and configuration: <parent> <groupId>org.springframework.boot</groupId> <...
sromdhane's user avatar
  • 443
0 votes
0 answers
42 views

Persisting Entities with multi-part foreign keys in Hibernate 6

I am using Hibernate 6.2.22, unfortunately newer versions are not possible at the moment for most likely unrelated reasons. I have created the entities User, Organization, and UserOrganization, as n ...
Tim Lammarsch's user avatar
0 votes
1 answer
46 views

yGuard obfuscated jar will not connect to database with Hibernate

I am having trouble getting hibernate to play nice with yGuard in my single-jar application that was packaged with the maven-asssembly plugin. The application is unable to initialize the database ...
gbiz123's user avatar
  • 131
1 vote
2 answers
51 views

java transaction.rollback() not rollbacking the DB

I try to do transactions on my project java, and I realise all transactions don't rollback the rows in DB. It's a local project (the DB was MySQL on phpmyadmin, all tables in innoDB). I try to do an ...
Ailten's user avatar
  • 21
0 votes
1 answer
30 views

Custom implementation of getCurrentAuditor method returns error when trying to use a JPA repository

I have a user entity with an audit field named lastUpdatedUserId (same as LastModifiedBy). This is an integer field. I'm trying to use the auditing feature provided by Spring and did everything stated ...
shirdisai's user avatar
0 votes
0 answers
23 views

How to use Java CriteriaBuilder's notLike method when comparing tables?

I have two Entity's. Recipe: @jakarta.persistence.Entity public class Recipe implements Serializable { private static final long serialVersionUID = 1L; @jakarta.persistence.Id @jakarta.persistence....
humbleCoder's user avatar
-1 votes
1 answer
36 views

Repeated column mapping in many to one relationship (Spring JPA)

When I run my springboot project, I get error: Column 'transactionNumber' is duplicated in mapping for entity 'com.myproject.Entities.IndividualItemsTransactionEntity' (use '@Column(insertable=false, ...
Jason Chan's user avatar
0 votes
0 answers
22 views

How to use spring Repository without Primary OR composite key? [duplicate]

I've a following table in my company's existing database CREATE TABLE person ( person_name VARCHAR(255) NOT NULL, person_type VARCHAR(255) NULL, description TEXT NULL, is_active ...
Bhesh Sejawal's user avatar
1 vote
1 answer
33 views

Implicit Naming Strategy Hibernate

I am doing an Spring Boot project and I am having a problem with the Naming Strategy used by Hibernate. As we can see in the following link: Naming Strategies. I do not know why my program has ...
Sergio Herreros's user avatar
0 votes
0 answers
17 views

having trouble to load data using multiple query with different table dynamically in hibernate

what is the best way to get data from multiple query with different table dynamically in hibernate 6. Say for example, I have to get data from below queries from hibernate. The selection for one or ...
Sanu's user avatar
  • 1
0 votes
1 answer
27 views

JPA validation ignores columnDefinition

I got following definition on a createTable in liquibase: <column name="FOO" type="CHAR(3)"> <constraints nullable="false"/> </column> When I run ...
Pwnstar's user avatar
  • 2,184
0 votes
0 answers
17 views

Hibernate query language: Unsuccessful in getting multiple ManyToMany/OneToMany Fields without selecting all unnecessary fields

I have tried every way to fetch only amenityMaster and entranceFacings as collections in projection without fetching rest of the fields. No solution on the net works. Looks like some limitation of ...
Rohit Nohwar's user avatar
1 vote
0 answers
34 views

JPA: How to override the column name of a nested @EmbeddedId

Project description I use Spring Boot 3.2.3 with Kotlin, Gradle - Kotlin and Java 21. I use Postgres as my db. The actual problem In the code below I created a simple OneToMany relationship between ...
Marc Grec's user avatar
  • 105
0 votes
0 answers
7 views

one entity attributes gets persisted to other entity attributes

I want to perform a jpa related program that have functionlity like when I enter values for attributes in parent entity those need to updated in other table with same attributes is there a way to do ...
Ajay's user avatar
  • 1
0 votes
1 answer
37 views

Asking for advice on debugging a not-working JPA delete call

We're having a rather complex table structure in our Spring Boot application, consisting of about ten entities linked by one-to-one, one-to-many, many-to-one and many-to-many relations. They're ...
ahuemmer's user avatar
  • 1,941
0 votes
1 answer
39 views

StoredProcedureQuery with Multiple out parameter not working after hibernate(6) and java (17) upgrade

Earlier StoredProcedureQuery with two out parameter is working. I successfully called a stored procedure with two out and multiple IN parameters. But after java and hibernate upgrade it is not working ...
Ganesh Nav's user avatar
0 votes
0 answers
72 views

EclipseLink Performance Problem on Update to Vaadin 24 / Springboot 3

I am working on an Web-Application which is in productive use for about 17 years. Currently it's using Vaadin 23 and EclipseLink 2.7.8. After the end of the support for Vaadin 23 it is necessary to ...
Matthias's user avatar
0 votes
2 answers
24 views

What is the reason that spring boot only queries appear in the hibernate log and no mapped value values are seen?

As you can see, only query statements appear in the log? I can't see the actual matching values on the values?? If you test insert, the value goes into the table well... I even asked Chatgpt to add ...
DevJWP's user avatar
  • 31
0 votes
1 answer
20 views

I have created tables using @Entity but what if there are always addition and deletion of columns in table in springboot jpa application

have created spring boot rest api, with spring boot JPA , I have created tables using @Entity but what if there is always change in columns. There are always addition and deletion of columns in tables ...
Mrudula P's user avatar
0 votes
1 answer
56 views

Insert Query Works On H2 but Not On Spring/Java itself

I'm trying to develop a track rating web project with Spring Boot, on basic level. I've written two seperate Entities that have Many to Many relationship with each other. Which are Tracks and Singers ...
Yiğit Altay's user avatar
0 votes
1 answer
48 views

Query for JPA endpoint needs explicit type casts

I'm currently doing an endpoint to find a list of exchange_request by its status. For it, I defined this query in my repository: @Query("SELECT er FROM ExchangeRequest er WHERE er.status = :...
vale383's user avatar
  • 85
0 votes
0 answers
23 views

class org.hibernate.mapping.JoinedSubclass cannot be cast to class org.hibernate.mapping.RootClass

I'm in the process of creating a CRM for my final training project. I have this error which appears when I run the application and I block completely. My research says it's related to IDs between ...
AnBnd's user avatar
  • 1
0 votes
1 answer
23 views

Enabling 2nd level cache in Spring JPA

Since managing sessions, transaction and other stuff is not required in Spring Data JPA unlike Hibernate, is there any way 2nd level caching can be enabled in Spring Data JPA? I tried google but it ...
Agrudge Amicus's user avatar
0 votes
1 answer
69 views

Hexagonal Architecture - How to update entity?

I want to update a column in the database but everytime I call the update method a new column is being added in the database and it is not updating the specified column I am trying to follow the ...
Nisi Zenuni's user avatar
-1 votes
1 answer
25 views

Detached entity passed to persist, but the entity was just persisted

I'm getting this error that I shouldn't be getting. First, I persist an appointment1, with doctor1, and it gets saved. Then, on appointment4, I get detached entity error, but doctor1 is already saved =...
ManBehindTheCurtain's user avatar
0 votes
1 answer
23 views

JPA: Locking a parent object to prevent multiple children being created

I am using JPA with EclipseLink and MySQL to manage my data and I want to prevent my application creating two child objects that are not compatible. My current logic which does not work looks like ...
mjaggard's user avatar
  • 2,401
0 votes
0 answers
15 views

Spring JPA entity doesn't update when i use getReferenceId() in transactional function

The contents of the database do not change despite the normal communication and modification of the contents to be modified through the DTO. entity code like this @Getter @ToString(callSuper = true) @...
ExcelsiorKim's user avatar
0 votes
1 answer
17 views

How to Handle One-to-Many Relationship Mapping in JPA/Hibernate with Embedded Entities

I have an entity AccountContact with fields id, accountId, and a list of Contact entities representing account contacts. The Contact entity is embedded within AccountContact. I don't want to use two ...
FranzF's user avatar
  • 113
1 vote
2 answers
44 views

Conditional loading @ManyToMany JPA

I have a user Entity and Article Entity. The fetch type of articles is LAZY. I dont need to load articles all the time but I have a case in which I need to load the user favorites articles. How can I ...
Emmad Zahid's user avatar
0 votes
1 answer
18 views

Hibernate: Delete the join entries but not the entities

I have a ManyToMany relationship between employees and status groups, realized via a join table employee_status_group. I want to reach the following: when a status group gets deleted: delete the join ...
ATW's user avatar
  • 269
0 votes
0 answers
89 views

JPA association between three entities with specific business requirements

I'm making an application that has three entities: DomesticViolence, Person and PersonState. I'm new in JPA and i have no idea how to map these three entities while respecting the following business ...
HDonev's user avatar
  • 1
1 vote
2 answers
113 views

Getting error as "required a bean of type.....that could not be found"

I have made a basic structure of a project named expense tracker, where I got error. Even though I have been trying to resolve it for a long time, it persists. Error : APPLICATION FAILED TO START ...
Giribala's user avatar
0 votes
0 answers
17 views

ObjectOptimisticLockingFailureException specific scenario on database update

While trying to insert into database, Iam getting below Stack Trace - StackTrace":"org.springframework.orm.ObjectOptimisticLockingFailureException: Batch update returned unexpected row count ...
lecarpetron dookmarion's user avatar
-1 votes
1 answer
27 views

Can I use EntityGraph to make EAGER association LAZY?

For example I have class Foo { @OneToOne(fetch = FetchType.EAGER) Bar bar; } and in some queries I want not to load bar. I found the way to solve this: interface FooRepository extends ...
Dima G.'s user avatar
  • 99
0 votes
0 answers
75 views

Saving OAuth2 Login User in Database in Spring boot 3

I have a google authentication setup with spring boot v3. I have setup the authentication flow configuration as to save the authenticated google users some details in the local db with a ...
CleanCodeOnline's user avatar
2 votes
1 answer
149 views

How to unmarshall a XML without namespace using the Jakarta XML Unmarshaller?

I am trying to unmarshal an XML into a Java object using the jakarta.xml.bind.Unmarshaller but my XML does not contain some of the default namespaces as they are part of the XSD already. How to either ...
BATMAN_2008's user avatar
  • 3,230
0 votes
0 answers
31 views

One select SQL with left join with followed by mapping in code or multiple selects

I have a question, most likely a stupid one, regarding selecting queries in hibernate. I have Entity A with a oneToMany relationship to another entity B (A.id_key = B.id_status). A schema: create ...
Фёдор Антонов's user avatar
0 votes
0 answers
24 views

Could not determine recommended JdbcType for `com.test.dd.entity.ConsumerRequest

Getting below error logs when running jpa transaction in postgresql database. Issue is generated after upgrading hibernate-core 6+ version. `Could not determine recommended JdbcType for `com.test.dd....
Pradeep Rai's user avatar
0 votes
0 answers
36 views

Is a posibility to return custom complex objects JPA

I'm developing a Spring Boot application with Spring Data JPA. I'm using a custom JPQL query to group by some field and list of object. My entity class: public class Review { @ManyToOne ...
Marcel Parlog's user avatar
0 votes
0 answers
20 views

ERROR: update or delete on table "tb_webapp" violates foreign key constraint on table "tb_database"

I'm trying to delete the parent student or parent course and I get this error: update or delete on table "tb_webapp" violates foreign key constraint "fkkp7x1km86fdyb6c1jdc4u3phg" ...
RICKY MARNAEK SIBARANI's user avatar
0 votes
1 answer
10 views

Is there an option in intellij to generate tables from our classes (entities)

How to generate database tables from entity classes with jpa hibernate. Using the IntelliJ IDE. Because I created my entities with the jpa annotations, I also created the data source and tested the ...
glad veunick's user avatar
0 votes
0 answers
23 views

JPA: Mapping a list of enums to an entity

I have two tables employee: id | ... employee_statusgroup: employee_id | statusgroup and want to get all the statusgroups (its an enum) of an employee in the employee entity. I tried this @...
ATW's user avatar
  • 269
0 votes
2 answers
49 views

What's the best way to make sure a transactional method does not propagate to a readonly transactional method

I'm currently facing an issue with two methods of the same Spring service, here's a basic example: @Transactional(readOnly = true) public Optional<SomeEntity> readSomeEntity(string idEntity) ...
dorian.naa's user avatar

1
3 4
5
6 7
1042