Category "jpa"

JPA duplicate entry error on EntityManager.remove and then EntityManager.persist

I am using Hibernate implementation of JPA. Let's say I have a list of objects which I have to persist in a table called Event. All these objects have the same

i have this exception "org.hibernate.tool.schema.spi.CommandAcceptanceException:

this is my code package com.examplesector.choosesectors.models.Entity; import lombok.*; import javax.persistence.*; import javax.validation.constraints.Size;

JPA Query clause IN / Invalid relational operator

How to include the IN clause in the Query if the parameter is not null? If I try to put the ":ramos is null" it gives an error @Query(value = "SELECT r FROM Par

How to implement a search table with many to many relationship in Hibernate with a 3rd class entity

I am trying to learn Hibernate to create on startup the Db from entities, but I have only found articles suggesting how to implement many to many relationship w

How use projections in spring-data-jpa?

I need to get all the information about the ticket in one request, also the name, author, and year of the book. I have implemented this : I create interface Tic

JPA: Data integrity violation instead of Upsert

I have this entity with these fields and this primary key: @Getter @Setter @Entity @Builder @NoArgsConstructor @AllArgsConstructor @Table(name = "MY_TABLE", sch

How to make inherited fields of non-audited base entity being audited for audited child entity in JPA?

I have a base entity not intended to be audited: @Data @MappedSuperclass @EqualsAndHashCode(of = {"id"}) public abstract class BaseEntity implements Serializabl

How to map specific column in entity class

I have two tables Users and UserRoles. These are the entity class I have created, @Entity @Table(name="users") public Users { @Id @Column(name = "id") private

QuerydslBindings cannot bind multiple aliases to a path

Let's look at the code first, the following is how I bind two aliases to root.createdDate at the same time, but only one will always take effect, and the last a

Java ORM vs multiple entities

I have a class Health Check - as part of the class I record how many parasites are seen (enum NONE, SOME, MANY) and also the location of the parasites (enum HEA

Java Spring JPA Query Error: '(',<expression>,FUNCTION or identifier expected, got '('

I'm asking the question cuz all the related posts i found are not answered Error at line 21 Screenshot Hello guys I need some help with this Query, at line 21 I

Guice-persist: inconsistent data from EntityManagers

I have a problem with the persistence in a java web application. We use Ninjaframework (6.8.1) which uses Guice as dependency injection framework and for persis

How to parse XML files without knowledge of filename

I have a directory in which I receive orders as XML file. I want to parse this file and then do some things with it. I can set a scheduled job to check this dir

Spring boot - adding a secondary data source causes nothing to get save during a integration test

In a project I am working on we added a secondary data source. This meant adding the entity factory and the transaction manager at the @EnableJpaRepositories. W

Spring boot mapsId

Hi I using spring boot jpa and I need to use mapsid. There are not so much information about that and I wonder if anyone can help me understand how to use maybe

What is the best practice for solving the number of cases of N searches in Spring JPA?

What is the best practice for solving the number of cases of N searches? There are 3 search conditions for me. There are search conditions of A, B, and C. In th

Proper mapping ( JPA ) composite key

For example i have entities @Entity public class A{ @Id Long Id; ... } @Entity public class B{ @Id Long Id; ... } @Entity @IdClass(ABId.class). public class AB{

Select only a set to improve perfomance

I search to know if a user have an active subscription @Query("select case when count(u) > 0 then true else false end from User u where u.id=:userId and cur

EntityManager closed when executing queries on different threads

I am trying to execute a couple of queries on different threads. There are 2 top level queries each executing on different tables at runtime. For executing the

SQL inner join with top to JPPQL

I have this SQL: SELECT b.NAME, b.ID, hc1.CATCH_DATE, hc1.id FROM BIRD b INNER JOIN HEALTH_CHECK hc1 ON hc1.BIRD_ID = b.ID INNER JOIN (