Category "jpa"

How to properly use JPA/Hibernate?

I'm trying to understand annotations better with JPA / Hibernate and SQL Server. I created a simple project: an abstract class named "Articles". Two classes inh

How to write a query using multiple 'IN' or any other keywords in SQL so that the condition being applied will be based upon the order defined

I want to fetch records from the database as : select * from table where column1 IN (aa, bb , cc...) and column2 IN (34, 55, 66...) and column3 IN(df, fg, hh...

JPA-Eclipselink caching nested tables (entities)

I am using Java JPA-Eclipselink persistence (v2.6.9) in combination with Apache Tomcat Web Server. I am fetching from database large amount of data from nested

Spring Batch JPA Bulk Insert eats performance when using GenerationType.IDENTITY

I am using Spring Boot and Spring Batch and JPA to load data from One database into another. In a single batch Job I've created 10 steps to run steps in sequenc

Unable to store ManyToOne association for an entity

I am unable to bind foreign_key baz_id to Baz on a POST call, it fails with a instantiation error trying to store a bar POST http://localhost/foo/api/v1/bars {

Spring native query with GROUP BY and ORDER BY also pagination

What if I have my native query (with PostgreSQL) in a more "complex" way, which I need to GROUP the data in order to apply an ORDER BY clause? Well, doing so wi

Convert a list of enums and store as 'varchar[]'

Trying to figure out how to store a list of enums in a single table column. I started with a String and it worked. I'll show only the relevant parts of the code

JPA @Version behavior when data is changed from unmanaged connection

Enabling @Version on table Customer when running the tests below @Test public void actionsTest1 () throws InterruptedException { CustomerState t = customerS

could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet with oauth

I am doing a rest service with java spring boot. The tables are created correctly in the database and locally test everything works correctly, but when I mount

Hibernate NamedQuery UPDATE statement throws QuerySyntaxException

I encountered a very interesting issue. I want to create an UPDATE statement NamedQuery for my class (I know this is a bit hacky). The weird thing is if I use p

How can you merge the same type entities consecutively using JPA PresistanceContext

I am currently creating a small project to mimic simple bank transactions. Currently there are two types of transactions. Request transaction Transaction is can

Read Array at index in jpa Query

I have a native Query that return a list of objects, i need to pass an array as parameter to the function getAllUsers. @Repository public interface UserReposito

Bi-directional relation in hibernate is failing to be cascadelly saved

I am using a Spring-Boot (2.3.3) application with Hibernate (5.4.20) and JPA repository on MySql DB, and I have a Bi-directional relationship between an entity:

Error creating bean with name 'entityManagerFactory' caused by java.lang.IllegalStateException

In the code I do not even use entityManagerFactory. I extend JPARepository and for creating the tables I have entities annotated with @Entity (using javax.persi

Spring JPA Paging to Stream

We are currently using cockroach DB, but this doesn't support returning X records at a time presumably due to lack of cursor support. This means that when tryin

spring data extension for quarkus datasource name

I want to use the spring data repositories in my quarkus application with jpa. As long as I use the default datasource and no named persistence unit, I'm able t

Checkmarx report sql injection JpaRepository

im running Checkmarx on my code and im getting an sql injection vulnerability. this is the simplified method im using public String assignRole(String userId, St

JPA CriteriaBuilder ManyToOne and null values

I'm trying to create a Specification for filtering a table. This table has 2 @ManyToOne relationships (that can be null) and I'd like to apply the filter inside

How can we test for the N+1 problem in JPA/Hibernate?

I have a N+1 problem, and I’d like to write some kind of automated regression test because it impacts performance very much. I thought about spying the E

QueryDSL Predicate for use with JPARepository where field is a JSON String converted using an AttributeConverter to a List<Object>

I have a JPA Entity (Terminal) which uses an AttributeConverter to convert a Database String into a list of Objects (ProgrmRegistration). The converter just us