Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-24-2020 01:03 AM
I am trying to use DTO projection, to get only selected relation by the DTO to optimize Neo4j query.
It works fine with normal fields but when I try to get insight relationship with the projected fields, it returns null.
This is my Node entity
@Node("Subscription")
data class Subscription(
@Id
val id: UUID,
@Relationship(type = "TO_PLAN", direction = OUTGOING)
val plan: SubscriptionPlan?,
@Relationship(type = "HAS_INVOICE", direction = OUTGOING)
val invoice: Invoice?,
@Relationship(type = "HAS_INSIGHT", direction = OUTGOING)
val insight: Map<Insight, SubscriptionInsightsRelationship>,
val status: SubscriptionStatuses,
val isAutoRenewal: Boolean,
val insightsLastChange: LocalDateTime?,
@CreatedDate
val createdDate: LocalDateTime?,
@LastModifiedDate
val lastModifiedDate: LocalDateTime?
)
The Map is how to set rich relationship in Neo4j⚡️RX
This is my projection DTO
data class RetrieveSubscriptionDto(
val id: UUID,
val insight: Map<Insight, SubscriptionInsightsRelationship>?,
val status: SubscriptionStatuses,
val lastModifiedDate: LocalDateTime?
)
This is the repository
interface SubscriptionRepository : ReactiveNeo4jRepository<Subscription, UUID> {
fun findAllByIdIsNotNull(): Flux<RetrieveSubscriptionDto>
}
The returned value with this projection is
{
"id": "d3a816e5-d0be-4721-b34d-346b011b9757",
"insight": null,
"status": "ACTIVE",
"lastModifiedDate": "2020-10-18T01:29:40.37691"
}
10-26-2020 07:26 AM
We recently improved the behaviour of DTO projections: https://github.com/spring-projects/spring-data-neo4j/commit/b85a5beeb6532ed0f75f50216889a0594d650341
This is no part of the Spring Data Neo4j RC 2 that you can get in a Spring Boot application version 2.4.0-M4.
Some nodes:
SDN/RX is now the official Spring Data Neo4j 6 that will get released on Wednesday (28.10).
The relationship mapping has also changed for relationship properties to be now like:
val insight: List<SubscriptionInsightsRelationship>
and within the @RelationshipProperties
class there should be a @TargetNode val insight:Insight
to point to the correct target entity.
10-26-2020 11:16 AM
If i want to try I should go with spring boot 2.4.0-M4 and spring neo4j data dependency 6.0.0RC 2?
11-03-2020 02:15 AM
Sorry for the delayed answer.
As of this writing you can use the Spring Boot 2.4.0-RC1 that already includes the GA version of SDN 6.0.
All the sessions of the conference are now available online