Я начал изучать разработку REST API с использованием Spring и Neo4J. Я не могу понять, как работают репозитории, даже просматривая документацию.
У меня есть узел Airport и связь LINE. В базе данных Neo4J хранятся двусторонние линии между двумя аэропортами. Я хотел бы получить все отношения между всеми аэропортами. Как я могу это сделать? Я попробовал этот запрос. Он возвращает правильное количество экземпляров класса Line, но все атрибуты имеют значение NULL. Что я делаю не так?
Это класс AirportNode:
@Node("Airport")
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class AirportNode implements Serializable {
/**
* The unique identifier for the airport node in Neo4J.
*/
@Id
@GeneratedValue
private Long id;
/**
* The relational database ID corresponding to this airport.
* This links the Neo4j node to its counterpart in a relational database.
*/
@Property("relational_id")
private Long relationalId;
/**
* IATA code of the airport (3-letter code).
* This is a unique identifier for the airport according to the International Air Transport Association standard.
*/
@Property("code")
private String code;
@Property("name")
private String name;
@Property("country")
private String country;
@Property("zone")
private String zone;
@Property("latitude")
private Double latitude;
@Property("longitude")
private Double longitude;
/// Getters, Setters, ctors
}
Это класс Line:
@RelationshipProperties
@Getter
@Setter
public class Line {
/**
* The unique identifier for this relationship in Neo4J.
*/
@Id
@GeneratedValue
private Long id;
/**
* The destination airport that this line connects to.
*/
@TargetNode
private AirportNode destination;
@Property(name="distance")
private Double distance;
@Property(name="relational_id")
private Long relationalId;
// getters, setters, ctors
}
Это LineRepository с запросом:
public interface LineRepository extends Neo4JRepository {
@Query("""
MATCH (origin:Airport)-[r:LINE]->(destination:Airport)
WHERE id(origin) < id(destination)
RETURN r, destination
""")
List findAllLines();
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... ing-spring
Получите список отношений из репозитория Neo4J, используя Spring. ⇐ JAVA
Программисты JAVA общаются здесь
-
Anonymous
1764150332
Anonymous
Я начал изучать разработку REST API с использованием Spring и Neo4J. Я не могу понять, как работают репозитории, даже просматривая документацию.
У меня есть узел Airport и связь LINE. В базе данных Neo4J хранятся двусторонние линии между двумя аэропортами. Я хотел бы получить все отношения между всеми аэропортами. Как я могу это сделать? Я попробовал этот запрос. Он возвращает правильное количество экземпляров класса Line, но все атрибуты имеют значение NULL. Что я делаю не так?
Это класс AirportNode:
@Node("Airport")
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class AirportNode implements Serializable {
/**
* The unique identifier for the airport node in Neo4J.
*/
@Id
@GeneratedValue
private Long id;
/**
* The relational database ID corresponding to this airport.
* This links the Neo4j node to its counterpart in a relational database.
*/
@Property("relational_id")
private Long relationalId;
/**
* IATA code of the airport (3-letter code).
* This is a unique identifier for the airport according to the International Air Transport Association standard.
*/
@Property("code")
private String code;
@Property("name")
private String name;
@Property("country")
private String country;
@Property("zone")
private String zone;
@Property("latitude")
private Double latitude;
@Property("longitude")
private Double longitude;
/// Getters, Setters, ctors
}
Это класс Line:
@RelationshipProperties
@Getter
@Setter
public class Line {
/**
* The unique identifier for this relationship in Neo4J.
*/
@Id
@GeneratedValue
private Long id;
/**
* The destination airport that this line connects to.
*/
@TargetNode
private AirportNode destination;
@Property(name="distance")
private Double distance;
@Property(name="relational_id")
private Long relationalId;
// getters, setters, ctors
}
Это LineRepository с запросом:
public interface LineRepository extends Neo4JRepository {
@Query("""
MATCH (origin:Airport)-[r:LINE]->(destination:Airport)
WHERE id(origin) < id(destination)
RETURN r, destination
""")
List findAllLines();
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79827307/get-a-list-of-relationships-from-neo4j-repository-using-spring[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия