Neo4J: Cyclic OneToMany adds an incorrect ManyToOne
See original GitHub issueOverview of the issue
Neo4J generation Cyclic Relationship to entity itself results in second, incorrect property.
Motivation for or Use Case
I want a Person to have friends as a collection of type Person.
Reproduce the error
entity Person {
name: String
}
relationship OneToMany {
Person{friends} to Person
}
Generate application based on this. Generated domain class:
@Node
public class Person implements Serializable {
// correct:
@Relationship
private Set<Person> friends = new HashSet<>();
// incorrect:
@Relationship("person")
@JsonIgnoreProperties("friends")
private Person person;
}
Also, some additional code is generated based on this, including CRUD in the front end.
Related issues
This similar issue was related to React, and Neo4J was not used back then: https://github.com/jhipster/generator-jhipster/issues/11549
Suggest a Fix
Do not generate the reverse relationship in a OneToMany to type itself for Neo4J.
JHipster Version(s)
6.8.0
JHipster configuration
{ “generator-jhipster”: { “promptValues”: { “packageName”: “com.blabla”, “nativeLanguage”: “en” }, “jhipsterVersion”: “6.8.0”, “applicationType”: “monolith”, “baseName”: “blabla”, “packageName”: “com.blabla”, “packageFolder”: “com/blabla”, “serverPort”: “8080”, “authenticationType”: “jwt”, “cacheProvider”: “ehcache”, “enableHibernateCache”: false, “websocket”: false, “databaseType”: “neo4j”, “devDatabaseType”: “neo4j”, “prodDatabaseType”: “neo4j”, “searchEngine”: false, “messageBroker”: false, “serviceDiscoveryType”: false, “buildTool”: “maven”, “enableSwaggerCodegen”: false, “jwtSecretKey”: “”, “embeddableLaunchScript”: false, “useSass”: true, “clientPackageManager”: “npm”, “clientFramework”: “angularX”, “clientTheme”: “minty”, “clientThemeVariant”: “primary”, “creationTimestamp”: 1588343391509, “testFrameworks”: [“cucumber”], “jhiPrefix”: “jhi”, “entitySuffix”: “”, “dtoSuffix”: “DTO”, “otherModules”: [], “enableTranslation”: true, “nativeLanguage”: “en”, “languages”: [“en”], “blueprints”: [], “herokuAppName”: “blabla”, “herokuDeployType”: “jar” } }
If you have a JDL please wrap it in below structure
JDL definitions
JDL content here
Entity configuration(s) entityName.json
files generated in the .jhipster
directory
Here, Person is called Trainer. I think I already see the problem. There is a ManyToOne after the OneToMany that should probably go. I checked, and it is not in the jhipster-jdl.jh
{ “name”: “Trainer”, “fields”: [ { “fieldName”: “name”, “fieldType”: “String” }, { “fieldName”: “code”, “fieldType”: “Long” }, { “fieldName”: “level”, “fieldType”: “Integer” }, { “fieldName”: “xp”, “fieldType”: “Integer” }, { “fieldName”: “team”, “fieldType”: “Team”, “fieldValues”: “VALOR,MYSTIC,INSTINCT” } ], “relationships”: [ { “relationshipType”: “one-to-many”, “otherEntityName”: “trainer”, “otherEntityRelationshipName”: “trainer”, “relationshipName”: “friends” }, { “relationshipType”: “many-to-one”, “otherEntityName”: “trainer”, “otherEntityRelationshipName”: “friends”, “relationshipName”: “trainer”, “otherEntityField”: “id” } ], “changelogDate”: “20200502070200”, “entityTableName”: “trainer”, “dto”: “no”, “pagination”: “no”, “service”: “serviceImpl”, “jpaMetamodelFiltering”: false, “fluentMethods”: true, “readOnly”: false, “embedded”: false, “clientRootFolder”: “”, “applications”: “*” }
Browsers and Operating System
Linux Mint 19
- Checking this box is mandatory (this is just to show you read everything)
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
Top GitHub Comments
Does it cause any problems except for neo4j? If not let’s just do it for neo
@atomfrede should we disable the automatic conversion to a bidirectional one-to-many relationship only if the DB type is Neo4j? Or also if the source & destination entities are the same?