docs: Add another QBE example.
This commit is contained in:
@@ -55,6 +55,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
@@ -141,6 +142,9 @@ import org.springframework.data.neo4j.integration.issues.gh2639.Individual;
|
||||
import org.springframework.data.neo4j.integration.issues.gh2639.LanguageRelationship;
|
||||
import org.springframework.data.neo4j.integration.issues.gh2639.ProgrammingLanguage;
|
||||
import org.springframework.data.neo4j.integration.issues.gh2639.Sales;
|
||||
import org.springframework.data.neo4j.integration.issues.qbe.A;
|
||||
import org.springframework.data.neo4j.integration.issues.qbe.ARepository;
|
||||
import org.springframework.data.neo4j.integration.issues.qbe.B;
|
||||
import org.springframework.data.neo4j.integration.misc.ConcreteImplementationTwo;
|
||||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.repository.query.QueryFragmentsAndParameters;
|
||||
@@ -189,6 +193,8 @@ class IssuesIT extends TestBase {
|
||||
setupGH2572(transaction);
|
||||
setupGH2583(transaction);
|
||||
|
||||
transaction.run("CREATE (:A {name: 'A name', id: randomUUID()}) -[:HAS] ->(:B {anotherName: 'Whatever', id: randomUUID()})");
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
bookmarkCapture.seedWith(session.lastBookmarks());
|
||||
@@ -266,6 +272,21 @@ class IssuesIT extends TestBase {
|
||||
cityModelRepository.saveAll(List.of(aachen, utrecht));
|
||||
}
|
||||
|
||||
@Test
|
||||
void qbeWithRelationship(@Autowired ARepository repository) {
|
||||
|
||||
var probe = new A();
|
||||
probe.setB(new B("Whatever"));
|
||||
var optionalResult = repository.findOne(Example.of(probe));
|
||||
assertThat(optionalResult).hasValueSatisfying(a -> {
|
||||
assertThat(a.getName()).isEqualTo("A name");
|
||||
assertThat(a.getId()).isNotNull();
|
||||
});
|
||||
|
||||
var allResults = repository.findAll(Example.of(probe));
|
||||
assertThat(allResults).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("GH-2168")
|
||||
void findByIdShouldWork(@Autowired DomainObjectRepository domainObjectRepository) {
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2011-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.issues.qbe;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.neo4j.core.schema.GeneratedValue;
|
||||
import org.springframework.data.neo4j.core.schema.Id;
|
||||
import org.springframework.data.neo4j.core.schema.Node;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship;
|
||||
|
||||
/**
|
||||
* Internally reported question / issue.
|
||||
*
|
||||
* @author Michael Simons
|
||||
*/
|
||||
@Node
|
||||
public class A {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(GeneratedValue.UUIDGenerator.class)
|
||||
UUID id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Relationship(type = "HAS")
|
||||
private B b;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public B getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(B b) {
|
||||
this.b = b;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2011-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.issues.qbe;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
|
||||
/**
|
||||
* Internally reported question / issue.
|
||||
*
|
||||
* @author Michael Simons
|
||||
*/
|
||||
public interface ARepository extends Neo4jRepository<A, UUID> {
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2011-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.neo4j.integration.issues.qbe;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.neo4j.core.schema.GeneratedValue;
|
||||
import org.springframework.data.neo4j.core.schema.Id;
|
||||
import org.springframework.data.neo4j.core.schema.Node;
|
||||
|
||||
/**
|
||||
* Internally reported question / issue.
|
||||
*
|
||||
* @author Michael Simons
|
||||
*/
|
||||
@Node
|
||||
public class B {
|
||||
@Id
|
||||
@GeneratedValue(GeneratedValue.UUIDGenerator.class)
|
||||
UUID id;
|
||||
|
||||
private String anotherName;
|
||||
|
||||
public B(String anotherName) {
|
||||
this.anotherName = anotherName;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getAnotherName() {
|
||||
return anotherName;
|
||||
}
|
||||
|
||||
public void setAnotherName(String anotherName) {
|
||||
this.anotherName = anotherName;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user