|
97 | 97 | import org.springframework.data.neo4j.integration.imperative.repositories.PersonWithNoConstructorRepository;
|
98 | 98 | import org.springframework.data.neo4j.integration.imperative.repositories.PersonWithWitherRepository;
|
99 | 99 | import org.springframework.data.neo4j.integration.imperative.repositories.ThingRepository;
|
| 100 | +import org.springframework.data.neo4j.integration.issues.gh2421.BaseNodeEntity; |
| 101 | +import org.springframework.data.neo4j.integration.issues.gh2421.MeasurementMeta; |
| 102 | +import org.springframework.data.neo4j.integration.issues.gh2421.projections.ApiMeasurementMetaProjection; |
100 | 103 | import org.springframework.data.neo4j.integration.shared.common.AltHobby;
|
101 | 104 | import org.springframework.data.neo4j.integration.shared.common.AltLikedByPersonRelationship;
|
102 | 105 | import org.springframework.data.neo4j.integration.shared.common.AltPerson;
|
|
151 | 154 | import org.springframework.data.neo4j.test.Neo4jExtension;
|
152 | 155 | import org.springframework.data.neo4j.types.CartesianPoint2d;
|
153 | 156 | import org.springframework.data.neo4j.types.GeographicPoint2d;
|
| 157 | +import org.springframework.data.projection.TargetAware; |
| 158 | +import org.springframework.data.repository.Repository; |
154 | 159 | import org.springframework.data.repository.query.FluentQuery;
|
155 | 160 | import org.springframework.data.repository.query.Param;
|
156 | 161 | import org.springframework.test.annotation.DirtiesContext;
|
@@ -3054,6 +3059,15 @@ void setupData(Transaction transaction) {
|
3054 | 3059 | true, 1L, TEST_PERSON1_BORN_ON, "something", Arrays.asList("a", "b"), NEO4J_HQ, createdAt.toInstant());
|
3055 | 3060 | person2 = new PersonWithAllConstructor(id2, TEST_PERSON2_NAME, TEST_PERSON2_FIRST_NAME, TEST_PERSON_SAMEVALUE,
|
3056 | 3061 | false, 2L, TEST_PERSON2_BORN_ON, null, Collections.emptyList(), SFO, null);
|
| 3062 | + |
| 3063 | + transaction.run("" + |
| 3064 | + "CREATE (m1:MeasurementMeta{nodeId: 'm1'}) "+ |
| 3065 | + "CREATE (m2:MeasurementMeta{nodeId: 'm2'}) "+ |
| 3066 | + "CREATE (nt2:NodeType{nodeTypeId: 'nt2'}) "+ |
| 3067 | + "CREATE (m1)-[:HAS_TYPE]->(nt2)" + |
| 3068 | + "CREATE (m2)-[:HAS_TYPE]->(nt2)" + |
| 3069 | + "CREATE (m1)-[:WEIGHTS]->(m2)" |
| 3070 | + ); |
3057 | 3071 | }
|
3058 | 3072 |
|
3059 | 3073 | @Test
|
@@ -3390,6 +3404,18 @@ void existsById(@Autowired PersonRepository repository) {
|
3390 | 3404 | assertThat(exists).isTrue();
|
3391 | 3405 | }
|
3392 | 3406 |
|
| 3407 | + @Test |
| 3408 | + void test(@Autowired MeasurementMetaRepository repository) { |
| 3409 | + Optional<ApiMeasurementMetaProjection> m1 = repository.findByNodeId("m1", ApiMeasurementMetaProjection.class); |
| 3410 | + assertThat(m1) |
| 3411 | + .isPresent() |
| 3412 | + .get() |
| 3413 | + .extracting(projection -> (MeasurementMeta) ((TargetAware)projection).getTarget()) |
| 3414 | + .extracting(BaseNodeEntity::getParent) |
| 3415 | + .extracting(BaseNodeEntity::getNodeType) |
| 3416 | + .isNull(); |
| 3417 | + } |
| 3418 | + |
3393 | 3419 | @Test // GH-2033
|
3394 | 3420 | void existsByProperty(@Autowired PersonRepository repository) {
|
3395 | 3421 |
|
@@ -4492,6 +4518,10 @@ interface SameIdEntitiesRepository extends Neo4jRepository<SameIdProperty.PolEnt
|
4492 | 4518 | interface EntityWithCustomIdAndDynamicLabelsRepository
|
4493 | 4519 | extends Neo4jRepository<EntitiesWithDynamicLabels.EntityWithCustomIdAndDynamicLabels, String> {}
|
4494 | 4520 |
|
| 4521 | + interface MeasurementMetaRepository extends Repository<MeasurementMeta, String> { |
| 4522 | + <R> Optional<R> findByNodeId(String nodeId, Class<R> clazz); |
| 4523 | + } |
| 4524 | + |
4495 | 4525 | @SpringJUnitConfig(Config.class)
|
4496 | 4526 | static abstract class IntegrationTestBase {
|
4497 | 4527 |
|
@@ -4544,7 +4574,8 @@ public Driver driver() {
|
4544 | 4574 | protected Collection<String> getMappingBasePackages() {
|
4545 | 4575 | return Arrays.asList(
|
4546 | 4576 | PersonWithAllConstructor.class.getPackage().getName(),
|
4547 |
| - Flight.class.getPackage().getName() |
| 4577 | + Flight.class.getPackage().getName(), |
| 4578 | + MeasurementMeta.class.getPackage().getName() |
4548 | 4579 | );
|
4549 | 4580 | }
|
4550 | 4581 |
|
|
0 commit comments