Questions tagged [data-jpa-test]
16 questions
1
vote
2 answers
Upgrade from SpringBoot 2.6 -> 2.7 - No qualifying bean of type 'org.springframework.boot....TestEntityManager' available
I updated from SpringBoot 2.6.12 to 2.7.11 and as a consequence our RepositoryTests were not working anymore.
The @autowired TestEntityManager can't be filled by a qualifying bean after the upgrade.
I tried a lot of solutions from other threads and…

Hypermiler
- 11
- 4
1
vote
2 answers
Why does DataJpaTest fail when saving OneToMany-related data in this pattern?
I have three Hibernate @Entity's below that mimic a failure in my production app:
@Entity
@Data
@SuperBuilder(toBuilder = true)
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Dog extends Animal {
String…

Jake Stout
- 487
- 1
- 5
- 17
0
votes
0 answers
@DataJpaTest seems to be mutating UUID columns
I'm working on updating a project from Spring Boot 2.7 to 3.1, and one unit test for a repository is throwing me for a loop. The entity is
@Entity
@Data
@NoArgsConstructor
@Table(name = "RETRY", schema = "DOCUMENT")
public class RetryEntity {
…

spartanhooah
- 183
- 4
- 15
0
votes
0 answers
Multi-threaded JPA Test doesn't Roll Back. Why?
Below is part of simple @DataJPATest. Two tests are identical.
It rolls back without problem when it executed in a single thread.
@Test
void SingleThreadTest1() throws RequesterException, InterruptedException {
…

Jiwon
- 1,074
- 1
- 11
- 27
0
votes
1 answer
Running Spring Boot Tests using @DataJpaTest and @Testcontainers results into ddl exceptions
A minimal Example can be found here: https://github.com/jbcbezerra/springboot-tc/tree/master/src/test/java/com/example/test
When using Spring Boot 3.1 and trying to Test a Repository, where the tests connects to a mysql container instead to a…

bentinhoj
- 13
- 2
0
votes
1 answer
H2 Database Tables can't be created for DataJpaTests
My Springboot project uses MariaDB and JPA works fine in normal mode.
When I tried to run my DataJpa JUNIT Tests, there was an error. "The Table Company could not be found (the database is empty)".
This is my application.properties File for my…

Miggtor
- 3
- 1
0
votes
0 answers
Repositoty Test error: Failed to load ApplicationContext @ComponentScan ANNOTATION type filter requires an annotation type: interface
I have a Spring Boot application which includes UserRepository, it extends JpaRepository and marked as @Repository. I want to create a test class UserRepository which starts like…

stakeika
- 55
- 1
- 8
0
votes
0 answers
Run Liquibase migration only once for all @DataJpaTest classes
I'm testing my JPA repositories using @DataJpaTest with Liquibase (@DataJpaTest + H2 + Liquibase) and I've noticed that Spring runs Liquibase migration scripts for each @DataJpaTest class which is time consuming. Is there a way to run migration…

sys463
- 337
- 2
- 5
- 18
0
votes
1 answer
How can I initialize H2 once for all DataJpaTests
I have hundreds @DataJpaTest-annotated classes within my spring boot library and it seems that every single class initializes/drops the schema.
How can I initialize (and eventually drops) the schema for all test classes?
// I have 1500 classes look…

Jin Kwon
- 20,295
- 14
- 115
- 184
0
votes
0 answers
Connecting the test class in the spring boot project to the in-memory database
application.properties:
server.port=8081
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/familybudgetapp
spring.datasource.username=root
spring.datasource.password=12345
…

Taha Ünsal
- 1
- 2
0
votes
1 answer
docker-compose.yml to dockerize the spring boot project
*I want to dockerize my spring boot project. I created docker-compose.yml but ./mvnw clean package && docker-compose build && docker-compose up
When I run these commands, the test in the repository test class gives an error. I want to update the…

Taha Ünsal
- 1
- 2
0
votes
1 answer
JUnit @DataJpaTest org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
I'm trying to do a test on the repository using @DataJPATest but @Autowired is not working
I already tried looking for examples of junit5 with @DataJpaTest, but I didn't find it
I tried adding other dependencies, I used @SpringTest and it worked,…
0
votes
0 answers
Load Liquibase files in Oracle xe Test Container from different module in spring boot project
I need to write DataJpaTest for the repository tests using the oracle test container. Using
spring.liquibase.change-log=classpath:/liquibase/liquibaseChangeLog.xml
but Liquibase file exists in a different module called database
Project structure:
-…

Ram Tungala
- 1
- 1
0
votes
1 answer
Problem when testing via @DataJpaTest with composite key entities
I'm trying to test an entity that I've mapped with a composite key.
Simply, I tried to test from the Repository layer, but the desired data and results did not come out.
I don't use @CreationTimestamp very often, so you don't have to mention this…

awse2050
- 13
- 2
0
votes
1 answer
@DataJpaTest ignores @Column(unique = true) and @Column(nullable = false)
I have an issue in testing save operation by Jpa.
I have a User object:
@Entity
@Table(name = "USERS", schema = "ecommercy")
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = {"createdAt", "updatedAt"}, allowGetters =…

Soroush Shemshadi
- 524
- 4
- 18