Relative Content

Tag Archive for postgresqljpa

Order by not getting appended properly in spring jpa

@Query(value = “”” WITH cte1 as ( select distinct woa.id as woa_id from work_activity woa join activity_assignment waa on waa.activity_id = woa.id join activity_assignment_log waal on waal.activity_id = woa.id join ref_provider rp on rp.id = waal.provider_id where rp.external_id in (:providerIds) and woa.modified_date >= CAST(:modifiedDate AS timestamp) ) select * from ( select wa.id as waId, […]

How to reduce time taken by createEntityManagerFactory

I’m setting up unit tests for my company application. It’s set up to create a new docker container of the database for every test, so each test has a fresh database to work with. However, I get an IO error when I attempt to reuse EntityManagerFactory between tests now. I tried instantiating a new EMF for each test but it takes about 74% of the runtime just to call Persistence.createEntityManagerFactory, which is really slowing down the test suite. Is it possible to either: reuse the EMF between tests by connecting to the new database container at the start of each test or somehow reduce the time taken to create a new instance of EntityManagerFactory?