|
|
|
@ -69,7 +69,9 @@ import org.springframework.data.jdbc.testing.AssumeFeatureTestExecutionListener; |
|
|
|
import org.springframework.data.jdbc.testing.EnabledOnFeature; |
|
|
|
import org.springframework.data.jdbc.testing.EnabledOnFeature; |
|
|
|
import org.springframework.data.jdbc.testing.TestConfiguration; |
|
|
|
import org.springframework.data.jdbc.testing.TestConfiguration; |
|
|
|
import org.springframework.data.jdbc.testing.TestDatabaseFeatures; |
|
|
|
import org.springframework.data.jdbc.testing.TestDatabaseFeatures; |
|
|
|
|
|
|
|
import org.springframework.data.relational.core.mapping.Column; |
|
|
|
import org.springframework.data.relational.core.mapping.MappedCollection; |
|
|
|
import org.springframework.data.relational.core.mapping.MappedCollection; |
|
|
|
|
|
|
|
import org.springframework.data.relational.core.mapping.Table; |
|
|
|
import org.springframework.data.relational.core.mapping.event.AbstractRelationalEvent; |
|
|
|
import org.springframework.data.relational.core.mapping.event.AbstractRelationalEvent; |
|
|
|
import org.springframework.data.relational.core.mapping.event.AfterConvertEvent; |
|
|
|
import org.springframework.data.relational.core.mapping.event.AfterConvertEvent; |
|
|
|
import org.springframework.data.relational.core.sql.LockMode; |
|
|
|
import org.springframework.data.relational.core.sql.LockMode; |
|
|
|
@ -113,6 +115,8 @@ public class JdbcRepositoryIntegrationTests { |
|
|
|
@Autowired MyEventListener eventListener; |
|
|
|
@Autowired MyEventListener eventListener; |
|
|
|
@Autowired RootRepository rootRepository; |
|
|
|
@Autowired RootRepository rootRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired WithDelimitedColumnRepository withDelimitedColumnRepository; |
|
|
|
|
|
|
|
|
|
|
|
private static DummyEntity createDummyEntity() { |
|
|
|
private static DummyEntity createDummyEntity() { |
|
|
|
|
|
|
|
|
|
|
|
DummyEntity entity = new DummyEntity(); |
|
|
|
DummyEntity entity = new DummyEntity(); |
|
|
|
@ -1238,6 +1242,22 @@ public class JdbcRepositoryIntegrationTests { |
|
|
|
assertThat(match.get().getName()).contains(two.getName()); |
|
|
|
assertThat(match.get().getName()).contains(two.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void withDelimitedColumnTest() { |
|
|
|
|
|
|
|
WithDelimitedColumn withDelimitedColumn = new WithDelimitedColumn(); |
|
|
|
|
|
|
|
withDelimitedColumn.setType("TYPICAL"); |
|
|
|
|
|
|
|
withDelimitedColumn.setIdentifier("UR-123"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WithDelimitedColumn saved = withDelimitedColumnRepository.save(withDelimitedColumn); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(saved.getId()).isNotNull(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Optional<WithDelimitedColumn> inDatabase = withDelimitedColumnRepository.findById(saved.getId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(inDatabase).isPresent(); |
|
|
|
|
|
|
|
assertThat(inDatabase.get().getIdentifier()).isEqualTo("UR-123"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Root createRoot(String namePrefix) { |
|
|
|
private Root createRoot(String namePrefix) { |
|
|
|
|
|
|
|
|
|
|
|
return new Root(null, namePrefix, |
|
|
|
return new Root(null, namePrefix, |
|
|
|
@ -1361,10 +1381,17 @@ public class JdbcRepositoryIntegrationTests { |
|
|
|
List<DummyEntity> findByEnumType(Direction direction); |
|
|
|
List<DummyEntity> findByEnumType(Direction direction); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface RootRepository extends ListCrudRepository<Root, Long> { |
|
|
|
|
|
|
|
List<Root> findAllByOrderByIdAsc(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface WithDelimitedColumnRepository extends CrudRepository<WithDelimitedColumn, Long> { } |
|
|
|
|
|
|
|
|
|
|
|
@Configuration |
|
|
|
@Configuration |
|
|
|
@Import(TestConfiguration.class) |
|
|
|
@Import(TestConfiguration.class) |
|
|
|
static class Config { |
|
|
|
static class Config { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired JdbcRepositoryFactory factory; |
|
|
|
@Autowired JdbcRepositoryFactory factory; |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
@ -1382,6 +1409,9 @@ public class JdbcRepositoryIntegrationTests { |
|
|
|
return factory.getRepository(RootRepository.class); |
|
|
|
return factory.getRepository(RootRepository.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
WithDelimitedColumnRepository withDelimitedColumnRepository() { return factory.getRepository(WithDelimitedColumnRepository.class); } |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
NamedQueries namedQueries() throws IOException { |
|
|
|
NamedQueries namedQueries() throws IOException { |
|
|
|
|
|
|
|
|
|
|
|
@ -1404,15 +1434,11 @@ public class JdbcRepositoryIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
return extensionAwareQueryMethodEvaluationContextProvider; |
|
|
|
return extensionAwareQueryMethodEvaluationContextProvider; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public EvaluationContextExtension evaluationContextExtension() { |
|
|
|
public EvaluationContextExtension evaluationContextExtension() { |
|
|
|
return new MyIdContextProvider(); |
|
|
|
return new MyIdContextProvider(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface RootRepository extends ListCrudRepository<Root, Long> { |
|
|
|
|
|
|
|
List<Root> findAllByOrderByIdAsc(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Value |
|
|
|
@Value |
|
|
|
@ -1424,6 +1450,14 @@ public class JdbcRepositoryIntegrationTests { |
|
|
|
@MappedCollection(idColumn = "ROOT_ID", keyColumn = "ROOT_KEY") List<Intermediate> intermediates; |
|
|
|
@MappedCollection(idColumn = "ROOT_ID", keyColumn = "ROOT_KEY") List<Intermediate> intermediates; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Data |
|
|
|
|
|
|
|
@Table("WITH_DELIMITED_COLUMN") |
|
|
|
|
|
|
|
static class WithDelimitedColumn { |
|
|
|
|
|
|
|
@Id Long id; |
|
|
|
|
|
|
|
@Column("ORG.XTUNIT.IDENTIFIER") String identifier; |
|
|
|
|
|
|
|
@Column ("STYPE") String type; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Value |
|
|
|
@Value |
|
|
|
static class Intermediate { |
|
|
|
static class Intermediate { |
|
|
|
|
|
|
|
|
|
|
|
|