|
| 1 | +/* |
| 2 | + * Copyright 2008-2025 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.jpa.repository.support; |
| 17 | + |
| 18 | +import static org.assertj.core.api.Assertions.assertThat; |
| 19 | + |
| 20 | +import jakarta.persistence.EntityManager; |
| 21 | +import jakarta.persistence.PersistenceContext; |
| 22 | +import java.util.List; |
| 23 | +import org.junit.jupiter.api.BeforeEach; |
| 24 | +import org.junit.jupiter.api.Test; |
| 25 | +import org.junit.jupiter.api.extension.ExtendWith; |
| 26 | +import org.springframework.data.jpa.domain.sample.User; |
| 27 | +import org.springframework.data.jpa.repository.JpaRepository; |
| 28 | +import org.springframework.test.context.ContextConfiguration; |
| 29 | +import org.springframework.test.context.junit.jupiter.SpringExtension; |
| 30 | +import org.springframework.transaction.annotation.Transactional; |
| 31 | + |
| 32 | +@ExtendWith(SpringExtension.class) |
| 33 | +@ContextConfiguration({"classpath:infrastructure.xml", "classpath:eclipselink-h2.xml"}) |
| 34 | +@Transactional |
| 35 | +class EclipseLinkDeleteAllByIdInBatchSimpleIdTests { |
| 36 | + |
| 37 | + @PersistenceContext |
| 38 | + EntityManager em; |
| 39 | + |
| 40 | + private JpaRepository<User, Integer> users; |
| 41 | + |
| 42 | + @BeforeEach |
| 43 | + void setUp() { |
| 44 | + users = new JpaRepositoryFactory(em).getRepository(UserRepository.class); |
| 45 | + } |
| 46 | + |
| 47 | + @Test // GH-3990 |
| 48 | + void deleteAllByIdInBatchShouldWorkOnEclipseLinkWithSimpleId() { |
| 49 | + User one = new User( "one", "eins", "[email protected]"); |
| 50 | + User two = new User( "two", "zwei", "[email protected]"); |
| 51 | + User three = new User( "three", "drei", "[email protected]"); |
| 52 | + |
| 53 | + users.saveAll(List.of(one, two, three)); |
| 54 | + users.flush(); |
| 55 | + |
| 56 | + users.deleteAllByIdInBatch(List.of(one.getId(), three.getId())); |
| 57 | + |
| 58 | + assertThat(users.findAll()).containsExactly(two); |
| 59 | + } |
| 60 | + |
| 61 | + private interface UserRepository extends JpaRepository<User, Integer> { |
| 62 | + } |
| 63 | +} |
0 commit comments