GH-2763 - De-Lombok all the things.

Closes #2763
This commit is contained in:
Gerrit Meier
2023-07-07 13:39:00 +02:00
parent ebb56d0b58
commit 47feb15244
154 changed files with 7383 additions and 1209 deletions

View File

@@ -1,2 +0,0 @@
lombok.nonNull.exceptionType = IllegalArgumentException

12
pom.xml
View File

@@ -523,18 +523,6 @@
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<dependencies>
<dependency>
<!-- See https://github.com/awhitford/lombok.maven/issues/34 -->
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>

View File

@@ -15,27 +15,99 @@
*/
package org.springframework.data.neo4j.core.mapping.callback;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Value;
import lombok.With;
import java.util.Date;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import java.util.Date;
/**
* @author Michael J. Simons
*/
@Value
@With
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class ImmutableSample {
public final class ImmutableSample {
@Id String id;
@CreatedDate Date created;
@LastModifiedDate Date modified;
@Id
private final String id;
@CreatedDate
private final Date created;
@LastModifiedDate
private final Date modified;
public ImmutableSample(String id, Date created, Date modified) {
this.id = id;
this.created = created;
this.modified = modified;
}
public ImmutableSample() {
this.id = null;
this.created = null;
this.modified = null;
}
public String getId() {
return this.id;
}
public Date getCreated() {
return this.created;
}
public Date getModified() {
return this.modified;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ImmutableSample)) {
return false;
}
final ImmutableSample other = (ImmutableSample) o;
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$created = this.getCreated();
final Object other$created = other.getCreated();
if (this$created == null ? other$created != null : !this$created.equals(other$created)) {
return false;
}
final Object this$modified = this.getModified();
final Object other$modified = other.getModified();
if (this$modified == null ? other$modified != null : !this$modified.equals(other$modified)) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $created = this.getCreated();
result = result * PRIME + ($created == null ? 43 : $created.hashCode());
final Object $modified = this.getModified();
result = result * PRIME + ($modified == null ? 43 : $modified.hashCode());
return result;
}
public String toString() {
return "ImmutableSample(id=" + this.getId() + ", created=" + this.getCreated() + ", modified=" + this.getModified() + ")";
}
public ImmutableSample withId(String newId) {
return this.id == newId ? this : new ImmutableSample(newId, this.created, this.modified);
}
public ImmutableSample withCreated(Date newCreated) {
return this.created == newCreated ? this : new ImmutableSample(this.id, newCreated, this.modified);
}
public ImmutableSample withModified(Date newModified) {
return this.modified == newModified ? this : new ImmutableSample(this.id, this.created, newModified);
}
}

View File

@@ -15,23 +15,6 @@
*/
package org.springframework.data.neo4j.integration.imperative;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import lombok.Data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiPredicate;
import java.util.function.Function;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.neo4j.cypherdsl.core.Cypher;
@@ -50,7 +33,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.neo4j.test.Neo4jImperativeTestConfiguration;
import org.springframework.data.neo4j.core.DatabaseSelectionProvider;
import org.springframework.data.neo4j.core.Neo4jTemplate;
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty;
@@ -63,10 +45,26 @@ import org.springframework.data.neo4j.integration.shared.common.PersonWithAssign
import org.springframework.data.neo4j.integration.shared.common.ThingWithGeneratedId;
import org.springframework.data.neo4j.test.BookmarkCapture;
import org.springframework.data.neo4j.test.Neo4jExtension.Neo4jConnectionSupport;
import org.springframework.data.neo4j.test.Neo4jImperativeTestConfiguration;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiPredicate;
import java.util.function.Function;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* @author Gerrit Meier
* @author Michael J. Simons
@@ -354,14 +352,88 @@ class Neo4jTemplateIT {
return predicate;
}
@Data
static class DtoPersonProjection {
/** The ID is required in a project that should be saved. */
/**
* The ID is required in a project that should be saved.
*/
private final Long id;
private String lastName;
private String firstName;
DtoPersonProjection(Long id) {
this.id = id;
}
public Long getId() {
return this.id;
}
public String getLastName() {
return this.lastName;
}
public String getFirstName() {
return this.firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof DtoPersonProjection)) {
return false;
}
final DtoPersonProjection other = (DtoPersonProjection) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$lastName = this.getLastName();
final Object other$lastName = other.getLastName();
if (this$lastName == null ? other$lastName != null : !this$lastName.equals(other$lastName)) {
return false;
}
final Object this$firstName = this.getFirstName();
final Object other$firstName = other.getFirstName();
if (this$firstName == null ? other$firstName != null : !this$firstName.equals(other$firstName)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof DtoPersonProjection;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $lastName = this.getLastName();
result = result * PRIME + ($lastName == null ? 43 : $lastName.hashCode());
final Object $firstName = this.getFirstName();
result = result * PRIME + ($firstName == null ? 43 : $firstName.hashCode());
return result;
}
public String toString() {
return "Neo4jTemplateIT.DtoPersonProjection(id=" + this.getId() + ", lastName=" + this.getLastName() + ", firstName=" + this.getFirstName() + ")";
}
}
@Test // GH-2215

View File

@@ -160,6 +160,7 @@ import org.springframework.data.neo4j.test.Neo4jImperativeTestConfiguration;
import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
/**
* @author Michael J. Simons
@@ -307,7 +308,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2415")
void saveWithProjectionImplementedByEntity(@Autowired Neo4jMappingContext mappingContext,
@Autowired Neo4jTemplate neo4jTemplate) {
@Autowired Neo4jTemplate neo4jTemplate) {
Neo4jPersistentEntity<?> metaData = mappingContext.getPersistentEntity(BaseNodeEntity.class);
NodeEntity nodeEntity = neo4jTemplate
@@ -461,6 +462,7 @@ class IssuesIT extends TestBase {
});
}
@Transactional // otherwise the relationships will add up
@RepeatedTest(5)
@Tag("GH-2289")
@Tag("GH-2294")
@@ -534,7 +536,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2326")
void saveShouldAddAllLabels(@Autowired AnimalRepository animalRepository,
@Autowired BookmarkCapture bookmarkCapture) {
@Autowired BookmarkCapture bookmarkCapture) {
List<AbstractLevel2> animals = Arrays.asList(new AbstractLevel2.AbstractLevel3.Concrete1(),
new AbstractLevel2.AbstractLevel3.Concrete2());
@@ -547,7 +549,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2326")
void saveAllShouldAddAllLabels(@Autowired AnimalRepository animalRepository,
@Autowired BookmarkCapture bookmarkCapture) {
@Autowired BookmarkCapture bookmarkCapture) {
List<AbstractLevel2> animals = Arrays.asList(new AbstractLevel2.AbstractLevel3.Concrete1(),
new AbstractLevel2.AbstractLevel3.Concrete2());
@@ -718,7 +720,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2493")
void saveOneShouldWork(@Autowired Driver driver, @Autowired BookmarkCapture bookmarkCapture,
@Autowired TestObjectRepository repository) {
@Autowired TestObjectRepository repository) {
TestObject testObject = new TestObject(new TestData(4711, "Foobar"));
testObject = repository.save(testObject);
@@ -730,7 +732,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2493")
void saveAllShouldWork(@Autowired Driver driver, @Autowired BookmarkCapture bookmarkCapture,
@Autowired TestObjectRepository repository) {
@Autowired TestObjectRepository repository) {
TestObject testObject = new TestObject(new TestData(4711, "Foobar"));
testObject = repository.saveAll(Collections.singletonList(testObject)).get(0);
@@ -819,7 +821,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2533")
void projectionWorksForDynamicRelationshipsOnSave(@Autowired GH2533Repository repository,
@Autowired Neo4jTemplate neo4jTemplate) {
@Autowired Neo4jTemplate neo4jTemplate) {
EntitiesAndProjections.GH2533Entity rootEntity = createData(repository);
rootEntity = repository.findByIdWithLevelOneLinks(rootEntity.id).get();
@@ -839,7 +841,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2533")
void saveRelatedEntityWithRelationships(@Autowired GH2533Repository repository,
@Autowired Neo4jTemplate neo4jTemplate) {
@Autowired Neo4jTemplate neo4jTemplate) {
EntitiesAndProjections.GH2533Entity rootEntity = createData(repository);
neo4jTemplate.saveAs(rootEntity, EntitiesAndProjections.GH2533EntityWithRelationshipToEntity.class);
@@ -906,7 +908,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2576")
void listOfMapsShouldBeUsableAsArguments(@Autowired Neo4jTemplate template, @Autowired CollegeRepository collegeRepository) {
void listOfMapsShouldBeUsableAsArguments(@Autowired Neo4jTemplate template, @Autowired CollegeRepository collegeRepository) {
var student = template.save(new Student("S1"));
var college = template.save(new College("C1"));
@@ -920,7 +922,7 @@ class IssuesIT extends TestBase {
@Test
@Tag("GH-2576")
void listOfMapsShouldBeUsableAsArgumentsWithWorkaround(@Autowired Neo4jTemplate template, @Autowired CollegeRepository collegeRepository) {
void listOfMapsShouldBeUsableAsArgumentsWithWorkaround(@Autowired Neo4jTemplate template, @Autowired CollegeRepository collegeRepository) {
var student = template.save(new Student("S1"));
var college = template.save(new College("C1"));
@@ -997,7 +999,7 @@ class IssuesIT extends TestBase {
languageRelationships.add(perlRelationship);
Developer harry = new Developer("Harry", languageRelationships);
List<CompanyPerson> team = Arrays.asList(greg, roy, craig, harry);
List<CompanyPerson> team = Arrays.asList(greg, roy, craig, harry);
Company acme = new Company("ACME", team);
companyRepository.save(acme);
@@ -1114,7 +1116,7 @@ class IssuesIT extends TestBase {
@Override
public PlatformTransactionManager transactionManager(Driver driver,
DatabaseSelectionProvider databaseNameProvider) {
DatabaseSelectionProvider databaseNameProvider) {
BookmarkCapture bookmarkCapture = bookmarkCapture();
return new Neo4jTransactionManager(driver, databaseNameProvider,
@@ -1213,7 +1215,7 @@ class IssuesIT extends TestBase {
}
private static void assertThatTestObjectHasBeenCreated(Driver driver, BookmarkCapture bookmarkCapture,
TestObject testObject) {
TestObject testObject) {
try (Session session = driver.session(bookmarkCapture.createSessionConfig())) {
Map<String, Object> arguments = new HashMap<>();
arguments.put("id", testObject.getId());

View File

@@ -17,6 +17,7 @@ package org.springframework.data.neo4j.integration.issues;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.BeforeEach;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -86,7 +87,6 @@ class ReactiveIssuesIT extends TestBase {
try (Transaction transaction = session.beginTransaction()) {
transaction.run("MATCH (n) detach delete n");
setupGH2289(transaction);
setupGH2328(transaction);
setupGH2572(transaction);
@@ -96,6 +96,17 @@ class ReactiveIssuesIT extends TestBase {
}
}
@BeforeEach
void setup(@Autowired BookmarkCapture bookmarkCapture) {
try (Session session = neo4jConnectionSupport.getDriver().session(bookmarkCapture.createSessionConfig())) {
try (Transaction transaction = session.beginTransaction()) {
setupGH2289(transaction);
transaction.commit();
}
bookmarkCapture.seedWith(session.lastBookmarks());
}
}
@RepeatedTest(23)
@Tag("GH-2289")
void testNewRelation(@Autowired ReactiveSkuRepository skuRepo) {
@@ -204,7 +215,7 @@ class ReactiveIssuesIT extends TestBase {
@Test
@Tag("GH-2326")
void saveShouldAddAllLabels(@Autowired ReactiveAnimalRepository animalRepository,
@Autowired BookmarkCapture bookmarkCapture) {
@Autowired BookmarkCapture bookmarkCapture) {
List<String> ids = new ArrayList<>();
List<AbstractLevel2> animals = Arrays.asList(new AbstractLevel2.AbstractLevel3.Concrete1(),
@@ -222,7 +233,7 @@ class ReactiveIssuesIT extends TestBase {
@Test
@Tag("GH-2326")
void saveAllShouldAddAllLabels(@Autowired ReactiveAnimalRepository animalRepository,
@Autowired BookmarkCapture bookmarkCapture) {
@Autowired BookmarkCapture bookmarkCapture) {
List<String> ids = new ArrayList<>();
List<AbstractLevel2> animals = Arrays.asList(new AbstractLevel2.AbstractLevel3.Concrete1(),
@@ -314,7 +325,7 @@ class ReactiveIssuesIT extends TestBase {
@Test
@Tag("GH-2498")
void shouldNotDeleteFreshlyCreatedRelationships(@Autowired Driver driver, @Autowired
ReactiveNeo4jTemplate template) {
ReactiveNeo4jTemplate template) {
Group group = new Group();
group.setName("test");
@@ -432,7 +443,7 @@ class ReactiveIssuesIT extends TestBase {
@Override
public ReactiveTransactionManager reactiveTransactionManager(Driver driver,
ReactiveDatabaseSelectionProvider databaseSelectionProvider) {
ReactiveDatabaseSelectionProvider databaseSelectionProvider) {
BookmarkCapture bookmarkCapture = bookmarkCapture();
return new ReactiveNeo4jTransactionManager(driver, databaseSelectionProvider,

View File

@@ -48,7 +48,7 @@ abstract class TestBase {
@BeforeEach
protected final void beforeEach(@Autowired BookmarkCapture bookmarkCapture) {
try (Session session = neo4jConnectionSupport.getDriver().session(bookmarkCapture.createSessionConfig());
Transaction transaction = session.beginTransaction()
Transaction transaction = session.beginTransaction()
) {
List<String> labelsToDelete = List.of("AbstractBase", "AccountingMeasurementMeta", "Application",
"BaseNodeEntity", "CityModel", "ConcreteImplementationOne", "ConcreteImplementationTwo",
@@ -100,9 +100,10 @@ abstract class TestBase {
}
protected static void setupGH2289(QueryRunner queryRunner) {
queryRunner.run("MATCH (s:SKU_RO) DETACH DELETE s").consume();
for (int i = 0; i < 4; ++i) {
queryRunner.run("CREATE (s:SKU_RO {number: $i, name: $n})",
Values.parameters("i", i, "n", new String(new char[] { (char) ('A' + i) }))).consume();
Values.parameters("i", i, "n", new String(new char[]{(char) ('A' + i)}))).consume();
}
}
@@ -170,7 +171,7 @@ abstract class TestBase {
}
protected static void assertSingleApplicationNodeWithMultipleWorkflows(Driver driver,
BookmarkCapture bookmarkCapture) {
BookmarkCapture bookmarkCapture) {
try (Session session = driver.session(bookmarkCapture.createSessionConfig())) {
Record record = session.executeRead(
@@ -182,7 +183,7 @@ abstract class TestBase {
}
protected static void assertMultipleApplicationsNodeWithASingleWorkflow(Driver driver,
BookmarkCapture bookmarkCapture) {
BookmarkCapture bookmarkCapture) {
try (Session session = driver.session(bookmarkCapture.createSessionConfig())) {
List<Record> records = session.executeRead(

View File

@@ -15,17 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.events;
import static org.assertj.core.api.Assertions.assertThat;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.Driver;
@@ -52,6 +41,13 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Michael J. Simons
*/
@@ -73,7 +69,8 @@ class EventsPublisherIT {
static AtomicBoolean receivedAfterCommitEvent = new AtomicBoolean(false);
@Test // GH-2580
@Test
// GH-2580
void beforeAndAfterCommitEventsShouldWork(@Autowired Neo4jObjectService service) {
service.save("foobar");
@@ -81,13 +78,15 @@ class EventsPublisherIT {
assertThat(receivedAfterCommitEvent).isTrue();
}
@Slf4j
@Component
@RequiredArgsConstructor
static class Neo4jObjectListener {
private final Neo4jObjectService service;
Neo4jObjectListener(Neo4jObjectService service) {
this.service = service;
}
@TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT)
public void onBeforeCommit(Neo4jMessage message) {
Optional<Neo4jObject> optionalNeo4jObject = service.findById(message.getMessageId());
@@ -139,9 +138,51 @@ class EventsPublisherIT {
}
}
@Data
static class Neo4jMessage {
private final String messageId;
Neo4jMessage(String messageId) {
this.messageId = messageId;
}
public String getMessageId() {
return this.messageId;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Neo4jMessage)) {
return false;
}
final Neo4jMessage other = (Neo4jMessage) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$messageId = this.getMessageId();
final Object other$messageId = other.getMessageId();
if (this$messageId == null ? other$messageId != null : !this$messageId.equals(other$messageId)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof Neo4jMessage;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $messageId = this.getMessageId();
result = result * PRIME + ($messageId == null ? 43 : $messageId.hashCode());
return result;
}
public String toString() {
return "EventsPublisherIT.Neo4jMessage(messageId=" + this.getMessageId() + ")";
}
}
@Repository

View File

@@ -15,10 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.events;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
@@ -26,13 +22,60 @@ import org.springframework.data.neo4j.core.schema.Property;
/**
* @author Michael J. Simons
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Node(primaryLabel = "Neo4jObject")
public class Neo4jObject {
@Id
@Property(name = "id")
private String id;
@Id
@Property(name = "id")
private String id;
public Neo4jObject(String id) {
this.id = id;
}
public Neo4jObject() {
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Neo4jObject)) {
return false;
}
final Neo4jObject other = (Neo4jObject) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof Neo4jObject;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
return result;
}
public String toString() {
return "Neo4jObject(id=" + this.getId() + ")";
}
}

View File

@@ -15,25 +15,27 @@
*/
package org.springframework.data.neo4j.integration.issues.events;
import lombok.AllArgsConstructor;
import java.util.Optional;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* @author Michael J. Simons
*/
@Service
@Transactional
@AllArgsConstructor
public class Neo4jObjectService {
private final EventsPublisherIT.Neo4jObjectRepository neo4jObjectRepository;
private final ApplicationEventPublisher publisher;
public Neo4jObjectService(EventsPublisherIT.Neo4jObjectRepository neo4jObjectRepository, ApplicationEventPublisher publisher) {
this.neo4jObjectRepository = neo4jObjectRepository;
this.publisher = publisher;
}
public Optional<Neo4jObject> findById(String id) {
return neo4jObjectRepository.findById(id);
}

View File

@@ -15,9 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2168;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.neo4j.core.convert.ConvertWith;
import org.springframework.data.neo4j.core.schema.CompositeProperty;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
@@ -29,8 +26,6 @@ import org.springframework.data.neo4j.core.schema.Property;
* @author Michael J. Simons
*/
@Node
@Getter
@Setter
public class DomainObject {
@Id
@@ -46,4 +41,36 @@ public class DomainObject {
@ConvertWith(converterRef = "converterBean")
private UnrelatedObject storedAsAnotherSingleProperty = new UnrelatedObject();
public String getId() {
return this.id;
}
public UnrelatedObject getStoredAsMultipleProperties() {
return this.storedAsMultipleProperties;
}
public UnrelatedObject getStoredAsSingleProperty() {
return this.storedAsSingleProperty;
}
public UnrelatedObject getStoredAsAnotherSingleProperty() {
return this.storedAsAnotherSingleProperty;
}
public void setId(String id) {
this.id = id;
}
public void setStoredAsMultipleProperties(UnrelatedObject storedAsMultipleProperties) {
this.storedAsMultipleProperties = storedAsMultipleProperties;
}
public void setStoredAsSingleProperty(UnrelatedObject storedAsSingleProperty) {
this.storedAsSingleProperty = storedAsSingleProperty;
}
public void setStoredAsAnotherSingleProperty(UnrelatedObject storedAsAnotherSingleProperty) {
this.storedAsAnotherSingleProperty = storedAsAnotherSingleProperty;
}
}

View File

@@ -27,6 +27,6 @@ public final class GeneratedValueStrategy implements IdGenerator<String> {
@Override
public String generateId(String primaryLabel, Object entity) {
return "Please use something that one randomly create conflicting ids :) " +
ThreadLocalRandom.current().nextLong();
ThreadLocalRandom.current().nextLong();
}
}

View File

@@ -15,14 +15,10 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2168;
import lombok.Getter;
import lombok.Setter;
/**
* @author Michael J. Simons
*/
@Getter
@Setter
@SuppressWarnings("HiddenField")
public class UnrelatedObject {
private boolean aBooleanValue;
@@ -36,4 +32,20 @@ public class UnrelatedObject {
this.aBooleanValue = aBooleanValue;
this.aLongValue = aLongValue;
}
public boolean isABooleanValue() {
return this.aBooleanValue;
}
public Long getALongValue() {
return this.aLongValue;
}
public void setABooleanValue(boolean aBooleanValue) {
this.aBooleanValue = aBooleanValue;
}
public void setALongValue(Long aLongValue) {
this.aLongValue = aLongValue;
}
}

View File

@@ -25,7 +25,8 @@ import org.springframework.data.neo4j.core.schema.Node;
@Node
public abstract class Step {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
public Long getId() {

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2289;
import lombok.Data;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.RelationshipId;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
@@ -25,17 +23,20 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
/**
* @author Michael J. Simons
*/
@Data // lombok
@RelationshipProperties
public class RangeRelation {
@RelationshipId
private Long id;
@Property private double minDelta;
@Property private double maxDelta;
@Property private RelationType relationType;
@Property
private double minDelta;
@Property
private double maxDelta;
@Property
private RelationType relationType;
@TargetNode private Sku targetSku;
@TargetNode
private Sku targetSku;
public RangeRelation(Sku targetSku, double minDelta, double maxDelta, RelationType relationType) {
this.targetSku = targetSku;
@@ -43,4 +44,103 @@ public class RangeRelation {
this.maxDelta = maxDelta;
this.relationType = relationType;
}
public Long getId() {
return this.id;
}
public double getMinDelta() {
return this.minDelta;
}
public double getMaxDelta() {
return this.maxDelta;
}
public RelationType getRelationType() {
return this.relationType;
}
public Sku getTargetSku() {
return this.targetSku;
}
public void setId(Long id) {
this.id = id;
}
public void setMinDelta(double minDelta) {
this.minDelta = minDelta;
}
public void setMaxDelta(double maxDelta) {
this.maxDelta = maxDelta;
}
public void setRelationType(RelationType relationType) {
this.relationType = relationType;
}
public void setTargetSku(Sku targetSku) {
this.targetSku = targetSku;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof RangeRelation)) {
return false;
}
final RangeRelation other = (RangeRelation) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
if (Double.compare(this.getMinDelta(), other.getMinDelta()) != 0) {
return false;
}
if (Double.compare(this.getMaxDelta(), other.getMaxDelta()) != 0) {
return false;
}
final Object this$relationType = this.getRelationType();
final Object other$relationType = other.getRelationType();
if (this$relationType == null ? other$relationType != null : !this$relationType.equals(other$relationType)) {
return false;
}
final Object this$targetSku = this.getTargetSku();
final Object other$targetSku = other.getTargetSku();
if (this$targetSku == null ? other$targetSku != null : !this$targetSku.equals(other$targetSku)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof RangeRelation;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final long $minDelta = Double.doubleToLongBits(this.getMinDelta());
result = result * PRIME + (int) ($minDelta >>> 32 ^ $minDelta);
final long $maxDelta = Double.doubleToLongBits(this.getMaxDelta());
result = result * PRIME + (int) ($maxDelta >>> 32 ^ $maxDelta);
final Object $relationType = this.getRelationType();
result = result * PRIME + ($relationType == null ? 43 : $relationType.hashCode());
final Object $targetSku = this.getTargetSku();
result = result * PRIME + ($targetSku == null ? 43 : $targetSku.hashCode());
return result;
}
public String toString() {
return "RangeRelation(id=" + this.getId() + ", minDelta=" + this.getMinDelta() + ", maxDelta=" + this.getMaxDelta() + ", relationType=" + this.getRelationType() + ", targetSku=" + this.getTargetSku() + ")";
}
}

View File

@@ -15,9 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2289;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.RelationshipId;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
@@ -26,19 +23,21 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
/**
* @author Michael J. Simons
*/
@Data // lombok
@RelationshipProperties
public class RangeRelationRO {
@EqualsAndHashCode.Exclude
@RelationshipId
private Long id;
@Property private double minDelta;
@Property private double maxDelta;
@Property private RelationType relationType;
@Property
private double minDelta;
@Property
private double maxDelta;
@Property
private RelationType relationType;
@TargetNode private SkuRO targetSku;
@TargetNode
private SkuRO targetSku;
public RangeRelationRO(SkuRO targetSku, double minDelta, double maxDelta, RelationType relationType) {
this.targetSku = targetSku;
@@ -46,4 +45,103 @@ public class RangeRelationRO {
this.maxDelta = maxDelta;
this.relationType = relationType;
}
public Long getId() {
return this.id;
}
public double getMinDelta() {
return this.minDelta;
}
public double getMaxDelta() {
return this.maxDelta;
}
public RelationType getRelationType() {
return this.relationType;
}
public SkuRO getTargetSku() {
return this.targetSku;
}
public void setId(Long id) {
this.id = id;
}
public void setMinDelta(double minDelta) {
this.minDelta = minDelta;
}
public void setMaxDelta(double maxDelta) {
this.maxDelta = maxDelta;
}
public void setRelationType(RelationType relationType) {
this.relationType = relationType;
}
public void setTargetSku(SkuRO targetSku) {
this.targetSku = targetSku;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof RangeRelationRO)) {
return false;
}
final RangeRelationRO other = (RangeRelationRO) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
if (Double.compare(this.getMinDelta(), other.getMinDelta()) != 0) {
return false;
}
if (Double.compare(this.getMaxDelta(), other.getMaxDelta()) != 0) {
return false;
}
final Object this$relationType = this.getRelationType();
final Object other$relationType = other.getRelationType();
if (this$relationType == null ? other$relationType != null : !this$relationType.equals(other$relationType)) {
return false;
}
final Object this$targetSku = this.getTargetSku();
final Object other$targetSku = other.getTargetSku();
if (this$targetSku == null ? other$targetSku != null : !this$targetSku.equals(other$targetSku)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof RangeRelationRO;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final long $minDelta = Double.doubleToLongBits(this.getMinDelta());
result = result * PRIME + (int) ($minDelta >>> 32 ^ $minDelta);
final long $maxDelta = Double.doubleToLongBits(this.getMaxDelta());
result = result * PRIME + (int) ($maxDelta >>> 32 ^ $maxDelta);
final Object $relationType = this.getRelationType();
result = result * PRIME + ($relationType == null ? 43 : $relationType.hashCode());
final Object $targetSku = this.getTargetSku();
result = result * PRIME + ($targetSku == null ? 43 : $targetSku.hashCode());
return result;
}
public String toString() {
return "RangeRelationRO(id=" + this.getId() + ", minDelta=" + this.getMinDelta() + ", maxDelta=" + this.getMaxDelta() + ", relationType=" + this.getRelationType() + ", targetSku=" + this.getTargetSku() + ")";
}
}

View File

@@ -15,27 +15,23 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2289;
import lombok.Getter;
import lombok.Setter;
import java.util.HashSet;
import java.util.Set;
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.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.HashSet;
import java.util.Set;
/**
* @author Michael J. Simons
*/
@Node("SKU")
@Getter // lombok
@Setter
public class Sku {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
@Property("number")
@@ -71,4 +67,44 @@ public class Sku {
", name='" + name +
'}';
}
public Long getId() {
return this.id;
}
public Long getNumber() {
return this.number;
}
public String getName() {
return this.name;
}
public Set<RangeRelation> getRangeRelationsOut() {
return this.rangeRelationsOut;
}
public Set<RangeRelation> getRangeRelationsIn() {
return this.rangeRelationsIn;
}
public void setId(Long id) {
this.id = id;
}
public void setNumber(Long number) {
this.number = number;
}
public void setName(String name) {
this.name = name;
}
public void setRangeRelationsOut(Set<RangeRelation> rangeRelationsOut) {
this.rangeRelationsOut = rangeRelationsOut;
}
public void setRangeRelationsIn(Set<RangeRelation> rangeRelationsIn) {
this.rangeRelationsIn = rangeRelationsIn;
}
}

View File

@@ -15,13 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2289;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.util.HashSet;
import java.util.Set;
import org.springframework.data.annotation.ReadOnlyProperty;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
@@ -29,25 +22,23 @@ import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.HashSet;
import java.util.Set;
/**
* @author Michael J. Simons
*/
@Node("SKU_RO")
@Getter // lombok
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class SkuRO {
@Id @GeneratedValue
@EqualsAndHashCode.Include
@Id
@GeneratedValue
private Long id;
@Property("number")
@EqualsAndHashCode.Include
private Long number;
@Property(value = "name", readOnly = true)
@EqualsAndHashCode.Include
private String name;
@Relationship(type = "RANGE_RELATION_TO", direction = Relationship.Direction.OUTGOING)
@@ -67,4 +58,89 @@ public class SkuRO {
rangeRelationsOut.add(relationOut);
return relationOut;
}
public Long getId() {
return this.id;
}
public Long getNumber() {
return this.number;
}
public String getName() {
return this.name;
}
public Set<RangeRelationRO> getRangeRelationsOut() {
return this.rangeRelationsOut;
}
public Set<RangeRelationRO> getRangeRelationsIn() {
return this.rangeRelationsIn;
}
public void setId(Long id) {
this.id = id;
}
public void setNumber(Long number) {
this.number = number;
}
public void setName(String name) {
this.name = name;
}
public void setRangeRelationsOut(Set<RangeRelationRO> rangeRelationsOut) {
this.rangeRelationsOut = rangeRelationsOut;
}
public void setRangeRelationsIn(Set<RangeRelationRO> rangeRelationsIn) {
this.rangeRelationsIn = rangeRelationsIn;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof SkuRO)) {
return false;
}
final SkuRO other = (SkuRO) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$number = this.getNumber();
final Object other$number = other.getNumber();
if (this$number == null ? other$number != null : !this$number.equals(other$number)) {
return false;
}
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof SkuRO;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $number = this.getNumber();
result = result * PRIME + ($number == null ? 43 : $number.hashCode());
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
return result;
}
}

View File

@@ -29,7 +29,8 @@ import org.springframework.data.neo4j.core.schema.Relationship;
@Node
public class Person {
@Id @GeneratedValue(GeneratedValue.UUIDGenerator.class)
@Id
@GeneratedValue(GeneratedValue.UUIDGenerator.class)
private String id;
private final String name;

View File

@@ -24,7 +24,8 @@ import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
*/
public abstract class BaseEntity {
@Id @GeneratedValue(UUIDStringGenerator.class)
@Id
@GeneratedValue(UUIDStringGenerator.class)
private String id;
public String getId() {

View File

@@ -15,26 +15,34 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2328;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
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 java.util.UUID;
/**
* @author Michael J. Simons
* @soundtrack Motörhead - Better Motörhead Than Dead - Live At Hammersmith
*/
@Node
@Getter
@RequiredArgsConstructor
public class Entity2328 {
@Id @GeneratedValue
@Id
@GeneratedValue
private UUID id;
private final String name;
public Entity2328(String name) {
this.name = name;
}
public UUID getId() {
return this.id;
}
public String getName() {
return this.name;
}
}

View File

@@ -15,14 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2415;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.NonFinal;
import lombok.experimental.SuperBuilder;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
@@ -31,24 +23,132 @@ import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
/**
* @author Andreas Berger
*/
@SuppressWarnings("HiddenField")
@Node
@NonFinal
@Data
@Setter(AccessLevel.PRIVATE)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@SuperBuilder(toBuilder = true)
public class BaseNodeEntity {
@Id
@GeneratedValue(UUIDStringGenerator.class)
@EqualsAndHashCode.Include
private String nodeId;
private String name;
protected BaseNodeEntity() {
}
protected BaseNodeEntity(BaseNodeEntityBuilder<?, ?> b) {
this.nodeId = b.nodeId;
this.name = b.name;
}
public static BaseNodeEntityBuilder<?, ?> builder() {
return new BaseNodeEntityBuilderImpl();
}
@Override
public String toString() {
return getClass().getSimpleName() + " - " + getName() + " (" + getNodeId() + ")";
}
public String getNodeId() {
return this.nodeId;
}
public String getName() {
return this.name;
}
private void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
private void setName(String name) {
this.name = name;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BaseNodeEntity)) {
return false;
}
final BaseNodeEntity other = (BaseNodeEntity) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$nodeId = this.getNodeId();
final Object other$nodeId = other.getNodeId();
if (this$nodeId == null ? other$nodeId != null : !this$nodeId.equals(other$nodeId)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof BaseNodeEntity;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $nodeId = this.getNodeId();
result = result * PRIME + ($nodeId == null ? 43 : $nodeId.hashCode());
return result;
}
public BaseNodeEntityBuilder<?, ?> toBuilder() {
return new BaseNodeEntityBuilderImpl().$fillValuesFrom(this);
}
/**
* the builder
* @param <C> needed c type
* @param <B> needed b type
*/
public static abstract class BaseNodeEntityBuilder<C extends BaseNodeEntity, B extends BaseNodeEntityBuilder<C, B>> {
private String nodeId;
private String name;
private static void $fillValuesFromInstanceIntoBuilder(BaseNodeEntity instance, BaseNodeEntityBuilder<?, ?> b) {
b.nodeId(instance.nodeId);
b.name(instance.name);
}
public B nodeId(String nodeId) {
this.nodeId = nodeId;
return self();
}
public B name(String name) {
this.name = name;
return self();
}
protected B $fillValuesFrom(C instance) {
BaseNodeEntityBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
return self();
}
protected abstract B self();
public abstract C build();
public String toString() {
return "BaseNodeEntity.BaseNodeEntityBuilder(nodeId=" + this.nodeId + ", name=" + this.name + ")";
}
}
private static final class BaseNodeEntityBuilderImpl extends BaseNodeEntityBuilder<BaseNodeEntity, BaseNodeEntityBuilderImpl> {
private BaseNodeEntityBuilderImpl() {
}
protected BaseNodeEntityBuilderImpl self() {
return this;
}
public BaseNodeEntity build() {
return new BaseNodeEntity(this);
}
}
}

View File

@@ -15,37 +15,113 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2415;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.With;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.annotation.Immutable;
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.support.UUIDStringGenerator;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Andreas Berger
*/
@SuppressWarnings("HiddenField")
@Node
@Value
@With
@AllArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Immutable
@Builder(toBuilder = true)
public class Credential {
public final class Credential {
@JsonIgnore
@Id
@GeneratedValue(UUIDStringGenerator.class)
@EqualsAndHashCode.Include
private final
String id;
String name;
private final String name;
public Credential(String id, String name) {
this.id = id;
this.name = name;
}
public static CredentialBuilder builder() {
return new CredentialBuilder();
}
public String getId() {
return this.id;
}
public String getName() {
return this.name;
}
public String toString() {
return "Credential(id=" + this.getId() + ", name=" + this.getName() + ")";
}
public Credential withId(String id) {
return this.id == id ? this : new Credential(id, this.name);
}
public Credential withName(String name) {
return this.name == name ? this : new Credential(this.id, name);
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Credential)) {
return false;
}
final Credential other = (Credential) o;
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
return result;
}
public CredentialBuilder toBuilder() {
return new CredentialBuilder().id(this.id).name(this.name);
}
/**
* the builder
*/
public static class CredentialBuilder {
private String id;
private String name;
CredentialBuilder() {
}
@JsonIgnore
public CredentialBuilder id(String id) {
this.id = id;
return this;
}
public CredentialBuilder name(String name) {
this.name = name;
return this;
}
public Credential build() {
return new Credential(this.id, this.name);
}
public String toString() {
return "Credential.CredentialBuilder(id=" + this.id + ", name=" + this.name + ")";
}
}
}

View File

@@ -15,29 +15,17 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2415;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Set;
/**
* @author Andreas Berger
*/
@SuppressWarnings("HiddenField")
@Node
@Data
@Setter(AccessLevel.PRIVATE)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true)
@SuperBuilder(toBuilder = true)
public class NodeEntity extends BaseNodeEntity implements NodeWithDefinedCredentials {
@JsonIgnore
@@ -47,8 +35,121 @@ public class NodeEntity extends BaseNodeEntity implements NodeWithDefinedCredent
@Relationship(type = "HAS_CREDENTIAL")
private Set<Credential> definedCredentials;
protected NodeEntity() {
}
protected NodeEntity(NodeEntityBuilder<?, ?> b) {
super(b);
this.children = b.children;
this.definedCredentials = b.definedCredentials;
}
public static NodeEntityBuilder<?, ?> builder() {
return new NodeEntityBuilderImpl();
}
@Override
public String toString() {
return super.toString();
}
public Set<BaseNodeEntity> getChildren() {
return this.children;
}
public Set<Credential> getDefinedCredentials() {
return this.definedCredentials;
}
@JsonIgnore
private void setChildren(Set<BaseNodeEntity> children) {
this.children = children;
}
private void setDefinedCredentials(Set<Credential> definedCredentials) {
this.definedCredentials = definedCredentials;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof NodeEntity)) {
return false;
}
final NodeEntity other = (NodeEntity) o;
if (!other.canEqual((Object) this)) {
return false;
}
if (!super.equals(o)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof NodeEntity;
}
public int hashCode() {
int result = super.hashCode();
return result;
}
public NodeEntityBuilder<?, ?> toBuilder() {
return new NodeEntityBuilderImpl().$fillValuesFrom(this);
}
/**
* the builder
* @param <C> needed c type
* @param <B> needed b type
*/
public static abstract class NodeEntityBuilder<C extends NodeEntity, B extends NodeEntityBuilder<C, B>> extends BaseNodeEntityBuilder<C, B> {
private Set<BaseNodeEntity> children;
private Set<Credential> definedCredentials;
private static void $fillValuesFromInstanceIntoBuilder(NodeEntity instance, NodeEntityBuilder<?, ?> b) {
b.children(instance.children);
b.definedCredentials(instance.definedCredentials);
}
@JsonIgnore
public B children(Set<BaseNodeEntity> children) {
this.children = children;
return self();
}
public B definedCredentials(Set<Credential> definedCredentials) {
this.definedCredentials = definedCredentials;
return self();
}
protected B $fillValuesFrom(C instance) {
super.$fillValuesFrom(instance);
NodeEntityBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
return self();
}
protected abstract B self();
public abstract C build();
public String toString() {
return "NodeEntity.NodeEntityBuilder(super=" + super.toString() + ", children=" + this.children + ", definedCredentials=" + this.definedCredentials + ")";
}
}
private static final class NodeEntityBuilderImpl extends NodeEntityBuilder<NodeEntity, NodeEntityBuilderImpl> {
private NodeEntityBuilderImpl() {
}
protected NodeEntityBuilderImpl self() {
return this;
}
public NodeEntity build() {
return new NodeEntity(this);
}
}
}

View File

@@ -15,26 +15,37 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2459;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.List;
/**
* Labels are written out on purpose for the test.
*
* @author Gerrit Meier
*/
@Node("PetOwner")
@Getter
@Setter
public abstract class PetOwner {
@Id
private String uuid;
@Relationship(type = "hasPet")
private List<Animal> pets;
public String getUuid() {
return this.uuid;
}
public List<Animal> getPets() {
return this.pets;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setPets(List<Animal> pets) {
this.pets = pets;
}
}

View File

@@ -15,23 +15,20 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2474;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
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.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author Stephen Jackson
*/
@Node
@Data
public class CityModel {
@Id
@GeneratedValue(generatorClass = GeneratedValue.UUIDGenerator.class)
@@ -50,4 +47,125 @@ public class CityModel {
@Property("exotic.property")
private String exoticProperty;
public CityModel() {
}
public UUID getCityId() {
return this.cityId;
}
public PersonModel getMayor() {
return this.mayor;
}
public List<PersonModel> getCitizens() {
return this.citizens;
}
public List<JobRelationship> getCityEmployees() {
return this.cityEmployees;
}
public String getName() {
return this.name;
}
public String getExoticProperty() {
return this.exoticProperty;
}
public void setCityId(UUID cityId) {
this.cityId = cityId;
}
public void setMayor(PersonModel mayor) {
this.mayor = mayor;
}
public void setCitizens(List<PersonModel> citizens) {
this.citizens = citizens;
}
public void setCityEmployees(List<JobRelationship> cityEmployees) {
this.cityEmployees = cityEmployees;
}
public void setName(String name) {
this.name = name;
}
public void setExoticProperty(String exoticProperty) {
this.exoticProperty = exoticProperty;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CityModel)) {
return false;
}
final CityModel other = (CityModel) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$cityId = this.getCityId();
final Object other$cityId = other.getCityId();
if (this$cityId == null ? other$cityId != null : !this$cityId.equals(other$cityId)) {
return false;
}
final Object this$mayor = this.getMayor();
final Object other$mayor = other.getMayor();
if (this$mayor == null ? other$mayor != null : !this$mayor.equals(other$mayor)) {
return false;
}
final Object this$citizens = this.getCitizens();
final Object other$citizens = other.getCitizens();
if (this$citizens == null ? other$citizens != null : !this$citizens.equals(other$citizens)) {
return false;
}
final Object this$cityEmployees = this.getCityEmployees();
final Object other$cityEmployees = other.getCityEmployees();
if (this$cityEmployees == null ? other$cityEmployees != null : !this$cityEmployees.equals(other$cityEmployees)) {
return false;
}
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
final Object this$exoticProperty = this.getExoticProperty();
final Object other$exoticProperty = other.getExoticProperty();
if (this$exoticProperty == null ? other$exoticProperty != null : !this$exoticProperty.equals(other$exoticProperty)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof CityModel;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $cityId = this.getCityId();
result = result * PRIME + ($cityId == null ? 43 : $cityId.hashCode());
final Object $mayor = this.getMayor();
result = result * PRIME + ($mayor == null ? 43 : $mayor.hashCode());
final Object $citizens = this.getCitizens();
result = result * PRIME + ($citizens == null ? 43 : $citizens.hashCode());
final Object $cityEmployees = this.getCityEmployees();
result = result * PRIME + ($cityEmployees == null ? 43 : $cityEmployees.hashCode());
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $exoticProperty = this.getExoticProperty();
result = result * PRIME + ($exoticProperty == null ? 43 : $exoticProperty.hashCode());
return result;
}
public String toString() {
return "CityModel(cityId=" + this.getCityId() + ", mayor=" + this.getMayor() + ", citizens=" + this.getCitizens() + ", cityEmployees=" + this.getCityEmployees() + ", name=" + this.getName() + ", exoticProperty=" + this.getExoticProperty() + ")";
}
}

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2474;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -24,7 +22,6 @@ import java.util.UUID;
/**
* @author Stephen Jackson
*/
@Data
public class CityModelDTO {
private UUID cityId;
private String name;
@@ -34,19 +31,230 @@ public class CityModelDTO {
public List<PersonModelDTO> citizens = new ArrayList<>();
public List<JobRelationshipDTO> cityEmployees = new ArrayList<>();
/**
* Nested projection
*/
@Data
public static class PersonModelDTO {
private UUID personId;
public CityModelDTO() {
}
public UUID getCityId() {
return this.cityId;
}
public String getName() {
return this.name;
}
public String getExoticProperty() {
return this.exoticProperty;
}
public PersonModelDTO getMayor() {
return this.mayor;
}
public List<PersonModelDTO> getCitizens() {
return this.citizens;
}
public List<JobRelationshipDTO> getCityEmployees() {
return this.cityEmployees;
}
public void setCityId(UUID cityId) {
this.cityId = cityId;
}
public void setName(String name) {
this.name = name;
}
public void setExoticProperty(String exoticProperty) {
this.exoticProperty = exoticProperty;
}
public void setMayor(PersonModelDTO mayor) {
this.mayor = mayor;
}
public void setCitizens(List<PersonModelDTO> citizens) {
this.citizens = citizens;
}
public void setCityEmployees(List<JobRelationshipDTO> cityEmployees) {
this.cityEmployees = cityEmployees;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CityModelDTO)) {
return false;
}
final CityModelDTO other = (CityModelDTO) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$cityId = this.getCityId();
final Object other$cityId = other.getCityId();
if (this$cityId == null ? other$cityId != null : !this$cityId.equals(other$cityId)) {
return false;
}
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
final Object this$exoticProperty = this.getExoticProperty();
final Object other$exoticProperty = other.getExoticProperty();
if (this$exoticProperty == null ? other$exoticProperty != null : !this$exoticProperty.equals(other$exoticProperty)) {
return false;
}
final Object this$mayor = this.getMayor();
final Object other$mayor = other.getMayor();
if (this$mayor == null ? other$mayor != null : !this$mayor.equals(other$mayor)) {
return false;
}
final Object this$citizens = this.getCitizens();
final Object other$citizens = other.getCitizens();
if (this$citizens == null ? other$citizens != null : !this$citizens.equals(other$citizens)) {
return false;
}
final Object this$cityEmployees = this.getCityEmployees();
final Object other$cityEmployees = other.getCityEmployees();
if (this$cityEmployees == null ? other$cityEmployees != null : !this$cityEmployees.equals(other$cityEmployees)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof CityModelDTO;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $cityId = this.getCityId();
result = result * PRIME + ($cityId == null ? 43 : $cityId.hashCode());
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $exoticProperty = this.getExoticProperty();
result = result * PRIME + ($exoticProperty == null ? 43 : $exoticProperty.hashCode());
final Object $mayor = this.getMayor();
result = result * PRIME + ($mayor == null ? 43 : $mayor.hashCode());
final Object $citizens = this.getCitizens();
result = result * PRIME + ($citizens == null ? 43 : $citizens.hashCode());
final Object $cityEmployees = this.getCityEmployees();
result = result * PRIME + ($cityEmployees == null ? 43 : $cityEmployees.hashCode());
return result;
}
public String toString() {
return "CityModelDTO(cityId=" + this.getCityId() + ", name=" + this.getName() + ", exoticProperty=" + this.getExoticProperty() + ", mayor=" + this.getMayor() + ", citizens=" + this.getCitizens() + ", cityEmployees=" + this.getCityEmployees() + ")";
}
/**
* Nested projection
*/
public static class PersonModelDTO {
private UUID personId;
public PersonModelDTO() {
}
public UUID getPersonId() {
return this.personId;
}
public void setPersonId(UUID personId) {
this.personId = personId;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof PersonModelDTO)) {
return false;
}
final PersonModelDTO other = (PersonModelDTO) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$personId = this.getPersonId();
final Object other$personId = other.getPersonId();
if (this$personId == null ? other$personId != null : !this$personId.equals(other$personId)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof PersonModelDTO;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $personId = this.getPersonId();
result = result * PRIME + ($personId == null ? 43 : $personId.hashCode());
return result;
}
public String toString() {
return "CityModelDTO.PersonModelDTO(personId=" + this.getPersonId() + ")";
}
}
/**
* Nested projection
*/
@Data
public static class JobRelationshipDTO {
private PersonModelDTO person;
public JobRelationshipDTO() {
}
public PersonModelDTO getPerson() {
return this.person;
}
public void setPerson(PersonModelDTO person) {
this.person = person;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof JobRelationshipDTO)) {
return false;
}
final JobRelationshipDTO other = (JobRelationshipDTO) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$person = this.getPerson();
final Object other$person = other.getPerson();
if (this$person == null ? other$person != null : !this$person.equals(other$person)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof JobRelationshipDTO;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $person = this.getPerson();
result = result * PRIME + ($person == null ? 43 : $person.hashCode());
return result;
}
public String toString() {
return "CityModelDTO.JobRelationshipDTO(person=" + this.getPerson() + ")";
}
}
}

View File

@@ -32,8 +32,8 @@ public interface CityModelRepository extends Neo4jRepository<CityModel, UUID> {
Optional<CityModelDTO> findByCityId(UUID cityId);
@Query(""
+ "MATCH (n:CityModel)"
+ "RETURN n :#{orderBy(#sort)}")
+ "MATCH (n:CityModel)"
+ "RETURN n :#{orderBy(#sort)}")
List<CityModel> customQuery(Sort sort);
long deleteAllByExoticProperty(String property);

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2474;
import lombok.Data;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
@@ -25,14 +24,89 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
* @author Stephen Jackson
*/
@RelationshipProperties
@Data
public class JobRelationship {
@Id
@GeneratedValue
private Long id;
@Id
@GeneratedValue
private Long id;
@TargetNode
private PersonModel person;
@TargetNode
private PersonModel person;
private String jobTitle;
private String jobTitle;
public JobRelationship() {
}
public Long getId() {
return this.id;
}
public PersonModel getPerson() {
return this.person;
}
public String getJobTitle() {
return this.jobTitle;
}
public void setId(Long id) {
this.id = id;
}
public void setPerson(PersonModel person) {
this.person = person;
}
public void setJobTitle(String jobTitle) {
this.jobTitle = jobTitle;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof JobRelationship)) {
return false;
}
final JobRelationship other = (JobRelationship) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$person = this.getPerson();
final Object other$person = other.getPerson();
if (this$person == null ? other$person != null : !this$person.equals(other$person)) {
return false;
}
final Object this$jobTitle = this.getJobTitle();
final Object other$jobTitle = other.getJobTitle();
if (this$jobTitle == null ? other$jobTitle != null : !this$jobTitle.equals(other$jobTitle)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof JobRelationship;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $person = this.getPerson();
result = result * PRIME + ($person == null ? 43 : $person.hashCode());
final Object $jobTitle = this.getJobTitle();
result = result * PRIME + ($jobTitle == null ? 43 : $jobTitle.hashCode());
return result;
}
public String toString() {
return "JobRelationship(id=" + this.getId() + ", person=" + this.getPerson() + ", jobTitle=" + this.getJobTitle() + ")";
}
}

View File

@@ -15,19 +15,16 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2474;
import lombok.Data;
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 java.util.UUID;
/**
* @author Stephen Jackson
*/
@Node
@Data
public class PersonModel {
@Id
@GeneratedValue(generatorClass = GeneratedValue.UUIDGenerator.class)
@@ -36,4 +33,95 @@ public class PersonModel {
private String address;
private String name;
private String favoriteFood;
public PersonModel() {
}
public UUID getPersonId() {
return this.personId;
}
public String getAddress() {
return this.address;
}
public String getName() {
return this.name;
}
public String getFavoriteFood() {
return this.favoriteFood;
}
public void setPersonId(UUID personId) {
this.personId = personId;
}
public void setAddress(String address) {
this.address = address;
}
public void setName(String name) {
this.name = name;
}
public void setFavoriteFood(String favoriteFood) {
this.favoriteFood = favoriteFood;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof PersonModel)) {
return false;
}
final PersonModel other = (PersonModel) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$personId = this.getPersonId();
final Object other$personId = other.getPersonId();
if (this$personId == null ? other$personId != null : !this$personId.equals(other$personId)) {
return false;
}
final Object this$address = this.getAddress();
final Object other$address = other.getAddress();
if (this$address == null ? other$address != null : !this$address.equals(other$address)) {
return false;
}
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
final Object this$favoriteFood = this.getFavoriteFood();
final Object other$favoriteFood = other.getFavoriteFood();
if (this$favoriteFood == null ? other$favoriteFood != null : !this$favoriteFood.equals(other$favoriteFood)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof PersonModel;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $personId = this.getPersonId();
result = result * PRIME + ($personId == null ? 43 : $personId.hashCode());
final Object $address = this.getAddress();
result = result * PRIME + ($address == null ? 43 : $address.hashCode());
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $favoriteFood = this.getFavoriteFood();
result = result * PRIME + ($favoriteFood == null ? 43 : $favoriteFood.hashCode());
return result;
}
public String toString() {
return "PersonModel(personId=" + this.getPersonId() + ", address=" + this.getAddress() + ", name=" + this.getName() + ", favoriteFood=" + this.getFavoriteFood() + ")";
}
}

View File

@@ -32,7 +32,7 @@ public class TestConverter implements Neo4jPersistentPropertyToMapConverter<Stri
@Override
public Map<String, Value> decompose(TestData property,
Neo4jConversionService neo4jConversionService) {
Neo4jConversionService neo4jConversionService) {
if (property == null) {
return Map.of();
@@ -43,7 +43,7 @@ public class TestConverter implements Neo4jPersistentPropertyToMapConverter<Stri
@Override
public TestData compose(Map<String, Value> source,
Neo4jConversionService neo4jConversionService) {
Neo4jConversionService neo4jConversionService) {
TestData data = new TestData();
if (source.get(NUM) != null) {
data.setNum(source.get(NUM).asInt());

View File

@@ -15,14 +15,9 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2493;
import lombok.Getter;
import lombok.Setter;
/**
* @author Michael J. Simons
*/
@Getter
@Setter
public class TestData {
private int num;
@@ -36,4 +31,20 @@ public class TestData {
this.num = num;
this.string = string;
}
public int getNum() {
return this.num;
}
public String getString() {
return this.string;
}
public void setNum(int num) {
this.num = num;
}
public void setString(String string) {
this.string = string;
}
}

View File

@@ -15,9 +15,7 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2493;
import lombok.Getter;
import lombok.Setter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.neo4j.core.schema.CompositeProperty;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
@@ -25,14 +23,10 @@ import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Michael J. Simons
*/
@Node
@Getter
@Setter
public class TestObject {
@Id
@@ -48,4 +42,21 @@ public class TestObject {
super();
data = aData;
}
public String getId() {
return this.id;
}
public TestData getData() {
return this.data;
}
public void setId(String id) {
this.id = id;
}
@JsonIgnore
public void setData(TestData data) {
this.data = data;
}
}

View File

@@ -27,7 +27,9 @@ import org.springframework.data.neo4j.core.schema.Node;
@Node
public class DomainModel {
@Id @GeneratedValue UUID id;
@Id
@GeneratedValue
UUID id;
private final String name;

View File

@@ -15,12 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2498;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
@@ -29,16 +23,73 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
/**
* @author Michael J. Simons
*/
@SuppressWarnings("HiddenField")
@RelationshipProperties
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public class Edge {
@Id
@GeneratedValue
Long id;
@TargetNode
Vertex vertex;
public Edge(Long id, Vertex vertex) {
this.id = id;
this.vertex = vertex;
}
public Edge() {
}
public static EdgeBuilder builder() {
return new EdgeBuilder();
}
public Long getId() {
return this.id;
}
public Vertex getVertex() {
return this.vertex;
}
public void setId(Long id) {
this.id = id;
}
public void setVertex(Vertex vertex) {
this.vertex = vertex;
}
public EdgeBuilder toBuilder() {
return new EdgeBuilder().id(this.id).vertex(this.vertex);
}
/**
* the builder
*/
public static class EdgeBuilder {
private Long id;
private Vertex vertex;
EdgeBuilder() {
}
public EdgeBuilder id(Long id) {
this.id = id;
return this;
}
public EdgeBuilder vertex(Vertex vertex) {
this.vertex = vertex;
return this;
}
public Edge build() {
return new Edge(this.id, this.vertex);
}
public String toString() {
return "Edge.EdgeBuilder(id=" + this.id + ", vertex=" + this.vertex + ")";
}
}
}

View File

@@ -15,33 +15,99 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2498;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
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;
import java.util.List;
/**
* @author Michael J. Simons
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@SuppressWarnings("HiddenField")
@Node("Vertex")
@Builder(toBuilder = true)
public class Vertex {
@Id
@GeneratedValue
Long id;
String name;
@Relationship(type = "CONNECTED_TO", direction = Relationship.Direction.INCOMING)
@Id
@GeneratedValue
Long id;
String name;
@Relationship(type = "CONNECTED_TO", direction = Relationship.Direction.INCOMING)
List<Edge> edges;
public Vertex(Long id, String name, List<Edge> edges) {
this.id = id;
this.name = name;
this.edges = edges;
}
public Vertex() {
}
public static VertexBuilder builder() {
return new VertexBuilder();
}
public Long getId() {
return this.id;
}
public String getName() {
return this.name;
}
public List<Edge> getEdges() {
return this.edges;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setEdges(List<Edge> edges) {
this.edges = edges;
}
public VertexBuilder toBuilder() {
return new VertexBuilder().id(this.id).name(this.name).edges(this.edges);
}
/**
* the builder
*/
public static class VertexBuilder {
private Long id;
private String name;
private List<Edge> edges;
VertexBuilder() {
}
public VertexBuilder id(Long id) {
this.id = id;
return this;
}
public VertexBuilder name(String name) {
this.name = name;
return this;
}
public VertexBuilder edges(List<Edge> edges) {
this.edges = edges;
return this;
}
public Vertex build() {
return new Vertex(this.id, this.name, this.edges);
}
public String toString() {
return "Vertex.VertexBuilder(id=" + this.id + ", name=" + this.name + ", edges=" + this.edges + ")";
}
}
}

View File

@@ -15,23 +15,18 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2500;
import lombok.Getter;
import lombok.Setter;
import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.data.annotation.Version;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* @author Michael J. Simons
*/
@Node
@Getter
@Setter
public class Device {
@Id
@@ -65,4 +60,36 @@ public class Device {
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
public Long getId() {
return this.id;
}
public Long getVersion() {
return this.version;
}
public String getName() {
return this.name;
}
public Set<Group> getGroups() {
return this.groups;
}
public void setId(Long id) {
this.id = id;
}
public void setVersion(Long version) {
this.version = version;
}
public void setName(String name) {
this.name = name;
}
public void setGroups(Set<Group> groups) {
this.groups = groups;
}
}

View File

@@ -15,12 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2500;
import lombok.Getter;
import lombok.Setter;
import java.util.LinkedHashSet;
import java.util.Set;
import org.springframework.data.annotation.Version;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
@@ -29,12 +23,13 @@ import org.springframework.data.neo4j.core.schema.Relationship;
import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
import org.springframework.lang.NonNull;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* @author Michael J. Simons
*/
@Node
@Getter
@Setter
public class Group {
@Id
@@ -77,4 +72,45 @@ public class Group {
result = 31 * result + name.hashCode();
return result;
}
public String getId() {
return this.id;
}
public Long getVersion() {
return this.version;
}
@NonNull
public String getName() {
return this.name;
}
public Set<Device> getDevices() {
return this.devices;
}
public Set<Group> getGroups() {
return this.groups;
}
public void setId(String id) {
this.id = id;
}
public void setVersion(Long version) {
this.version = version;
}
public void setName(@NonNull String name) {
this.name = name;
}
public void setDevices(Set<Device> devices) {
this.devices = devices;
}
public void setGroups(Set<Group> groups) {
this.groups = groups;
}
}

View File

@@ -15,31 +15,138 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2526;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
/**
* Defining most concrete entity
*/
@SuppressWarnings("HiddenField")
@Node
@Data
@Setter(AccessLevel.PRIVATE)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true)
@SuperBuilder(toBuilder = true)
public class AccountingMeasurementMeta extends MeasurementMeta {
private String formula;
@Relationship(type = "WEIGHTS", direction = Relationship.Direction.OUTGOING)
private MeasurementMeta baseMeasurement;
protected AccountingMeasurementMeta(String formula, MeasurementMeta baseMeasurement) {
this.formula = formula;
this.baseMeasurement = baseMeasurement;
}
protected AccountingMeasurementMeta() {
}
protected AccountingMeasurementMeta(AccountingMeasurementMetaBuilder<?, ?> b) {
super(b);
this.formula = b.formula;
this.baseMeasurement = b.baseMeasurement;
}
public static AccountingMeasurementMetaBuilder<?, ?> builder() {
return new AccountingMeasurementMetaBuilderImpl();
}
public String getFormula() {
return this.formula;
}
public MeasurementMeta getBaseMeasurement() {
return this.baseMeasurement;
}
public String toString() {
return "AccountingMeasurementMeta(formula=" + this.getFormula() + ", baseMeasurement=" + this.getBaseMeasurement() + ")";
}
private void setFormula(String formula) {
this.formula = formula;
}
private void setBaseMeasurement(MeasurementMeta baseMeasurement) {
this.baseMeasurement = baseMeasurement;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof AccountingMeasurementMeta)) {
return false;
}
final AccountingMeasurementMeta other = (AccountingMeasurementMeta) o;
if (!other.canEqual((Object) this)) {
return false;
}
if (!super.equals(o)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof AccountingMeasurementMeta;
}
public int hashCode() {
int result = super.hashCode();
return result;
}
public AccountingMeasurementMetaBuilder<?, ?> toBuilder() {
return new AccountingMeasurementMetaBuilderImpl().$fillValuesFrom(this);
}
/**
* the builder
* @param <C> needed c type
* @param <B> needed b type
*/
public static abstract class AccountingMeasurementMetaBuilder<C extends AccountingMeasurementMeta, B extends AccountingMeasurementMetaBuilder<C, B>> extends MeasurementMetaBuilder<C, B> {
private String formula;
private MeasurementMeta baseMeasurement;
private static void $fillValuesFromInstanceIntoBuilder(AccountingMeasurementMeta instance, AccountingMeasurementMetaBuilder<?, ?> b) {
b.formula(instance.formula);
b.baseMeasurement(instance.baseMeasurement);
}
public B formula(String formula) {
this.formula = formula;
return self();
}
public B baseMeasurement(MeasurementMeta baseMeasurement) {
this.baseMeasurement = baseMeasurement;
return self();
}
protected B $fillValuesFrom(C instance) {
super.$fillValuesFrom(instance);
AccountingMeasurementMetaBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
return self();
}
protected abstract B self();
public abstract C build();
public String toString() {
return "AccountingMeasurementMeta.AccountingMeasurementMetaBuilder(super=" + super.toString() + ", formula=" + this.formula + ", baseMeasurement=" + this.baseMeasurement + ")";
}
}
private static final class AccountingMeasurementMetaBuilderImpl extends AccountingMeasurementMetaBuilder<AccountingMeasurementMeta, AccountingMeasurementMetaBuilderImpl> {
private AccountingMeasurementMetaBuilderImpl() {
}
protected AccountingMeasurementMetaBuilderImpl self() {
return this;
}
public AccountingMeasurementMeta build() {
return new AccountingMeasurementMeta(this);
}
}
}

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2526;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.With;
import org.springframework.data.annotation.Immutable;
import org.springframework.data.neo4j.core.schema.RelationshipId;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
@@ -28,20 +23,76 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
/**
* Relationship with properties between measurement and measurand
*/
@SuppressWarnings("HiddenField")
@RelationshipProperties
@Value
@With
@AllArgsConstructor
@Immutable
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class DataPoint {
public final class DataPoint {
@RelationshipId
private final
Long id;
boolean manual;
private final boolean manual;
@TargetNode
@EqualsAndHashCode.Include
private final
Measurand measurand;
public DataPoint(Long id, boolean manual, Measurand measurand) {
this.id = id;
this.manual = manual;
this.measurand = measurand;
}
public Long getId() {
return this.id;
}
public boolean isManual() {
return this.manual;
}
public Measurand getMeasurand() {
return this.measurand;
}
public String toString() {
return "DataPoint(id=" + this.getId() + ", manual=" + this.isManual() + ", measurand=" + this.getMeasurand() + ")";
}
public DataPoint withId(Long id) {
return this.id == id ? this : new DataPoint(id, this.manual, this.measurand);
}
public DataPoint withManual(boolean manual) {
return this.manual == manual ? this : new DataPoint(this.id, manual, this.measurand);
}
public DataPoint withMeasurand(Measurand measurand) {
return this.measurand == measurand ? this : new DataPoint(this.id, this.manual, measurand);
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof DataPoint)) {
return false;
}
final DataPoint other = (DataPoint) o;
final Object this$measurand = this.getMeasurand();
final Object other$measurand = other.getMeasurand();
if (this$measurand == null ? other$measurand != null : !this$measurand.equals(other$measurand)) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $measurand = this.getMeasurand();
result = result * PRIME + ($measurand == null ? 43 : $measurand.hashCode());
return result;
}
}

View File

@@ -15,9 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2526;
import lombok.AllArgsConstructor;
import lombok.Value;
import org.springframework.data.annotation.Immutable;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
@@ -26,11 +23,46 @@ import org.springframework.data.neo4j.core.schema.Node;
* Target node
*/
@Node
@Value
@AllArgsConstructor
@Immutable
public class Measurand {
public final class Measurand {
@Id
private final
String measurandId;
public Measurand(String measurandId) {
this.measurandId = measurandId;
}
public String getMeasurandId() {
return this.measurandId;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Measurand)) {
return false;
}
final Measurand other = (Measurand) o;
final Object this$measurandId = this.getMeasurandId();
final Object other$measurandId = other.getMeasurandId();
if (this$measurandId == null ? other$measurandId != null : !this$measurandId.equals(other$measurandId)) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $measurandId = this.getMeasurandId();
result = result * PRIME + ($measurandId == null ? 43 : $measurandId.hashCode());
return result;
}
public String toString() {
return "Measurand(measurandId=" + this.getMeasurandId() + ")";
}
}

View File

@@ -15,30 +15,17 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2526;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import java.util.Set;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
import org.springframework.data.neo4j.integration.issues.gh2415.BaseNodeEntity;
import java.util.Set;
/**
* Defining relationship to measurand
*/
@SuppressWarnings("HiddenField")
@Node
@Data
@Setter(AccessLevel.PRIVATE)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true)
@SuperBuilder(toBuilder = true)
public class MeasurementMeta extends BaseNodeEntity {
@Relationship(type = "IS_MEASURED_BY", direction = Relationship.Direction.INCOMING)
@@ -46,4 +33,124 @@ public class MeasurementMeta extends BaseNodeEntity {
@Relationship(type = "USES", direction = Relationship.Direction.OUTGOING)
private Set<Variable> variables;
protected MeasurementMeta(Set<DataPoint> dataPoints, Set<Variable> variables) {
this.dataPoints = dataPoints;
this.variables = variables;
}
protected MeasurementMeta() {
}
protected MeasurementMeta(MeasurementMetaBuilder<?, ?> b) {
super(b);
this.dataPoints = b.dataPoints;
this.variables = b.variables;
}
public static MeasurementMetaBuilder<?, ?> builder() {
return new MeasurementMetaBuilderImpl();
}
public Set<DataPoint> getDataPoints() {
return this.dataPoints;
}
public Set<Variable> getVariables() {
return this.variables;
}
public String toString() {
return "MeasurementMeta(dataPoints=" + this.getDataPoints() + ", variables=" + this.getVariables() + ")";
}
private void setDataPoints(Set<DataPoint> dataPoints) {
this.dataPoints = dataPoints;
}
private void setVariables(Set<Variable> variables) {
this.variables = variables;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof MeasurementMeta)) {
return false;
}
final MeasurementMeta other = (MeasurementMeta) o;
if (!other.canEqual((Object) this)) {
return false;
}
if (!super.equals(o)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof MeasurementMeta;
}
public int hashCode() {
int result = super.hashCode();
return result;
}
public MeasurementMetaBuilder<?, ?> toBuilder() {
return new MeasurementMetaBuilderImpl().$fillValuesFrom(this);
}
/**
* the builder
* @param <C> needed c type
* @param <B> needed b type
*/
public static abstract class MeasurementMetaBuilder<C extends MeasurementMeta, B extends MeasurementMetaBuilder<C, B>> extends BaseNodeEntityBuilder<C, B> {
private Set<DataPoint> dataPoints;
private Set<Variable> variables;
private static void $fillValuesFromInstanceIntoBuilder(MeasurementMeta instance, MeasurementMetaBuilder<?, ?> b) {
b.dataPoints(instance.dataPoints);
b.variables(instance.variables);
}
public B dataPoints(Set<DataPoint> dataPoints) {
this.dataPoints = dataPoints;
return self();
}
public B variables(Set<Variable> variables) {
this.variables = variables;
return self();
}
protected B $fillValuesFrom(C instance) {
super.$fillValuesFrom(instance);
MeasurementMetaBuilder.$fillValuesFromInstanceIntoBuilder(instance, this);
return self();
}
protected abstract B self();
public abstract C build();
public String toString() {
return "MeasurementMeta.MeasurementMetaBuilder(super=" + super.toString() + ", dataPoints=" + this.dataPoints + ", variables=" + this.variables + ")";
}
}
private static final class MeasurementMetaBuilderImpl extends MeasurementMetaBuilder<MeasurementMeta, MeasurementMetaBuilderImpl> {
private MeasurementMetaBuilderImpl() {
}
protected MeasurementMetaBuilderImpl self() {
return this;
}
public MeasurementMeta build() {
return new MeasurementMeta(this);
}
}
}

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2526;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.With;
import org.springframework.data.annotation.Immutable;
import org.springframework.data.neo4j.core.schema.RelationshipId;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
@@ -28,20 +23,25 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
/**
* Second type of relationship
*/
@SuppressWarnings("HiddenField")
@RelationshipProperties
@Value
@With
@AllArgsConstructor
@EqualsAndHashCode
@Immutable
public class Variable {
public final class Variable {
@RelationshipId
private final
Long id;
@TargetNode
private final
MeasurementMeta measurement;
String variable;
private final String variable;
public Variable(Long id, MeasurementMeta measurement, String variable) {
this.id = id;
this.measurement = measurement;
this.variable = variable;
}
public static Variable create(MeasurementMeta measurement, String variable) {
return new Variable(null, measurement, variable);
@@ -51,4 +51,66 @@ public class Variable {
public String toString() {
return variable + ": " + measurement.getNodeId();
}
public Long getId() {
return this.id;
}
public MeasurementMeta getMeasurement() {
return this.measurement;
}
public String getVariable() {
return this.variable;
}
public Variable withId(Long id) {
return this.id == id ? this : new Variable(id, this.measurement, this.variable);
}
public Variable withMeasurement(MeasurementMeta measurement) {
return this.measurement == measurement ? this : new Variable(this.id, measurement, this.variable);
}
public Variable withVariable(String variable) {
return this.variable == variable ? this : new Variable(this.id, this.measurement, variable);
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Variable)) {
return false;
}
final Variable other = (Variable) o;
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$measurement = this.getMeasurement();
final Object other$measurement = other.getMeasurement();
if (this$measurement == null ? other$measurement != null : !this$measurement.equals(other$measurement)) {
return false;
}
final Object this$variable = this.getVariable();
final Object other$variable = other.getVariable();
if (this$variable == null ? other$variable != null : !this$variable.equals(other$variable)) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $measurement = this.getMeasurement();
result = result * PRIME + ($measurement == null ? 43 : $measurement.hashCode());
final Object $variable = this.getVariable();
result = result * PRIME + ($variable == null ? 43 : $variable.hashCode());
return result;
}
}

View File

@@ -24,8 +24,8 @@ import java.util.UUID;
*/
public class SomeStringGenerator implements IdGenerator<String> {
@Override
public String generateId(String primaryLabel, Object entity) {
return primaryLabel + UUID.randomUUID();
}
@Override
public String generateId(String primaryLabel, Object entity) {
return primaryLabel + UUID.randomUUID();
}
}

View File

@@ -15,25 +15,40 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2572;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
/**
* @author Michael J. Simons
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Node
public class GH2572Child extends GH2572BaseEntity<GH2572Child> {
private String name;
@Relationship(value = "IS_PET", direction = Relationship.Direction.OUTGOING)
private GH2572Parent owner;
public GH2572Child(String name, GH2572Parent owner) {
this.name = name;
this.owner = owner;
}
public GH2572Child() {
}
public String getName() {
return this.name;
}
public GH2572Parent getOwner() {
return this.owner;
}
public void setName(String name) {
this.name = name;
}
public void setOwner(GH2572Parent owner) {
this.owner = owner;
}
}

View File

@@ -15,24 +15,39 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2572;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.neo4j.core.schema.Node;
/**
* @author Michael J. Simons
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Node
public class GH2572Parent extends GH2572BaseEntity<GH2572Parent> {
private String name;
private int age;
public GH2572Parent(String name, int age) {
this.name = name;
this.age = age;
}
public GH2572Parent() {
}
public String getName() {
return this.name;
}
public int getAge() {
return this.age;
}
public void setName(String name) {
this.name = name;
}
public void setAge(int age) {
this.age = age;
}
}

View File

@@ -27,17 +27,17 @@ import org.springframework.data.neo4j.repository.query.Query;
public interface GH2572Repository extends Neo4jRepository<GH2572Child, String> {
@Query("MATCH(person:GH2572Parent {id: $id}) "
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog")
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog")
List<GH2572Child> getDogsForPerson(String id);
@Query("MATCH(person:GH2572Parent {id: $id}) "
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog ORDER BY dog.name ASC LIMIT 1")
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog ORDER BY dog.name ASC LIMIT 1")
Optional<GH2572Child> findOneDogForPerson(String id);
@Query("MATCH(person:GH2572Parent {id: $id}) "
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog ORDER BY dog.name ASC LIMIT 1")
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog ORDER BY dog.name ASC LIMIT 1")
GH2572Child getOneDogForPerson(String id);
}

View File

@@ -27,12 +27,12 @@ import org.springframework.data.neo4j.repository.query.Query;
public interface ReactiveGH2572Repository extends ReactiveNeo4jRepository<GH2572Child, String> {
@Query("MATCH(person:GH2572Parent {id: $id}) "
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog")
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog")
Flux<GH2572Child> getDogsForPerson(String id);
@Query("MATCH(person:GH2572Parent {id: $id}) "
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog ORDER BY dog.name ASC LIMIT 1")
+ "OPTIONAL MATCH (person)<-[:IS_PET]-(dog:GH2572Child) "
+ "RETURN dog ORDER BY dog.name ASC LIMIT 1")
Mono<GH2572Child> findOneDogForPerson(String id);
}

View File

@@ -26,7 +26,8 @@ import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
@Node
public class College {
@Id @GeneratedValue(UUIDStringGenerator.class)
@Id
@GeneratedValue(UUIDStringGenerator.class)
private String guid;
private String name;

View File

@@ -28,18 +28,18 @@ import org.springframework.data.neo4j.repository.query.Query;
public interface CollegeRepository extends Neo4jRepository<College, String> {
@Query("""
UNWIND $0 AS row
MATCH (student:Student{guid:row.stuGuid})
MATCH (college:College{guid:row.collegeGuid})
CREATE (student)<-[:STUDENT_OF]-(college) RETURN student.guid"""
UNWIND $0 AS row
MATCH (student:Student{guid:row.stuGuid})
MATCH (college:College{guid:row.collegeGuid})
CREATE (student)<-[:STUDENT_OF]-(college) RETURN student.guid"""
)
List<String> addStudentToCollege(List<Map<String, String>> list);
@Query("""
UNWIND $0 AS row
MATCH (student:Student{guid:row.stuGuid})
MATCH (college:College{guid:row.collegeGuid})
CREATE (student)<-[:STUDENT_OF]-(college) RETURN student.guid"""
UNWIND $0 AS row
MATCH (student:Student{guid:row.stuGuid})
MATCH (college:College{guid:row.collegeGuid})
CREATE (student)<-[:STUDENT_OF]-(college) RETURN student.guid"""
)
List<String> addStudentToCollegeWorkaround(List<Value> list);
}

View File

@@ -27,7 +27,8 @@ import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
@Node
public class Student {
@Id @GeneratedValue(UUIDStringGenerator.class)
@Id
@GeneratedValue(UUIDStringGenerator.class)
private String guid;
private String name;

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2579;
import lombok.Data;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
@@ -24,7 +22,6 @@ import org.springframework.data.neo4j.core.schema.Node;
/**
* @author Michael J. Simons
*/
@Data
@Node("Column")
public class ColumnNode {
@@ -39,4 +36,110 @@ public class ColumnNode {
private String tableName;
private String name;
public ColumnNode() {
}
public Long getId() {
return this.id;
}
public String getSourceName() {
return this.sourceName;
}
public String getSchemaName() {
return this.schemaName;
}
public String getTableName() {
return this.tableName;
}
public String getName() {
return this.name;
}
public void setId(Long id) {
this.id = id;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public void setName(String name) {
this.name = name;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ColumnNode)) {
return false;
}
final ColumnNode other = (ColumnNode) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$sourceName = this.getSourceName();
final Object other$sourceName = other.getSourceName();
if (this$sourceName == null ? other$sourceName != null : !this$sourceName.equals(other$sourceName)) {
return false;
}
final Object this$schemaName = this.getSchemaName();
final Object other$schemaName = other.getSchemaName();
if (this$schemaName == null ? other$schemaName != null : !this$schemaName.equals(other$schemaName)) {
return false;
}
final Object this$tableName = this.getTableName();
final Object other$tableName = other.getTableName();
if (this$tableName == null ? other$tableName != null : !this$tableName.equals(other$tableName)) {
return false;
}
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof ColumnNode;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $sourceName = this.getSourceName();
result = result * PRIME + ($sourceName == null ? 43 : $sourceName.hashCode());
final Object $schemaName = this.getSchemaName();
result = result * PRIME + ($schemaName == null ? 43 : $schemaName.hashCode());
final Object $tableName = this.getTableName();
result = result * PRIME + ($tableName == null ? 43 : $tableName.hashCode());
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
return result;
}
public String toString() {
return "ColumnNode(id=" + this.getId() + ", sourceName=" + this.getSourceName() + ", schemaName=" + this.getSchemaName() + ", tableName=" + this.getTableName() + ", name=" + this.getName() + ")";
}
}

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2579;
import lombok.Data;
import org.springframework.data.neo4j.core.schema.RelationshipId;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.core.schema.TargetNode;
@@ -24,13 +22,73 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
/**
* @author Michael J. Simons
*/
@Data
@RelationshipProperties
public class TableAndColumnRelation {
@RelationshipId
private Long id;
@RelationshipId
private Long id;
@TargetNode
private ColumnNode columnNode;
@TargetNode
private ColumnNode columnNode;
public TableAndColumnRelation() {
}
public Long getId() {
return this.id;
}
public ColumnNode getColumnNode() {
return this.columnNode;
}
public void setId(Long id) {
this.id = id;
}
public void setColumnNode(ColumnNode columnNode) {
this.columnNode = columnNode;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TableAndColumnRelation)) {
return false;
}
final TableAndColumnRelation other = (TableAndColumnRelation) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$columnNode = this.getColumnNode();
final Object other$columnNode = other.getColumnNode();
if (this$columnNode == null ? other$columnNode != null : !this$columnNode.equals(other$columnNode)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof TableAndColumnRelation;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $columnNode = this.getColumnNode();
result = result * PRIME + ($columnNode == null ? 43 : $columnNode.hashCode());
return result;
}
public String toString() {
return "TableAndColumnRelation(id=" + this.getId() + ", columnNode=" + this.getColumnNode() + ")";
}
}

View File

@@ -15,19 +15,16 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2579;
import lombok.Data;
import java.util.List;
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;
import java.util.List;
/**
* @author Michael J. Simons
*/
@Data
@Node("Table")
public class TableNode {
@@ -45,4 +42,125 @@ public class TableNode {
@Relationship(type = "BELONG", direction = Relationship.Direction.INCOMING)
private List<TableAndColumnRelation> tableAndColumnRelation;
public TableNode() {
}
public Long getId() {
return this.id;
}
public String getSourceName() {
return this.sourceName;
}
public String getSchemaName() {
return this.schemaName;
}
public String getName() {
return this.name;
}
public String getTableComment() {
return this.tableComment;
}
public List<TableAndColumnRelation> getTableAndColumnRelation() {
return this.tableAndColumnRelation;
}
public void setId(Long id) {
this.id = id;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
public void setName(String name) {
this.name = name;
}
public void setTableComment(String tableComment) {
this.tableComment = tableComment;
}
public void setTableAndColumnRelation(List<TableAndColumnRelation> tableAndColumnRelation) {
this.tableAndColumnRelation = tableAndColumnRelation;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TableNode)) {
return false;
}
final TableNode other = (TableNode) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$sourceName = this.getSourceName();
final Object other$sourceName = other.getSourceName();
if (this$sourceName == null ? other$sourceName != null : !this$sourceName.equals(other$sourceName)) {
return false;
}
final Object this$schemaName = this.getSchemaName();
final Object other$schemaName = other.getSchemaName();
if (this$schemaName == null ? other$schemaName != null : !this$schemaName.equals(other$schemaName)) {
return false;
}
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
final Object this$tableComment = this.getTableComment();
final Object other$tableComment = other.getTableComment();
if (this$tableComment == null ? other$tableComment != null : !this$tableComment.equals(other$tableComment)) {
return false;
}
final Object this$tableAndColumnRelation = this.getTableAndColumnRelation();
final Object other$tableAndColumnRelation = other.getTableAndColumnRelation();
if (this$tableAndColumnRelation == null ? other$tableAndColumnRelation != null : !this$tableAndColumnRelation.equals(other$tableAndColumnRelation)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof TableNode;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $sourceName = this.getSourceName();
result = result * PRIME + ($sourceName == null ? 43 : $sourceName.hashCode());
final Object $schemaName = this.getSchemaName();
result = result * PRIME + ($schemaName == null ? 43 : $schemaName.hashCode());
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $tableComment = this.getTableComment();
result = result * PRIME + ($tableComment == null ? 43 : $tableComment.hashCode());
final Object $tableAndColumnRelation = this.getTableAndColumnRelation();
result = result * PRIME + ($tableAndColumnRelation == null ? 43 : $tableAndColumnRelation.hashCode());
return result;
}
public String toString() {
return "TableNode(id=" + this.getId() + ", sourceName=" + this.getSourceName() + ", schemaName=" + this.getSchemaName() + ", name=" + this.getName() + ", tableComment=" + this.getTableComment() + ", tableAndColumnRelation=" + this.getTableAndColumnRelation() + ")";
}
}

View File

@@ -27,20 +27,20 @@ import org.springframework.data.repository.query.Param;
public interface TableRepository extends Neo4jRepository<TableNode, Long> {
@Query(value = """
UNWIND :#{#froms} AS col
WITH col.__properties__ AS col, :#{#to}.__properties__ AS to
MERGE (c:Column {
sourceName: col.sourceName,
schemaName: col.schemaName,
tableName: col.tableName,
name: col.name
})
MERGE (t:Table {
sourceName: to.sourceName,
schemaName: to.schemaName,
name: to.name
})
MERGE (c) -[r:BELONG]-> (t)"""
UNWIND :#{#froms} AS col
WITH col.__properties__ AS col, :#{#to}.__properties__ AS to
MERGE (c:Column {
sourceName: col.sourceName,
schemaName: col.schemaName,
tableName: col.tableName,
name: col.name
})
MERGE (t:Table {
sourceName: to.sourceName,
schemaName: to.schemaName,
name: to.name
})
MERGE (c) -[r:BELONG]-> (t)"""
)
void mergeTableAndColumnRelations(@Param("froms") List<ColumnNode> froms, @Param("to") TableNode to);
}

View File

@@ -20,4 +20,5 @@ import org.springframework.data.neo4j.repository.Neo4jRepository;
/**
* @author Gerrit Meier
*/
public interface GH2622Repository extends Neo4jRepository<MePointingTowardsMe, Long> { }
public interface GH2622Repository extends Neo4jRepository<MePointingTowardsMe, Long> {
}

View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/
package org.springframework.data.neo4j.integration.issues.gh2622;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;

View File

@@ -27,7 +27,8 @@ import org.springframework.data.neo4j.core.schema.Node;
@Node
public class Movie {
@Id @GeneratedValue
@Id
@GeneratedValue
private UUID id;
private String title;

View File

@@ -71,11 +71,11 @@ class ReactiveConnectionAcquisitionIT {
void connectionAcquisitionAfterErrorViaSDNTxManagerShouldWork(@Autowired MovieRepository movieRepository, @Autowired Driver driver) {
UUID id = UUID.randomUUID();
Flux
.range(1, 5)
.flatMap(i -> movieRepository.findById(id).switchIfEmpty(Mono.error(new RuntimeException())))
.then()
.as(StepVerifier::create)
.verifyError();
.range(1, 5)
.flatMap(i -> movieRepository.findById(id).switchIfEmpty(Mono.error(new RuntimeException())))
.then()
.as(StepVerifier::create)
.verifyError();
try (Session session = driver.session()) {
long aNumber = session.run("RETURN 1").single().get(0).asLong();
@@ -83,25 +83,26 @@ class ReactiveConnectionAcquisitionIT {
}
}
@Test // GH-2632
@Test
// GH-2632
void connectionAcquisitionAfterErrorViaImplicitTXShouldWork(@Autowired Driver driver) {
Flux
.range(1, 5)
.flatMap(
i -> {
Query query = new Query("MATCH (p:Product) WHERE p.id = $id RETURN p.title", Collections.singletonMap("id", 0));
return Flux.usingWhen(
Mono.fromSupplier(() -> driver.session(ReactiveSession.class)),
session -> Flux.from(session.run(query))
.flatMap(result -> Flux.from(result.records()))
.map(record -> record.get(0).asString()),
session -> Mono.fromDirect(session.close())
).switchIfEmpty(Mono.error(new RuntimeException()));
}
)
.then()
.as(StepVerifier::create)
.verifyError();
.range(1, 5)
.flatMap(
i -> {
Query query = new Query("MATCH (p:Product) WHERE p.id = $id RETURN p.title", Collections.singletonMap("id", 0));
return Flux.usingWhen(
Mono.fromSupplier(() -> driver.session(ReactiveSession.class)),
session -> Flux.from(session.run(query))
.flatMap(result -> Flux.from(result.records()))
.map(record -> record.get(0).asString()),
session -> Mono.fromDirect(session.close())
).switchIfEmpty(Mono.error(new RuntimeException()));
}
)
.then()
.as(StepVerifier::create)
.verifyError();
try (Session session = driver.session()) {
long aNumber = session.run("RETURN 1").single().get(0).asLong();
@@ -112,26 +113,27 @@ class ReactiveConnectionAcquisitionIT {
record SessionAndTx(ReactiveSession session, ReactiveTransaction tx) {
}
@Test // GH-2632
@Test
// GH-2632
void connectionAcquisitionAfterErrorViaExplicitTXShouldWork(@Autowired Driver driver) {
Flux
.range(1, 5)
.flatMap(
i -> {
Mono<SessionAndTx> f = Mono
.just(driver.session(ReactiveSession.class))
.flatMap(s -> Mono.fromDirect(s.beginTransaction()).map(tx -> new SessionAndTx(s, tx)));
return Flux.usingWhen(f,
h -> Flux.from(h.tx.run("MATCH (n) WHERE false = true RETURN n")).flatMap(ReactiveResult::records),
h -> Mono.from(h.tx.commit()).then(Mono.from(h.session.close())),
(h, e) -> Mono.from(h.tx.rollback()).then(Mono.from(h.session.close())),
h -> Mono.from(h.tx.rollback()).then(Mono.from(h.session.close()))
).switchIfEmpty(Mono.error(new RuntimeException()));
}
)
.then()
.as(StepVerifier::create)
.verifyError();
.range(1, 5)
.flatMap(
i -> {
Mono<SessionAndTx> f = Mono
.just(driver.session(ReactiveSession.class))
.flatMap(s -> Mono.fromDirect(s.beginTransaction()).map(tx -> new SessionAndTx(s, tx)));
return Flux.usingWhen(f,
h -> Flux.from(h.tx.run("MATCH (n) WHERE false = true RETURN n")).flatMap(ReactiveResult::records),
h -> Mono.from(h.tx.commit()).then(Mono.from(h.session.close())),
(h, e) -> Mono.from(h.tx.rollback()).then(Mono.from(h.session.close())),
h -> Mono.from(h.tx.rollback()).then(Mono.from(h.session.close()))
).switchIfEmpty(Mono.error(new RuntimeException()));
}
)
.then()
.as(StepVerifier::create)
.verifyError();
try (Session session = driver.session()) {
long aNumber = session.run("RETURN 1").single().get(0).asLong();
@@ -147,10 +149,10 @@ class ReactiveConnectionAcquisitionIT {
@Bean
public Driver driver() {
var config = org.neo4j.driver.Config.builder()
.withMaxConnectionPoolSize(2)
.withConnectionAcquisitionTimeout(2, TimeUnit.SECONDS)
.withLeakedSessionsLogging()
.build();
.withMaxConnectionPoolSize(2)
.withConnectionAcquisitionTimeout(2, TimeUnit.SECONDS)
.withLeakedSessionsLogging()
.build();
return GraphDatabase.driver(neo4jConnectionSupport.url, neo4jConnectionSupport.authToken, config);
}
}

View File

@@ -46,7 +46,7 @@ public class Developer extends CompanyPerson {
@Override
public String toString() {
return new StringJoiner(", ", Developer.class.getSimpleName() + "[", "]")
.add("name='" + name + "'")
.add("name='" + name + "'")
.add("programmingLanguages=" + programmingLanguages)
.toString();
}

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2727;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
@@ -30,12 +25,8 @@ import java.util.List;
/**
* @author Gerrit Meier
*/
@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
@SuppressWarnings("HiddenField")
@Node("FirstLevel")
@EqualsAndHashCode(of = {"id"})
public class FirstLevelEntity {
@Id
@GeneratedValue
@@ -45,4 +36,119 @@ public class FirstLevelEntity {
@Relationship("HasSecondLevel")
private List<SecondLevelEntityRelationship> secondLevelEntityRelationshipProperties;
public FirstLevelEntity() {
}
protected FirstLevelEntity(FirstLevelEntityBuilder<?, ?> b) {
this.id = b.id;
this.name = b.name;
this.secondLevelEntityRelationshipProperties = b.secondLevelEntityRelationshipProperties;
}
public static FirstLevelEntityBuilder<?, ?> builder() {
return new FirstLevelEntityBuilderImpl();
}
public Long getId() {
return this.id;
}
public String getName() {
return this.name;
}
public List<SecondLevelEntityRelationship> getSecondLevelEntityRelationshipProperties() {
return this.secondLevelEntityRelationshipProperties;
}
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setSecondLevelEntityRelationshipProperties(List<SecondLevelEntityRelationship> secondLevelEntityRelationshipProperties) {
this.secondLevelEntityRelationshipProperties = secondLevelEntityRelationshipProperties;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof FirstLevelEntity)) {
return false;
}
final FirstLevelEntity other = (FirstLevelEntity) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof FirstLevelEntity;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
return result;
}
/**
* the builder
* @param <C> needed c type
* @param <B> needed b type
*/
public static abstract class FirstLevelEntityBuilder<C extends FirstLevelEntity, B extends FirstLevelEntityBuilder<C, B>> {
private Long id;
private String name;
private List<SecondLevelEntityRelationship> secondLevelEntityRelationshipProperties;
public B id(Long id) {
this.id = id;
return self();
}
public B name(String name) {
this.name = name;
return self();
}
public B secondLevelEntityRelationshipProperties(List<SecondLevelEntityRelationship> secondLevelEntityRelationshipProperties) {
this.secondLevelEntityRelationshipProperties = secondLevelEntityRelationshipProperties;
return self();
}
protected abstract B self();
public abstract C build();
public String toString() {
return "FirstLevelEntity.FirstLevelEntityBuilder(id=" + this.id + ", name=" + this.name + ", secondLevelEntityRelationshipProperties=" + this.secondLevelEntityRelationshipProperties + ")";
}
}
private static final class FirstLevelEntityBuilderImpl extends FirstLevelEntityBuilder<FirstLevelEntity, FirstLevelEntityBuilderImpl> {
private FirstLevelEntityBuilderImpl() {
}
protected FirstLevelEntityBuilderImpl self() {
return this;
}
public FirstLevelEntity build() {
return new FirstLevelEntity(this);
}
}
}

View File

@@ -15,10 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2727;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.RelationshipId;
@@ -29,22 +25,51 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
* @author Gerrit Meier
* @param <T> relationship properties type
*/
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@RelationshipProperties
public class OrderedRelation<T> implements Comparable<OrderedRelation<T>> {
@RelationshipId
@GeneratedValue
private Long id;
@TargetNode
private T target;
@Property
private Integer order;
@RelationshipId
@GeneratedValue
private Long id;
@TargetNode
private T target;
@Property
private Integer order;
@Override
public int compareTo(final OrderedRelation<T> o) {
return order - o.order;
}
public OrderedRelation(Long id, T target, Integer order) {
this.id = id;
this.target = target;
this.order = order;
}
public OrderedRelation() {
}
@Override
public int compareTo(final OrderedRelation<T> o) {
return order - o.order;
}
public Long getId() {
return this.id;
}
public T getTarget() {
return this.target;
}
public Integer getOrder() {
return this.order;
}
public void setId(Long id) {
this.id = id;
}
public void setTarget(T target) {
this.target = target;
}
public void setOrder(Integer order) {
this.order = order;
}
}

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2727;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
@@ -30,12 +25,8 @@ import java.util.List;
/**
* @author Gerrit Meier
*/
@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
@SuppressWarnings("HiddenField")
@Node("SecondLevel")
@EqualsAndHashCode(of = {"id"})
public class SecondLevelEntity {
@Id
@GeneratedValue
@@ -45,4 +36,119 @@ public class SecondLevelEntity {
@Relationship("HasThirdLevel")
private List<ThirdLevelEntityRelationship> thirdLevelEntityRelationshipProperties;
public SecondLevelEntity() {
}
protected SecondLevelEntity(SecondLevelEntityBuilder<?, ?> b) {
this.id = b.id;
this.someValue = b.someValue;
this.thirdLevelEntityRelationshipProperties = b.thirdLevelEntityRelationshipProperties;
}
public static SecondLevelEntityBuilder<?, ?> builder() {
return new SecondLevelEntityBuilderImpl();
}
public Long getId() {
return this.id;
}
public String getSomeValue() {
return this.someValue;
}
public List<ThirdLevelEntityRelationship> getThirdLevelEntityRelationshipProperties() {
return this.thirdLevelEntityRelationshipProperties;
}
public void setId(Long id) {
this.id = id;
}
public void setSomeValue(String someValue) {
this.someValue = someValue;
}
public void setThirdLevelEntityRelationshipProperties(List<ThirdLevelEntityRelationship> thirdLevelEntityRelationshipProperties) {
this.thirdLevelEntityRelationshipProperties = thirdLevelEntityRelationshipProperties;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof SecondLevelEntity)) {
return false;
}
final SecondLevelEntity other = (SecondLevelEntity) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof SecondLevelEntity;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
return result;
}
/**
* the builder
* @param <C> needed c type
* @param <B> needed b type
*/
public static abstract class SecondLevelEntityBuilder<C extends SecondLevelEntity, B extends SecondLevelEntityBuilder<C, B>> {
private Long id;
private String someValue;
private List<ThirdLevelEntityRelationship> thirdLevelEntityRelationshipProperties;
public B id(Long id) {
this.id = id;
return self();
}
public B someValue(String someValue) {
this.someValue = someValue;
return self();
}
public B thirdLevelEntityRelationshipProperties(List<ThirdLevelEntityRelationship> thirdLevelEntityRelationshipProperties) {
this.thirdLevelEntityRelationshipProperties = thirdLevelEntityRelationshipProperties;
return self();
}
protected abstract B self();
public abstract C build();
public String toString() {
return "SecondLevelEntity.SecondLevelEntityBuilder(id=" + this.id + ", someValue=" + this.someValue + ", thirdLevelEntityRelationshipProperties=" + this.thirdLevelEntityRelationshipProperties + ")";
}
}
private static final class SecondLevelEntityBuilderImpl extends SecondLevelEntityBuilder<SecondLevelEntity, SecondLevelEntityBuilderImpl> {
private SecondLevelEntityBuilderImpl() {
}
protected SecondLevelEntityBuilderImpl self() {
return this;
}
public SecondLevelEntity build() {
return new SecondLevelEntity(this);
}
}
}

View File

@@ -15,11 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.gh2727;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
@@ -27,16 +22,112 @@ import org.springframework.data.neo4j.core.schema.Node;
/**
* @author Gerrit Meier
*/
@SuperBuilder
@NoArgsConstructor
@Getter
@Setter
@SuppressWarnings("HiddenField")
@Node("ThirdLevel")
@EqualsAndHashCode(of = {"id"})
public class ThirdLevelEntity {
@Id
@GeneratedValue
private Long id;
private String someValue;
public ThirdLevelEntity() {
}
protected ThirdLevelEntity(ThirdLevelEntityBuilder<?, ?> b) {
this.id = b.id;
this.someValue = b.someValue;
}
public static ThirdLevelEntityBuilder<?, ?> builder() {
return new ThirdLevelEntityBuilderImpl();
}
public Long getId() {
return this.id;
}
public String getSomeValue() {
return this.someValue;
}
public void setId(Long id) {
this.id = id;
}
public void setSomeValue(String someValue) {
this.someValue = someValue;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ThirdLevelEntity)) {
return false;
}
final ThirdLevelEntity other = (ThirdLevelEntity) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof ThirdLevelEntity;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
return result;
}
/**
* the builder
* @param <C> needed c type
* @param <B> needed b type
*/
public static abstract class ThirdLevelEntityBuilder<C extends ThirdLevelEntity, B extends ThirdLevelEntityBuilder<C, B>> {
private Long id;
private String someValue;
public B id(Long id) {
this.id = id;
return self();
}
public B someValue(String someValue) {
this.someValue = someValue;
return self();
}
protected abstract B self();
public abstract C build();
public String toString() {
return "ThirdLevelEntity.ThirdLevelEntityBuilder(id=" + this.id + ", someValue=" + this.someValue + ")";
}
}
private static final class ThirdLevelEntityBuilderImpl extends ThirdLevelEntityBuilder<ThirdLevelEntity, ThirdLevelEntityBuilderImpl> {
private ThirdLevelEntityBuilderImpl() {
}
protected ThirdLevelEntityBuilderImpl self() {
return this;
}
public ThirdLevelEntity build() {
return new ThirdLevelEntity(this);
}
}
}

View File

@@ -95,7 +95,7 @@ public abstract class AbstractTestBase {
@Override
public PlatformTransactionManager transactionManager(Driver driver,
DatabaseSelectionProvider databaseNameProvider) {
DatabaseSelectionProvider databaseNameProvider) {
BookmarkCapture bookmarkCapture = bookmarkCapture();
return new Neo4jTransactionManager(driver, databaseNameProvider,
Neo4jBookmarkManager.create(bookmarkCapture));

View File

@@ -26,25 +26,26 @@ import org.springframework.data.neo4j.core.schema.Relationship;
@Node
public class TestEntityWithAssignedId1 {
@Id
private String assignedId;
@Id
private String assignedId;
@Property("value_one")
private String valueOne;
@Property("value_one")
private String valueOne;
@Relationship("related_to")
private TestEntityWithAssignedId2 relatedEntity;
@Relationship("related_to")
private TestEntityWithAssignedId2 relatedEntity;
public TestEntityWithAssignedId1(String assignedId, String valueOne, TestEntityWithAssignedId2 relatedEntity) {
this.assignedId = assignedId;
this.valueOne = valueOne;
this.relatedEntity = relatedEntity;
}
public String getAssignedId() {
return assignedId;
}
public TestEntityWithAssignedId1(String assignedId, String valueOne, TestEntityWithAssignedId2 relatedEntity) {
this.assignedId = assignedId;
this.valueOne = valueOne;
this.relatedEntity = relatedEntity;
}
public TestEntityWithAssignedId2 getRelatedEntity() {
return relatedEntity;
}
public String getAssignedId() {
return assignedId;
}
public TestEntityWithAssignedId2 getRelatedEntity() {
return relatedEntity;
}
}

View File

@@ -25,14 +25,14 @@ import org.springframework.data.neo4j.core.schema.Property;
@Node
public class TestEntityWithAssignedId2 {
@Id
private String assignedId;
@Id
private String assignedId;
@Property("valueTwo")
private String valueTwo;
@Property("valueTwo")
private String valueTwo;
public TestEntityWithAssignedId2(String assignedId, String valueTwo) {
this.assignedId = assignedId;
this.valueTwo = valueTwo;
}
public TestEntityWithAssignedId2(String assignedId, String valueTwo) {
this.assignedId = assignedId;
this.valueTwo = valueTwo;
}
}

View File

@@ -27,26 +27,27 @@ import org.springframework.data.neo4j.core.schema.Relationship;
@Node
public class TestEntityWithGeneratedDeprecatedId1 {
@Id
@GeneratedValue
private Long id;
@Id
@GeneratedValue
private Long id;
@Property("value_one")
private String valueOne;
@Property("value_one")
private String valueOne;
@Relationship("related_to")
private TestEntityWithGeneratedDeprecatedId2 relatedEntity;
@Relationship("related_to")
private TestEntityWithGeneratedDeprecatedId2 relatedEntity;
public TestEntityWithGeneratedDeprecatedId1(Long id, String valueOne, TestEntityWithGeneratedDeprecatedId2 relatedEntity) {
this.id = id;
this.valueOne = valueOne;
this.relatedEntity = relatedEntity;
}
public Long getId() {
return id;
}
public TestEntityWithGeneratedDeprecatedId1(Long id, String valueOne, TestEntityWithGeneratedDeprecatedId2 relatedEntity) {
this.id = id;
this.valueOne = valueOne;
this.relatedEntity = relatedEntity;
}
public TestEntityWithGeneratedDeprecatedId2 getRelatedEntity() {
return relatedEntity;
}
public Long getId() {
return id;
}
public TestEntityWithGeneratedDeprecatedId2 getRelatedEntity() {
return relatedEntity;
}
}

View File

@@ -26,15 +26,15 @@ import org.springframework.data.neo4j.core.schema.Property;
@Node
public class TestEntityWithGeneratedDeprecatedId2 {
@Id
@GeneratedValue
private Long id;
@Id
@GeneratedValue
private Long id;
@Property("valueTwo")
private String valueTwo;
@Property("valueTwo")
private String valueTwo;
public TestEntityWithGeneratedDeprecatedId2(Long id, String valueTwo) {
this.id = id;
this.valueTwo = valueTwo;
}
public TestEntityWithGeneratedDeprecatedId2(Long id, String valueTwo) {
this.id = id;
this.valueTwo = valueTwo;
}
}

View File

@@ -70,7 +70,8 @@ class NestedProjectionsIT {
}
}
@RepeatedTest(20) // GH-2581
@RepeatedTest(20)
// GH-2581
void excludedHopMustNotVanish(@Autowired SourceNodeARepository repository) {
Optional<SourceNodeA> optionalSourceNode = repository.findById("L-l1");

View File

@@ -15,26 +15,18 @@
*/
package org.springframework.data.neo4j.integration.issues.projections.model;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Version;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.Objects;
/**
* @author Michael J. Simons
*/
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@SuppressWarnings("HiddenField")
@Node
public class CentralNode {
@@ -42,14 +34,30 @@ public class CentralNode {
@Property(name = "id")
private String id;
@Version Long version;
@Version
Long version;
private String name;
@Relationship(value = "B_TO_CENTRAL", direction = Relationship.Direction.INCOMING)
private SourceNodeB sourceNodeB;
@Override public boolean equals(Object o) {
public CentralNode(String id, Long version, String name, SourceNodeB sourceNodeB) {
this.id = id;
this.version = version;
this.name = name;
this.sourceNodeB = sourceNodeB;
}
public CentralNode() {
}
public static CentralNodeBuilder builder() {
return new CentralNodeBuilder();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@@ -72,4 +80,61 @@ public class CentralNode {
public void setName(String name) {
this.name = name;
}
public String getId() {
return this.id;
}
public Long getVersion() {
return this.version;
}
public String getName() {
return this.name;
}
public SourceNodeB getSourceNodeB() {
return this.sourceNodeB;
}
/**
* the builder
*/
public static class CentralNodeBuilder {
private String id;
private Long version;
private String name;
private SourceNodeB sourceNodeB;
CentralNodeBuilder() {
}
public CentralNodeBuilder id(String id) {
this.id = id;
return this;
}
public CentralNodeBuilder version(Long version) {
this.version = version;
return this;
}
public CentralNodeBuilder name(String name) {
this.name = name;
return this;
}
public CentralNodeBuilder sourceNodeB(SourceNodeB sourceNodeB) {
this.sourceNodeB = sourceNodeB;
return this;
}
public CentralNode build() {
return new CentralNode(this.id, this.version, this.name, this.sourceNodeB);
}
public String toString() {
return "CentralNode.CentralNodeBuilder(id=" + this.id + ", version=" + this.version + ", name=" + this.name + ", sourceNodeB=" + this.sourceNodeB + ")";
}
}
}

View File

@@ -15,39 +15,47 @@
*/
package org.springframework.data.neo4j.integration.issues.projections.model;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Version;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.Objects;
/**
* @author Michael J. Simons
*/
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@SuppressWarnings("HiddenField")
@Node
public class SourceNodeA {
@Id
private String id;
@Version Long version;
@Version
Long version;
private String value;
@Relationship("A_TO_CENTRAL")
private CentralNode centralNode;
@Override public boolean equals(Object o) {
public SourceNodeA(String id, Long version, String value, CentralNode centralNode) {
this.id = id;
this.version = version;
this.value = value;
this.centralNode = centralNode;
}
public SourceNodeA() {
}
public static SourceNodeABuilder builder() {
return new SourceNodeABuilder();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
@@ -58,11 +66,69 @@ public class SourceNodeA {
return Objects.equals(id, sourceNodeA.id) && Objects.equals(value, sourceNodeA.value);
}
@Override public int hashCode() {
@Override
public int hashCode() {
return Objects.hash(id, value);
}
public void setValue(String value) {
this.value = value;
}
public String getId() {
return this.id;
}
public Long getVersion() {
return this.version;
}
public String getValue() {
return this.value;
}
public CentralNode getCentralNode() {
return this.centralNode;
}
/**
* the builder
*/
public static class SourceNodeABuilder {
private String id;
private Long version;
private String value;
private CentralNode centralNode;
SourceNodeABuilder() {
}
public SourceNodeABuilder id(String id) {
this.id = id;
return this;
}
public SourceNodeABuilder version(Long version) {
this.version = version;
return this;
}
public SourceNodeABuilder value(String value) {
this.value = value;
return this;
}
public SourceNodeABuilder centralNode(CentralNode centralNode) {
this.centralNode = centralNode;
return this;
}
public SourceNodeA build() {
return new SourceNodeA(this.id, this.version, this.value, this.centralNode);
}
public String toString() {
return "SourceNodeA.SourceNodeABuilder(id=" + this.id + ", version=" + this.version + ", value=" + this.value + ", centralNode=" + this.centralNode + ")";
}
}
}

View File

@@ -15,29 +15,20 @@
*/
package org.springframework.data.neo4j.integration.issues.projections.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.data.annotation.Version;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
import java.util.Objects;
/**
* @author Michael J. Simons
*/
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@SuppressWarnings("HiddenField")
@Node
public class SourceNodeB {
@@ -45,7 +36,8 @@ public class SourceNodeB {
@Property(name = "id")
private String id;
@Version Long version;
@Version
Long version;
private String name;
@@ -53,6 +45,20 @@ public class SourceNodeB {
@Relationship("B_TO_CENTRAL")
private List<CentralNode> centralNodes;
public SourceNodeB(String id, Long version, String name, List<CentralNode> centralNodes) {
this.id = id;
this.version = version;
this.name = name;
this.centralNodes = centralNodes;
}
public SourceNodeB() {
}
public static SourceNodeBBuilder builder() {
return new SourceNodeBBuilder();
}
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -69,4 +75,62 @@ public class SourceNodeB {
public int hashCode() {
return Objects.hash(id, name);
}
public String getId() {
return this.id;
}
public Long getVersion() {
return this.version;
}
public String getName() {
return this.name;
}
public List<CentralNode> getCentralNodes() {
return this.centralNodes;
}
/**
* the builder
*/
public static class SourceNodeBBuilder {
private String id;
private Long version;
private String name;
private List<CentralNode> centralNodes;
SourceNodeBBuilder() {
}
public SourceNodeBBuilder id(String id) {
this.id = id;
return this;
}
public SourceNodeBBuilder version(Long version) {
this.version = version;
return this;
}
public SourceNodeBBuilder name(String name) {
this.name = name;
return this;
}
@JsonIgnore
public SourceNodeBBuilder centralNodes(List<CentralNode> centralNodes) {
this.centralNodes = centralNodes;
return this;
}
public SourceNodeB build() {
return new SourceNodeB(this.id, this.version, this.name, this.centralNodes);
}
public String toString() {
return "SourceNodeB.SourceNodeBBuilder(id=" + this.id + ", version=" + this.version + ", name=" + this.name + ", centralNodes=" + this.centralNodes + ")";
}
}
}

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.neo4j.integration.issues.projections.repository;
import lombok.AllArgsConstructor;
import org.springframework.data.neo4j.core.Neo4jOperations;
import org.springframework.data.neo4j.integration.issues.projections.model.SourceNodeA;
import org.springframework.data.neo4j.integration.issues.projections.projection.SourceNodeAProjection;
@@ -24,13 +22,16 @@ import org.springframework.data.neo4j.integration.issues.projections.projection.
/**
* @author Michael J. Simons
*/
@AllArgsConstructor
class CustomRepositoryImpl implements CustomRepository {
private final Neo4jOperations neo4jOperations;
private final Neo4jOperations neo4jOperations;
@Override
public SourceNodeAProjection saveWithProjection(SourceNodeA sourceNodeA) {
return neo4jOperations.saveAs(sourceNodeA, SourceNodeAProjection.class);
}
CustomRepositoryImpl(Neo4jOperations neo4jOperations) {
this.neo4jOperations = neo4jOperations;
}
@Override
public SourceNodeAProjection saveWithProjection(SourceNodeA sourceNodeA) {
return neo4jOperations.saveAs(sourceNodeA, SourceNodeAProjection.class);
}
}

View File

@@ -280,7 +280,7 @@ public class ImperativeElementIdIT extends AbstractElementIdTestBase {
AND elementId(e) = $id3
RETURN count(*)""";
var count = session.run(adaptQueryTo44IfNecessary(query),
Map.of("v1", "owner", "v2", "end", "id1", owner.getId(), "id2", owner.getIntermediate().getId(), "id3", owner.getIntermediate().getEnd().getId()))
Map.of("v1", "owner", "v2", "end", "id1", owner.getId(), "id2", owner.getIntermediate().getId(), "id3", owner.getIntermediate().getEnd().getId()))
.single().get(0).asLong();
assertThat(count).isEqualTo(1L);
}
@@ -311,11 +311,11 @@ public class ImperativeElementIdIT extends AbstractElementIdTestBase {
try (var session = driver.session(bookmarkCapture.createSessionConfig())) {
var count = session.run(adaptQueryTo44IfNecessary("""
MATCH (n:NodeWithGeneratedId4 {value: $v1}) -[r:INTERMEDIATE]-> (i:Intermediate) -[:END]-> (e:NodeWithGeneratedId4 {value: $v2})
WHERE elementId(n) = $id1
AND elementId(i) = $id2
AND elementId(e) = $id3
RETURN count(*)"""),
MATCH (n:NodeWithGeneratedId4 {value: $v1}) -[r:INTERMEDIATE]-> (i:Intermediate) -[:END]-> (e:NodeWithGeneratedId4 {value: $v2})
WHERE elementId(n) = $id1
AND elementId(i) = $id2
AND elementId(e) = $id3
RETURN count(*)"""),
Map.of("v1", "owner", "v2", "end", "id1", owner.getId(), "id2", owner.getIntermediate().getId(), "id3", owner.getIntermediate().getEnd().getId()))
.single().get(0).asLong();
assertThat(count).isEqualTo(1L);

View File

@@ -15,16 +15,6 @@
*/
package org.springframework.data.neo4j.integration.properties;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.data.annotation.Version;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
@@ -36,6 +26,12 @@ import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.core.schema.TargetNode;
import org.springframework.data.neo4j.core.support.DateLong;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Michael J. Simons
* @soundtrack Metallica - Metallica
@@ -45,16 +41,23 @@ final class DomainClasses {
private DomainClasses() {
}
@Getter @Setter
abstract static class BaseClass {
private String knownProperty;
public String getKnownProperty() {
return this.knownProperty;
}
public void setKnownProperty(String knownProperty) {
this.knownProperty = knownProperty;
}
}
@Node
@Getter @Setter
static class IrrelevantSourceContainer {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
@Relationship(type = "RELATIONSHIP_PROPERTY_CONTAINER")
@@ -64,79 +67,170 @@ final class DomainClasses {
RelationshipPropertyContainer relationshipPropertyContainer) {
this.relationshipPropertyContainer = relationshipPropertyContainer;
}
public Long getId() {
return this.id;
}
public RelationshipPropertyContainer getRelationshipPropertyContainer() {
return this.relationshipPropertyContainer;
}
public void setId(Long id) {
this.id = id;
}
public void setRelationshipPropertyContainer(RelationshipPropertyContainer relationshipPropertyContainer) {
this.relationshipPropertyContainer = relationshipPropertyContainer;
}
}
@Node
@Getter @Setter
static class DynRelSourc1 {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
@Relationship
Map<String, List<RelationshipPropertyContainer>> rels = new HashMap<>();
public Long getId() {
return this.id;
}
public Map<String, List<RelationshipPropertyContainer>> getRels() {
return this.rels;
}
public void setId(Long id) {
this.id = id;
}
public void setRels(Map<String, List<RelationshipPropertyContainer>> rels) {
this.rels = rels;
}
}
@Node
@Getter @Setter
static class DynRelSourc2 {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
@Relationship
Map<String, RelationshipPropertyContainer> rels = new HashMap<>();
public Long getId() {
return this.id;
}
public Map<String, RelationshipPropertyContainer> getRels() {
return this.rels;
}
public void setId(Long id) {
this.id = id;
}
public void setRels(Map<String, RelationshipPropertyContainer> rels) {
this.rels = rels;
}
}
@Node
static class IrrelevantTargetContainer {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
}
@RelationshipProperties
@Getter @Setter
static class RelationshipPropertyContainer extends BaseClass {
private @RelationshipId Long id;
private @RelationshipId Long id;
@TargetNode
private IrrelevantTargetContainer irrelevantTargetContainer;
public Long getId() {
return this.id;
}
public IrrelevantTargetContainer getIrrelevantTargetContainer() {
return this.irrelevantTargetContainer;
}
public void setId(Long id) {
this.id = id;
}
public void setIrrelevantTargetContainer(IrrelevantTargetContainer irrelevantTargetContainer) {
this.irrelevantTargetContainer = irrelevantTargetContainer;
}
}
@Node
@Getter @Setter
static class SimpleGeneratedIDPropertyContainer extends BaseClass {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
}
@Node
@Getter @Setter
static class SimpleGeneratedIDPropertyContainerWithVersion extends SimpleGeneratedIDPropertyContainer {
@Version
private Long version;
public Long getVersion() {
return this.version;
}
public void setVersion(Long version) {
this.version = version;
}
}
@Node
@Getter @Setter
static class SimplePropertyContainer extends BaseClass {
@Id
private String id;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
}
@Node
@Getter @Setter
static class SimplePropertyContainerWithVersion extends SimplePropertyContainer {
@Version
private Long version;
public Long getVersion() {
return this.version;
}
public void setVersion(Long version) {
this.version = version;
}
}
@Node
@AllArgsConstructor
@Getter @Setter
static class WeirdSource {
@Id
@@ -146,12 +240,33 @@ final class DomainClasses {
@Relationship(type = "ITS_COMPLICATED")
IrrelevantTargetContainer irrelevantTargetContainer;
WeirdSource(Date myFineId, IrrelevantTargetContainer irrelevantTargetContainer) {
this.myFineId = myFineId;
this.irrelevantTargetContainer = irrelevantTargetContainer;
}
public Date getMyFineId() {
return this.myFineId;
}
public IrrelevantTargetContainer getIrrelevantTargetContainer() {
return this.irrelevantTargetContainer;
}
public void setMyFineId(Date myFineId) {
this.myFineId = myFineId;
}
public void setIrrelevantTargetContainer(IrrelevantTargetContainer irrelevantTargetContainer) {
this.irrelevantTargetContainer = irrelevantTargetContainer;
}
}
@Node
@Getter @Setter
static class LonelySourceContainer {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
@Relationship(type = "RELATIONSHIP_PROPERTY_CONTAINER")
@@ -174,5 +289,69 @@ final class DomainClasses {
@Relationship
Map<String, SimplePropertyContainer> dynEmptySingle = new HashMap<>();
public Long getId() {
return this.id;
}
public RelationshipPropertyContainer getSingle() {
return this.single;
}
public List<RelationshipPropertyContainer> getMultiNull() {
return this.multiNull;
}
public List<RelationshipPropertyContainer> getMultiEmpty() {
return this.multiEmpty;
}
public Map<String, List<IrrelevantTargetContainer>> getDynNullList() {
return this.dynNullList;
}
public Map<String, List<SimpleGeneratedIDPropertyContainer>> getDynEmptyList() {
return this.dynEmptyList;
}
public Map<String, SimpleGeneratedIDPropertyContainerWithVersion> getDynNullSingle() {
return this.dynNullSingle;
}
public Map<String, SimplePropertyContainer> getDynEmptySingle() {
return this.dynEmptySingle;
}
public void setId(Long id) {
this.id = id;
}
public void setSingle(RelationshipPropertyContainer single) {
this.single = single;
}
public void setMultiNull(List<RelationshipPropertyContainer> multiNull) {
this.multiNull = multiNull;
}
public void setMultiEmpty(List<RelationshipPropertyContainer> multiEmpty) {
this.multiEmpty = multiEmpty;
}
public void setDynNullList(Map<String, List<IrrelevantTargetContainer>> dynNullList) {
this.dynNullList = dynNullList;
}
public void setDynEmptyList(Map<String, List<SimpleGeneratedIDPropertyContainer>> dynEmptyList) {
this.dynEmptyList = dynEmptyList;
}
public void setDynNullSingle(Map<String, SimpleGeneratedIDPropertyContainerWithVersion> dynNullSingle) {
this.dynNullSingle = dynNullSingle;
}
public void setDynEmptySingle(Map<String, SimplePropertyContainer> dynEmptySingle) {
this.dynEmptySingle = dynEmptySingle;
}
}
}

View File

@@ -15,23 +15,6 @@
*/
package org.springframework.data.neo4j.integration.reactive;
import static org.assertj.core.api.Assertions.assertThat;
import static org.neo4j.cypherdsl.core.Cypher.parameter;
import lombok.Data;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiPredicate;
import java.util.function.Function;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -74,6 +57,21 @@ import org.springframework.data.neo4j.test.Neo4jIntegrationTest;
import org.springframework.data.neo4j.test.Neo4jReactiveTestConfiguration;
import org.springframework.transaction.ReactiveTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiPredicate;
import java.util.function.Function;
import static org.assertj.core.api.Assertions.assertThat;
import static org.neo4j.cypherdsl.core.Cypher.parameter;
/**
* @author Gerrit Meier
@@ -95,7 +93,8 @@ class ReactiveNeo4jTemplateIT {
private Long simonsId;
private Long nullNullSchneider;
@Autowired ReactiveNeo4jTemplateIT(Driver driver, ReactiveNeo4jTemplate neo4jTemplate) {
@Autowired
ReactiveNeo4jTemplateIT(Driver driver, ReactiveNeo4jTemplate neo4jTemplate) {
this.driver = driver;
this.neo4jTemplate = neo4jTemplate;
}
@@ -129,11 +128,11 @@ class ReactiveNeo4jTemplateIT {
transaction.run(
"CREATE (root:NodeEntity:BaseNodeEntity{nodeId: 'root'}) " +
"CREATE (company:NodeEntity:BaseNodeEntity{nodeId: 'comp'}) " +
"CREATE (cred:Credential{id: 'uuid-1', name: 'Creds'}) " +
"CREATE (company)-[:CHILD_OF]->(root) " +
"CREATE (root)-[:HAS_CREDENTIAL]->(cred) " +
"CREATE (company)-[:WITH_CREDENTIAL]->(cred)");
"CREATE (company:NodeEntity:BaseNodeEntity{nodeId: 'comp'}) " +
"CREATE (cred:Credential{id: 'uuid-1', name: 'Creds'}) " +
"CREATE (company)-[:CHILD_OF]->(root) " +
"CREATE (root)-[:HAS_CREDENTIAL]->(cred) " +
"CREATE (company)-[:WITH_CREDENTIAL]->(cred)");
transaction.commit();
@@ -294,7 +293,8 @@ class ReactiveNeo4jTemplateIT {
}
}
@Test // 2230
@Test
// 2230
void findAllWithStatementWithoutParameters() {
Node node = Cypher.node("PersonWithAllConstructor").named("n");
Statement statement = Cypher.match(node).where(node.property("name").isEqualTo(Cypher.parameter("name").withValue(TEST_PERSON1_NAME)))
@@ -365,20 +365,94 @@ class ReactiveNeo4jTemplateIT {
BiPredicate<PropertyPath, Neo4jPersistentProperty> predicate = (path, property) -> false;
predicate = predicate.or((path, property) -> property.getName().equals("lastName"));
predicate = predicate.or((path, property) -> property.getName().equals("address")
|| path.toDotPath().startsWith("address.") && property.getName().equals("street"));
|| path.toDotPath().startsWith("address.") && property.getName().equals("street"));
predicate = predicate.or((path, property) -> property.getName().equals("country")
|| path.toDotPath().contains("address.country.") && property.getName().equals("name"));
|| path.toDotPath().contains("address.country.") && property.getName().equals("name"));
return predicate;
}
@Data
static class DtoPersonProjection {
/** The ID is required in a project that should be saved. */
/**
* The ID is required in a project that should be saved.
*/
private final Long id;
private String lastName;
private String firstName;
DtoPersonProjection(Long id) {
this.id = id;
}
public Long getId() {
return this.id;
}
public String getLastName() {
return this.lastName;
}
public String getFirstName() {
return this.firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof DtoPersonProjection)) {
return false;
}
final DtoPersonProjection other = (DtoPersonProjection) o;
if (!other.canEqual((Object) this)) {
return false;
}
final Object this$id = this.getId();
final Object other$id = other.getId();
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
return false;
}
final Object this$lastName = this.getLastName();
final Object other$lastName = other.getLastName();
if (this$lastName == null ? other$lastName != null : !this$lastName.equals(other$lastName)) {
return false;
}
final Object this$firstName = this.getFirstName();
final Object other$firstName = other.getFirstName();
if (this$firstName == null ? other$firstName != null : !this$firstName.equals(other$firstName)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof DtoPersonProjection;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $id = this.getId();
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
final Object $lastName = this.getLastName();
result = result * PRIME + ($lastName == null ? 43 : $lastName.hashCode());
final Object $firstName = this.getFirstName();
result = result * PRIME + ($firstName == null ? 43 : $firstName.hashCode());
return result;
}
public String toString() {
return "ReactiveNeo4jTemplateIT.DtoPersonProjection(id=" + this.getId() + ", lastName=" + this.getLastName() + ", firstName=" + this.getFirstName() + ")";
}
}
@Test
@@ -386,7 +460,7 @@ class ReactiveNeo4jTemplateIT {
// Using a query on purpose so that the address is null
template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.flatMap(p -> {
p.setFirstName("Micha");
p.setLastName("Simons");
@@ -406,7 +480,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2215
@Test
// GH-2215
void saveProjectionShouldWork(@Autowired ReactiveNeo4jTemplate template) {
template
@@ -427,11 +502,12 @@ class ReactiveNeo4jTemplateIT {
.as(StepVerifier::create)
.expectNextMatches(
person -> person.getFirstName().equals("Micha") && person.getLastName().equals("Simons")
&& person.getAddress() != null)
&& person.getAddress() != null)
.verifyComplete();
}
@Test // GH-2215
@Test
// GH-2215
void saveAllProjectionShouldWork(@Autowired ReactiveNeo4jTemplate template) {
template
@@ -452,7 +528,7 @@ class ReactiveNeo4jTemplateIT {
.as(StepVerifier::create)
.expectNextMatches(
person -> person.getFirstName().equals("Micha") && person.getLastName().equals("Simons")
&& person.getAddress() != null)
&& person.getAddress() != null)
.verifyComplete();
}
@@ -461,7 +537,7 @@ class ReactiveNeo4jTemplateIT {
// Using a query on purpose so that the address is null
template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.zipWith(template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Schnitzel"), Person.class))
.flatMapMany(t -> {
@@ -497,7 +573,7 @@ class ReactiveNeo4jTemplateIT {
// Using a query on purpose so that the address is null
template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.flatMap(p -> {
p.setFirstName("Micha");
p.setLastName("Simons");
@@ -522,7 +598,7 @@ class ReactiveNeo4jTemplateIT {
// Using a query on purpose so that the address is null
template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.zipWith(template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Schnitzel"), Person.class))
.flatMapMany(t -> {
@@ -558,7 +634,7 @@ class ReactiveNeo4jTemplateIT {
// Using a query on purpose so that the address is null
template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.flatMap(p -> {
p.setFirstName("Micha");
p.setLastName("Simons");
@@ -582,7 +658,7 @@ class ReactiveNeo4jTemplateIT {
void saveAsWithClosedProjectionOnSecondLevelShouldWork(@Autowired ReactiveNeo4jTemplate template) {
template.findOne("MATCH (p:Person {lastName: $lastName})-[r:LIVES_AT]-(a:Address) RETURN p, collect(r), collect(a)",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.flatMapMany(p -> {
p.getAddress().setCity("Braunschweig");
@@ -603,7 +679,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2420
@Test
// GH-2420
void saveAsWithDynamicProjectionOnSecondLevelShouldWork(@Autowired ReactiveNeo4jTemplate template) {
template.findOne("MATCH (p:Person {lastName: $lastName})-[r:LIVES_AT]-(a:Address) RETURN p, collect(r), collect(a)",
@@ -633,7 +710,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2420
@Test
// GH-2420
void saveAllAsWithDynamicProjectionOnSecondLevelShouldWork(@Autowired ReactiveNeo4jTemplate template) {
template.findOne("MATCH (p:Person {lastName: $lastName})-[r:LIVES_AT]-(a:Address) RETURN p, collect(r), collect(a)",
@@ -667,7 +745,7 @@ class ReactiveNeo4jTemplateIT {
void saveAsWithClosedProjectionOnThreeLevelShouldWork(@Autowired ReactiveNeo4jTemplate template) {
template.findOne("MATCH (p:Person {lastName: $lastName})-[r:LIVES_AT]-(a:Address)-[r2:BASED_IN]->(c:YetAnotherCountryEntity) RETURN p, collect(r), collect(r2), collect(a), collect(c)",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.flatMapMany(p -> {
Person.Address.Country country = p.getAddress().getCountry();
@@ -689,7 +767,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2544
@Test
// GH-2544
void saveAllAsWithEmptyList(@Autowired ReactiveNeo4jTemplate template) {
template.saveAllAs(Collections.emptyList(), ClosedProjection.class)
@@ -703,7 +782,8 @@ class ReactiveNeo4jTemplateIT {
static class Y {
}
@Test // GH-2544
@Test
// GH-2544
void saveWeirdHierarchy(@Autowired ReactiveNeo4jTemplate template) {
List<Object> things = new ArrayList<>();
@@ -720,7 +800,7 @@ class ReactiveNeo4jTemplateIT {
// Using a query on purpose so that the address is null
template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Siemons"), Person.class)
Collections.singletonMap("lastName", "Siemons"), Person.class)
.zipWith(template.findOne("MATCH (p:Person {lastName: $lastName}) RETURN p",
Collections.singletonMap("lastName", "Schnitzel"), Person.class))
.flatMapMany(t -> {
@@ -785,7 +865,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2270
@Test
// GH-2270
void executableFindShouldWorkAllDomainObjectsProjectedDTOShouldWork() {
neo4jTemplate.find(Person.class).as(DtoPersonProjection.class).all()
@@ -796,7 +877,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2270
@Test
// GH-2270
void executableFindShouldWorkOneDomainObjectsProjectedDTOShouldWork() {
neo4jTemplate.find(Person.class).as(DtoPersonProjection.class)
@@ -858,8 +940,8 @@ class ReactiveNeo4jTemplateIT {
void statementShouldWork() {
Node person = Cypher.node("Person");
Flux<Person> people = neo4jTemplate.find(Person.class).matching(Cypher.match(person)
.where(person.property("lastName").isEqualTo(Cypher.anonParameter("Siemons")))
.returning(person).build())
.where(person.property("lastName").isEqualTo(Cypher.anonParameter("Siemons")))
.returning(person).build())
.all();
people.map(Person::getLastName).as(StepVerifier::create).expectNext("Siemons").verifyComplete();
}
@@ -868,13 +950,14 @@ class ReactiveNeo4jTemplateIT {
void statementWithParamsShouldWork() {
Node person = Cypher.node("Person");
Flux<Person> people = neo4jTemplate.find(Person.class).matching(Cypher.match(person)
.where(person.property("lastName").isEqualTo(Cypher.parameter("lastName", "Siemons")))
.returning(person).build(), Collections.singletonMap("lastName", "Schnitzel"))
.where(person.property("lastName").isEqualTo(Cypher.parameter("lastName", "Siemons")))
.returning(person).build(), Collections.singletonMap("lastName", "Schnitzel"))
.all();
people.map(Person::getLastName).as(StepVerifier::create).expectNext("Schnitzel").verifyComplete();
}
@Test // GH-2407
@Test
// GH-2407
void shouldSaveAllAsWithAssignedIdProjected() {
neo4jTemplate.findById("x", PersonWithAssignedId.class)
@@ -896,7 +979,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2407
@Test
// GH-2407
void shouldSaveAsWithAssignedIdProjected() {
neo4jTemplate.findById("x", PersonWithAssignedId.class)
@@ -918,7 +1002,8 @@ class ReactiveNeo4jTemplateIT {
.verifyComplete();
}
@Test // GH-2415
@Test
// GH-2415
void saveWithProjectionImplementedByEntity(@Autowired Neo4jMappingContext mappingContext) {
Neo4jPersistentEntity<?> metaData = mappingContext.getPersistentEntity(BaseNodeEntity.class);

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.neo4j.integration.shared.common;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
@@ -29,7 +27,13 @@ public abstract class AbstractPet {
@GeneratedValue
private Long id;
@Getter @Setter
private String name;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -21,12 +21,15 @@ import org.springframework.data.neo4j.core.schema.Node;
/**
* Must require ctor instantiation and must not have a builder.
*
* @author Michael J. Simons
*/
@Node
public class AllArgsCtorNoBuilder {
@Id @GeneratedValue public Long id;
@Id
@GeneratedValue
public Long id;
private boolean aBoolean;

View File

@@ -28,7 +28,9 @@ import org.springframework.data.neo4j.core.schema.Relationship;
*/
@Node
public class AltHobby {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
private String name;
@@ -41,6 +43,7 @@ public class AltHobby {
public List<AltHobby> getMemberOf() {
return memberOf;
}
public Long getId() {
return id;
}

View File

@@ -53,7 +53,7 @@ public class AltLikedByPersonRelationship {
@Override
public boolean equals(Object o) {
if (this == o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {

View File

@@ -27,7 +27,9 @@ import java.util.Objects;
@Node
public class AltPerson {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
private final String name;

View File

@@ -26,7 +26,8 @@ import org.springframework.data.neo4j.core.schema.Node;
@Node("Thing2")
public class AnotherThingWithAssignedId {
@Id private final Long theId;
@Id
private final Long theId;
private String name;

View File

@@ -59,13 +59,13 @@ public abstract class AuditingITBase {
@BeforeEach
protected void setupData() {
try (Session session = driver.session(bookmarkCapture.createSessionConfig());
Transaction transaction = session.beginTransaction()) {
Transaction transaction = session.beginTransaction()) {
transaction.run("MATCH (n) detach delete n");
idOfExistingThing = transaction.run(
"CREATE (t:ImmutableAuditableThing {name: $name, createdBy: $createdBy, createdAt: $createdAt}) RETURN id(t) as id",
Values.parameters("name", EXISTING_THING_NAME, "createdBy", EXISTING_THING_CREATED_BY, "createdAt",
EXISTING_THING_CREATED_AT))
"CREATE (t:ImmutableAuditableThing {name: $name, createdBy: $createdBy, createdAt: $createdAt}) RETURN id(t) as id",
Values.parameters("name", EXISTING_THING_NAME, "createdBy", EXISTING_THING_CREATED_BY, "createdAt",
EXISTING_THING_CREATED_AT))
.single().get("id").asLong();
transaction.run(

View File

@@ -26,14 +26,18 @@ import org.springframework.data.neo4j.core.schema.Relationship;
@Node
public class BidirectionalEnd {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
private String name;
@Relationship(type = "CONNECTED", direction = Relationship.Direction.INCOMING) private BidirectionalStart start;
@Relationship(type = "CONNECTED", direction = Relationship.Direction.INCOMING)
private BidirectionalStart start;
@Relationship(type = "ANOTHER_CONNECTION",
direction = Relationship.Direction.INCOMING) private BidirectionalStart anotherStart;
direction = Relationship.Direction.INCOMING)
private BidirectionalStart anotherStart;
public BidirectionalEnd(String name) {
this.name = name;

View File

@@ -28,11 +28,14 @@ import org.springframework.data.neo4j.core.schema.Relationship;
@Node
public class BidirectionalStart {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
private String name;
@Relationship("CONNECTED") private Set<BidirectionalEnd> ends;
@Relationship("CONNECTED")
private Set<BidirectionalEnd> ends;
public BidirectionalStart(String name, Set<BidirectionalEnd> ends) {
this.name = name;

View File

@@ -33,7 +33,8 @@ import org.springframework.data.neo4j.core.schema.Relationship;
@Node
public class Book {
@Id @GeneratedValue
@Id
@GeneratedValue
private UUID id;
private String title;

View File

@@ -25,7 +25,9 @@ import org.springframework.data.neo4j.core.schema.Node;
@Node
public class Club {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
private String name;

View File

@@ -26,13 +26,16 @@ public class DeepRelationships {
// Let's build a looped chain here:
// Type1->Type2->Type3->Type1->...
/**
* Some type
*/
@Node
public static class LoopingType1 {
public LoopingType2 nextType;
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
}
/**
@@ -41,7 +44,9 @@ public class DeepRelationships {
@Node
public static class LoopingType2 {
public LoopingType3 nextType;
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
}
/**
@@ -50,6 +55,8 @@ public class DeepRelationships {
@Node
public static class LoopingType3 {
public LoopingType1 nextType;
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
}
}

View File

@@ -15,27 +15,18 @@
*/
package org.springframework.data.neo4j.integration.shared.common;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.HashSet;
import java.util.Set;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.Property;
import org.springframework.data.neo4j.core.schema.Relationship;
import java.util.HashSet;
import java.util.Set;
/**
* @author Michael J. Simons
*/
@Data
@ToString(exclude = { "friends" })
@Node
@NoArgsConstructor
@AllArgsConstructor
public class DoritoEatingPerson {
@Id
@@ -57,6 +48,112 @@ public class DoritoEatingPerson {
this.name = name;
}
public DoritoEatingPerson(long id, String name, boolean eatsDoritos, boolean friendsAlsoEatDoritos, Set<DoritoEatingPerson> friends) {
this.id = id;
this.name = name;
this.eatsDoritos = eatsDoritos;
this.friendsAlsoEatDoritos = friendsAlsoEatDoritos;
this.friends = friends;
}
public DoritoEatingPerson() {
}
public long getId() {
return this.id;
}
public String getName() {
return this.name;
}
public boolean isEatsDoritos() {
return this.eatsDoritos;
}
public boolean isFriendsAlsoEatDoritos() {
return this.friendsAlsoEatDoritos;
}
public Set<DoritoEatingPerson> getFriends() {
return this.friends;
}
public void setId(long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setEatsDoritos(boolean eatsDoritos) {
this.eatsDoritos = eatsDoritos;
}
public void setFriendsAlsoEatDoritos(boolean friendsAlsoEatDoritos) {
this.friendsAlsoEatDoritos = friendsAlsoEatDoritos;
}
public void setFriends(Set<DoritoEatingPerson> friends) {
this.friends = friends;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof DoritoEatingPerson)) {
return false;
}
final DoritoEatingPerson other = (DoritoEatingPerson) o;
if (!other.canEqual((Object) this)) {
return false;
}
if (this.getId() != other.getId()) {
return false;
}
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
if (this.isEatsDoritos() != other.isEatsDoritos()) {
return false;
}
if (this.isFriendsAlsoEatDoritos() != other.isFriendsAlsoEatDoritos()) {
return false;
}
final Object this$friends = this.getFriends();
final Object other$friends = other.getFriends();
if (this$friends == null ? other$friends != null : !this$friends.equals(other$friends)) {
return false;
}
return true;
}
protected boolean canEqual(final Object other) {
return other instanceof DoritoEatingPerson;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final long $id = this.getId();
result = result * PRIME + (int) ($id >>> 32 ^ $id);
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
result = result * PRIME + (this.isEatsDoritos() ? 79 : 97);
result = result * PRIME + (this.isFriendsAlsoEatDoritos() ? 79 : 97);
final Object $friends = this.getFriends();
result = result * PRIME + ($friends == null ? 43 : $friends.hashCode());
return result;
}
public String toString() {
return "DoritoEatingPerson(id=" + this.getId() + ", name=" + this.getName() + ", eatsDoritos=" + this.isEatsDoritos() + ", friendsAlsoEatDoritos=" + this.isFriendsAlsoEatDoritos() + ")";
}
/**
* Projection containing ambiguous name
*/

View File

@@ -15,15 +15,72 @@
*/
package org.springframework.data.neo4j.integration.shared.common;
import lombok.Value;
/**
* @author Michael J. Simon
*/
@Value
public class DtoPersonProjection {
public final class DtoPersonProjection {
String name;
String sameValue;
String firstName;
private final String name;
private final String sameValue;
private final String firstName;
public DtoPersonProjection(String name, String sameValue, String firstName) {
this.name = name;
this.sameValue = sameValue;
this.firstName = firstName;
}
public String getName() {
return this.name;
}
public String getSameValue() {
return this.sameValue;
}
public String getFirstName() {
return this.firstName;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof DtoPersonProjection)) {
return false;
}
final DtoPersonProjection other = (DtoPersonProjection) o;
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
final Object this$sameValue = this.getSameValue();
final Object other$sameValue = other.getSameValue();
if (this$sameValue == null ? other$sameValue != null : !this$sameValue.equals(other$sameValue)) {
return false;
}
final Object this$firstName = this.getFirstName();
final Object other$firstName = other.getFirstName();
if (this$firstName == null ? other$firstName != null : !this$firstName.equals(other$firstName)) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $sameValue = this.getSameValue();
result = result * PRIME + ($sameValue == null ? 43 : $sameValue.hashCode());
final Object $firstName = this.getFirstName();
result = result * PRIME + ($firstName == null ? 43 : $firstName.hashCode());
return result;
}
public String toString() {
return "DtoPersonProjection(name=" + this.getName() + ", sameValue=" + this.getSameValue() + ", firstName=" + this.getFirstName() + ")";
}
}

View File

@@ -15,23 +15,116 @@
*/
package org.springframework.data.neo4j.integration.shared.common;
import lombok.Value;
import java.util.List;
/**
* @author Michael J. Simons
*/
@Value
public class DtoPersonProjectionContainingAdditionalFields {
public final class DtoPersonProjectionContainingAdditionalFields {
String name;
String sameValue;
String firstName;
private final String name;
private final String sameValue;
private final String firstName;
List<PersonWithAllConstructor> otherPeople;
private final List<PersonWithAllConstructor> otherPeople;
Long someLongValue;
private final Long someLongValue;
List<Double> someDoubles;
private final List<Double> someDoubles;
public DtoPersonProjectionContainingAdditionalFields(String name, String sameValue, String firstName, List<PersonWithAllConstructor> otherPeople, Long someLongValue, List<Double> someDoubles) {
this.name = name;
this.sameValue = sameValue;
this.firstName = firstName;
this.otherPeople = otherPeople;
this.someLongValue = someLongValue;
this.someDoubles = someDoubles;
}
public String getName() {
return this.name;
}
public String getSameValue() {
return this.sameValue;
}
public String getFirstName() {
return this.firstName;
}
public List<PersonWithAllConstructor> getOtherPeople() {
return this.otherPeople;
}
public Long getSomeLongValue() {
return this.someLongValue;
}
public List<Double> getSomeDoubles() {
return this.someDoubles;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof DtoPersonProjectionContainingAdditionalFields)) {
return false;
}
final DtoPersonProjectionContainingAdditionalFields other = (DtoPersonProjectionContainingAdditionalFields) o;
final Object this$name = this.getName();
final Object other$name = other.getName();
if (this$name == null ? other$name != null : !this$name.equals(other$name)) {
return false;
}
final Object this$sameValue = this.getSameValue();
final Object other$sameValue = other.getSameValue();
if (this$sameValue == null ? other$sameValue != null : !this$sameValue.equals(other$sameValue)) {
return false;
}
final Object this$firstName = this.getFirstName();
final Object other$firstName = other.getFirstName();
if (this$firstName == null ? other$firstName != null : !this$firstName.equals(other$firstName)) {
return false;
}
final Object this$otherPeople = this.getOtherPeople();
final Object other$otherPeople = other.getOtherPeople();
if (this$otherPeople == null ? other$otherPeople != null : !this$otherPeople.equals(other$otherPeople)) {
return false;
}
final Object this$someLongValue = this.getSomeLongValue();
final Object other$someLongValue = other.getSomeLongValue();
if (this$someLongValue == null ? other$someLongValue != null : !this$someLongValue.equals(other$someLongValue)) {
return false;
}
final Object this$someDoubles = this.getSomeDoubles();
final Object other$someDoubles = other.getSomeDoubles();
if (this$someDoubles == null ? other$someDoubles != null : !this$someDoubles.equals(other$someDoubles)) {
return false;
}
return true;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $name = this.getName();
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
final Object $sameValue = this.getSameValue();
result = result * PRIME + ($sameValue == null ? 43 : $sameValue.hashCode());
final Object $firstName = this.getFirstName();
result = result * PRIME + ($firstName == null ? 43 : $firstName.hashCode());
final Object $otherPeople = this.getOtherPeople();
result = result * PRIME + ($otherPeople == null ? 43 : $otherPeople.hashCode());
final Object $someLongValue = this.getSomeLongValue();
result = result * PRIME + ($someLongValue == null ? 43 : $someLongValue.hashCode());
final Object $someDoubles = this.getSomeDoubles();
result = result * PRIME + ($someDoubles == null ? 43 : $someDoubles.hashCode());
return result;
}
public String toString() {
return "DtoPersonProjectionContainingAdditionalFields(name=" + this.getName() + ", sameValue=" + this.getSameValue() + ", firstName=" + this.getFirstName() + ", otherPeople=" + this.getOtherPeople() + ", someLongValue=" + this.getSomeLongValue() + ", someDoubles=" + this.getSomeDoubles() + ")";
}
}

View File

@@ -59,15 +59,15 @@ public abstract class DynamicRelationshipsITBase<T> {
try (Session session = driver.session(); Transaction transaction = session.beginTransaction()) {
transaction.run("MATCH (n) detach delete n");
var cypher = """
CREATE (t:%s {name: 'A'}) WITH t\s
CREATE (t) - [:HAS_WIFE] -> (w:Person {firstName: 'B'})\s
CREATE (t) - [:ACTIVE{performance:'average'}] -> (:Hobby {name: 'Biking'})\s
CREATE (t) - [:FOOTBALL{place:'Brunswick'}] -> (:Club {name: 'BTSV'})\s
CREATE (t) - [:HAS_DAUGHTER] -> (d:Person {firstName: 'C'}) WITH t\s
UNWIND ['Tom', 'Garfield'] AS cat CREATE (t) - [:CATS] -> (w:Pet {name: cat})\s
WITH DISTINCT t UNWIND ['Benji', 'Lassie'] AS dog\s
CREATE (t) - [:DOGS] -> (w:Pet {name: dog}) RETURN DISTINCT id(t) as id
""".formatted(labelOfTestSubject);
CREATE (t:%s {name: 'A'}) WITH t\s
CREATE (t) - [:HAS_WIFE] -> (w:Person {firstName: 'B'})\s
CREATE (t) - [:ACTIVE{performance:'average'}] -> (:Hobby {name: 'Biking'})\s
CREATE (t) - [:FOOTBALL{place:'Brunswick'}] -> (:Club {name: 'BTSV'})\s
CREATE (t) - [:HAS_DAUGHTER] -> (d:Person {firstName: 'C'}) WITH t\s
UNWIND ['Tom', 'Garfield'] AS cat CREATE (t) - [:CATS] -> (w:Pet {name: cat})\s
WITH DISTINCT t UNWIND ['Benji', 'Lassie'] AS dog\s
CREATE (t) - [:DOGS] -> (w:Pet {name: dog}) RETURN DISTINCT id(t) as id
""".formatted(labelOfTestSubject);
idOfExistingPerson = transaction.run(cypher)
.single().get("id").asLong();
transaction.commit();

View File

@@ -27,7 +27,8 @@ import org.springframework.data.neo4j.core.schema.Relationship;
*/
@Node
public class Editor {
@Id @GeneratedValue
@Id
@GeneratedValue
private UUID id;
String name;

View File

@@ -35,7 +35,9 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class SuperNode {
@Id @GeneratedValue public Long id;
@Id
@GeneratedValue
public Long id;
public SimpleDynamicLabels relatedTo;
@@ -50,9 +52,12 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class SimpleDynamicLabels {
@Id @GeneratedValue public Long id;
@Id
@GeneratedValue
public Long id;
@DynamicLabels public Set<String> moreLabels;
@DynamicLabels
public Set<String> moreLabels;
public Long getId() {
return id;
@@ -63,7 +68,8 @@ public final class EntitiesWithDynamicLabels {
* Used for testing whether the inherited dynamic labels is populated.
*/
@Node
public static class InheritedSimpleDynamicLabels extends SimpleDynamicLabels {}
public static class InheritedSimpleDynamicLabels extends SimpleDynamicLabels {
}
/**
* Same as {@link SimpleDynamicLabels} but with an added version field.
@@ -71,11 +77,15 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class SimpleDynamicLabelsWithVersion {
@Id @GeneratedValue public Long id;
@Id
@GeneratedValue
public Long id;
@Version public Long myVersion;
@Version
public Long myVersion;
@DynamicLabels public Set<String> moreLabels;
@DynamicLabels
public Set<String> moreLabels;
public Long getId() {
return id;
@@ -88,9 +98,11 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class SimpleDynamicLabelsWithBusinessId {
@Id public String id;
@Id
public String id;
@DynamicLabels public Set<String> moreLabels;
@DynamicLabels
public Set<String> moreLabels;
public String getId() {
return id;
@@ -103,11 +115,14 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class SimpleDynamicLabelsWithBusinessIdAndVersion {
@Id public String id;
@Id
public String id;
@Version public Long myVersion;
@Version
public Long myVersion;
@DynamicLabels public Set<String> moreLabels;
@DynamicLabels
public Set<String> moreLabels;
public String getId() {
return id;
@@ -120,9 +135,12 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class SimpleDynamicLabelsCtor {
@Id @GeneratedValue private final Long id;
@Id
@GeneratedValue
private final Long id;
@DynamicLabels public final Set<String> moreLabels;
@DynamicLabels
public final Set<String> moreLabels;
public SimpleDynamicLabelsCtor(Long id, Set<String> moreLabels) {
this.id = id;
@@ -136,26 +154,34 @@ public final class EntitiesWithDynamicLabels {
@Node("Baz")
public static class DynamicLabelsWithNodeLabel {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
@DynamicLabels public Set<String> moreLabels;
@DynamicLabels
public Set<String> moreLabels;
}
/**
* Dynamic labels together with multiple labels.
*/
@Node({ "Foo", "Bar" })
@Node({"Foo", "Bar"})
public static class DynamicLabelsWithMultipleNodeLabels {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
@DynamicLabels public Set<String> moreLabels;
@DynamicLabels
public Set<String> moreLabels;
}
@Node
static abstract class DynamicLabelsBaseClass {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
}
/**
@@ -164,7 +190,8 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class ExtendedBaseClass1 extends DynamicLabelsBaseClass {
@DynamicLabels public Set<String> moreLabels;
@DynamicLabels
public Set<String> moreLabels;
}
/**
@@ -173,9 +200,11 @@ public final class EntitiesWithDynamicLabels {
@Node
public static class EntityWithCustomIdAndDynamicLabels {
@Id public String identifier;
@Id
public String identifier;
@DynamicLabels public Set<String> myLabels;
@DynamicLabels
public Set<String> myLabels;
}
/**
@@ -183,7 +212,8 @@ public final class EntitiesWithDynamicLabels {
*/
@Node
public static abstract class BaseEntityWithoutDynamicLabels {
@Id public String id;
@Id
public String id;
}
/**
@@ -191,7 +221,8 @@ public final class EntitiesWithDynamicLabels {
*/
@Node
public static abstract class AbstractBaseEntityWithDynamicLabels extends BaseEntityWithoutDynamicLabels {
@DynamicLabels public Set<String> labels;
@DynamicLabels
public Set<String> labels;
}
/**
@@ -210,5 +241,6 @@ public final class EntitiesWithDynamicLabels {
public String name;
}
private EntitiesWithDynamicLabels() {}
private EntitiesWithDynamicLabels() {
}
}

View File

@@ -24,7 +24,8 @@ import org.springframework.data.neo4j.core.schema.Node;
@Node
public class EntityWithConvertedId {
@Id private IdentifyingEnum identifyingEnum;
@Id
private IdentifyingEnum identifyingEnum;
public IdentifyingEnum getIdentifyingEnum() {
return identifyingEnum;

View File

@@ -24,7 +24,9 @@ import org.springframework.data.neo4j.core.schema.Node;
*/
@Node
public class EntityWithPrimitiveConstructorArguments {
@Id @GeneratedValue public Long id;
@Id
@GeneratedValue
public Long id;
public final boolean someBooleanValue;
public final int someIntValue;

View File

@@ -29,7 +29,9 @@ import org.springframework.data.neo4j.core.schema.TargetNode;
@Node
public class EntityWithRelationshipPropertiesPath {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
@Relationship("RelationshipA")
private RelationshipPropertyA relationshipA;
@@ -77,7 +79,9 @@ public class EntityWithRelationshipPropertiesPath {
*/
@Node
public static class EntityA {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
@Relationship("RelationshipB")
private RelationshipPropertyB relationshipB;
@@ -92,7 +96,9 @@ public class EntityWithRelationshipPropertiesPath {
*/
@Node
public static class EntityB {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
}

View File

@@ -26,7 +26,8 @@ import org.springframework.data.neo4j.core.schema.Relationship;
@Node
public class Flight {
@Id @GeneratedValue
@Id
@GeneratedValue
private Long id;
private final String name;

View File

@@ -28,11 +28,14 @@ import java.util.List;
@Node
public class Friend {
@Id @GeneratedValue private Long id;
@Id
@GeneratedValue
private Long id;
private final String name;
@Relationship("KNOWS") private List<FriendshipRelationship> friends;
@Relationship("KNOWS")
private List<FriendshipRelationship> friends;
public Friend(String name) {
this.name = name;

Some files were not shown because too many files have changed in this diff Show More