Вы можете добавить автоматически сгенерированное свойство id
к сущности MongoDB, а также к сущности Neo4j, сохранить id
в объекте, который будет связан, соответственно, с другой сущностью и загрузить объект через библиотеку отображения графов объектов (neo4j).-огм) сохраненным id
при необходимости.
1.Часть MongoDB (версия Java)
1.1 YourMongoEntity
@Document
public class YourMongoEntity {
@Id
private String id;
@Indexed(unique = true)
private String furtherIdentifier;
// For reasons of clarity the default constructor, getter and setter are omitted.
}
1.2 YourMongoEntityDAO
@Repository
public interface YourMongoEntityDAO extends MongoRepository<YourMongoEntity, String> {
YourMongoEntity findById(String id);
}
2.Часть Neo4j (версия Java)
2.1 YourNeo4jEntity
@NodeEntity
public class YourNeo4jEntity {
@Id
@GeneratedValue
private Long id;
@Index(unique = true)
private Long furtherIdentifier;
// For reasons of clarity the default constructor, getter and setter are omitted.
}
2.2 YourNeo4jEntityDAO
@Repository
public interface YourNeo4jEntityDAO extends Neo4jRepository<YourNeo4jEntity, Long> {
YourNeo4jEntity findId(Long id);
}