kaiso / relmongo

Java relationship-enabled domain model persistence framework for MongoDB
https://kaiso.github.io/relmongo
Apache License 2.0
50 stars 9 forks source link

suggestion #25

Closed Kotlin-GDE closed 6 years ago

Kotlin-GDE commented 6 years ago

hi good work,

  1. i suggest to add more attributes for collection mapping (exp : orphanRemoval, mappedBy),

  2. there is a bug problem when use bidirection relationship (exp : person -> cars , car -> own person) when persist data there an exception for rerurcive data (spring boot + jackson) because the 2 side off relationship refrences recursivly one to other (person -> list cars & car -> person -> list cars -> ......, son can resole this without loose the the reference of 2 relationship

kaiso commented 6 years ago

Hello

Thank you for submitting the issue, don't forget to star the repository if you enjoy!.

I will give you feedback of the progression on these features.

Kotlin-GDE commented 6 years ago

hi

how about if i referrence a car owner (person) so when persist data (with spring boot) i have n exception of recusisvity between cars and person (person -> list cars -> each car -> person -> list cars -> ....) it possible to not reference a person from car entity but in this case you loose the info about the owner of car from car entity, so how to resole this probleme of recursivity data between bidiection relationships

kaiso commented 6 years ago

hi

that's what I said in my comment the only solution is the mappedBy and I'm working on it

Kotlin-GDE commented 6 years ago

hi

i try to resolve this exception with @JsonView @JsonManaged @JsonBackRef but the second side of relationship is broken (exp : car has no ref for owner = person) but this not what i want

kaiso commented 6 years ago

hi

I will deliver a release candidate version soon to fix your problem. I will drop a comment here to inform you.

kaiso commented 6 years ago

Hello I delivered the version 2.2.0-RC1 The version introduces the mappedBy property to enable bidirectional associations. To use the OneToOne bidirectional mapping follow the following example:

// in person class
    @OneToOne(fetch=FetchType.EAGER)
    @JoinProperty(name = "passport")
    private Passport passport;

//in passport class 
   @OneToOne(mappedBy = "passport", fetch = FetchType.EAGER)
    private Person owner;

To use the OneToMany bidirectinal mapping follow the following example:

//in person class
    @OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinProperty(name="carsrefs")
    private List<Car> cars;

//in car class
    @ManyToOne(mappedBy="cars")
    private Person owner;

Please let me know if all works well for you, do not forget to star the repository. Feel free to submit the issues you discover. IMPORTANT! this is only a candidate version, so there are some changes until the final version is released.

Thank you

Kotlin-GDE commented 6 years ago

hi

first i try to make s demo with @OntoMany (Person)-> @ManyToOne (Car) (jdk 11 , kotlin 1.2.60, spring boot 2.0.4 + reactive mongodb driver)

@Document @TypeAlias(value = "car") data class Car(@Id var id: String? = null, var marque: String? = null, @ManyToOne(mappedBy = "cars") var owner: Person? = null) {

override fun equals(other: Any?) = if(other is Car) id == other.id else false

}

@Document @TypeAlias(value = "person") data class Person (@Id var id: String? = null, var name: String? = null, var age: Int? = null, @JsonFormat(pattern = "dd/MM/yyyy", shape = JsonFormat.Shape.STRING) var dateNais: LocalDate? = null, @JsonProperty("cars") @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) var cars: MutableList? = null) {

override fun equals(other: Any?) = if(other is Person) id == other.id else false

}

@SpringBootApplication @EnableRelationalMongo class DemoApplication(val personRepository: PersonRepository, val carRepository: CarRepository) : ApplicationRunner { override fun run(args: ApplicationArguments?) { val person = Person().apply { id = "person-1" age = 36 name = "halim" this.dateNais = LocalDate.of(1982,3,18) }

    val car = Car().apply {
        owner = person
        id = "car-1"
        marque = "oodi-7"
    }

    person.cars?.add(car)

    personRepository.save(person).log().subscribe()
    //carRepository.save(car).log().subscribe()
}

}

execute with exception stack trace :

. _ _ /\ / '_ () \ \ \ \ ( ( )\ | ' | '| | ' \/ ` | \ \ \ \ \/ _)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========|_|==============|__/=//// :: Spring Boot :: (v2.0.4.RELEASE)

2018-08-17 14:47:37.228 INFO 7328 --- [ main] c.s.mongodb.demo.demo.DemoApplicationKt : Starting DemoApplicationKt on GHOST with PID 7328 (C:\Users\Halim\Desktop\demo\target\classes started by Halim in C:\Users\Halim\Desktop\demo) 2018-08-17 14:47:37.249 INFO 7328 --- [ main] c.s.mongodb.demo.demo.DemoApplicationKt : No active profile set, falling back to default profiles: default 2018-08-17 14:47:37.342 INFO 7328 --- [ main] onfigReactiveWebServerApplicationContext : Refreshing org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@632ceb35: startup date [Fri Aug 17 14:47:37 CEST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/Halim/.m2/repository/org/springframework/spring-core/5.0.8.RELEASE/spring-core-5.0.8.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-08-17 14:47:39.051 INFO 7328 --- [ main] o.s.w.r.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/] onto handler of type [class org.springframework.web.reactive.resource.ResourceWebHandler] 2018-08-17 14:47:39.051 INFO 7328 --- [ main] o.s.w.r.handler.SimpleUrlHandlerMapping : Mapped URL path [/] onto handler of type [class org.springframework.web.reactive.resource.ResourceWebHandler] 2018-08-17 14:47:39.155 INFO 7328 --- [ main] o.s.w.r.r.m.a.ControllerMethodResolver : Looking for @ControllerAdvice: org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@632ceb35: startup date [Fri Aug 17 14:47:37 CEST 2018]; root of context hierarchy 2018-08-17 14:47:39.502 INFO 7328 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:6666], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} 2018-08-17 14:47:39.503 INFO 7328 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:6666 to client view of cluster 2018-08-17 14:47:39.720 INFO 7328 --- [-localhost:6666] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:27}] to localhost:6666 2018-08-17 14:47:39.725 INFO 7328 --- [-localhost:6666] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:6666, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 1]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=4049398} 2018-08-17 14:47:39.727 INFO 7328 --- [-localhost:6666] org.mongodb.driver.cluster : Discovered cluster type of STANDALONE 2018-08-17 14:47:39.742 INFO 7328 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:6666], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} 2018-08-17 14:47:39.742 INFO 7328 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:6666 to client view of cluster 2018-08-17 14:47:39.752 INFO 7328 --- [-localhost:6666] org.mongodb.driver.connection : Opened connection [connectionId{localValue:2, serverValue:28}] to localhost:6666 2018-08-17 14:47:39.753 INFO 7328 --- [-localhost:6666] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:6666, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 1]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=689134} 2018-08-17 14:47:39.753 INFO 7328 --- [-localhost:6666] org.mongodb.driver.cluster : Discovered cluster type of STANDALONE 2018-08-17 14:47:39.917 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 14:47:39.919 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'owner' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 14:47:39.919 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 14:47:39.919 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'cars' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 14:47:40.010 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 14:47:40.011 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'owner' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 14:47:40.011 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 14:47:40.011 INFO 7328 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'cars' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 14:47:40.186 INFO 7328 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2018-08-17 14:47:40.227 INFO 7328 --- [ctor-http-nio-1] r.ipc.netty.tcp.BlockingNettyContext : Started HttpServer on /0:0:0:0:0:0:0:0:8888 2018-08-17 14:47:40.227 INFO 7328 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 8888 2018-08-17 14:47:40.232 INFO 7328 --- [ main] c.s.mongodb.demo.demo.DemoApplicationKt : Started DemoApplicationKt in 3.363 seconds (JVM running for 4.53) 2018-08-17 14:47:40.271 INFO 7328 --- [ main] reactor.Mono.Defer.1 : onSubscribe([Fuseable] Operators.EmptySubscription) 2018-08-17 14:47:40.271 INFO 7328 --- [ main] reactor.Mono.Defer.1 : request(unbounded) 2018-08-17 14:47:40.272 ERROR 7328 --- [ main] reactor.Mono.Defer.1 : onError(io.github.kaiso.relmongo.exception.RelMongoConfigurationException: Missing or misconfigured @JoinProperty annotation on Field cars from Class class com.spring.mongodb.demo.demo.entity.Person) 2018-08-17 14:47:40.274 ERROR 7328 --- [ main] reactor.Mono.Defer.1 :

io.github.kaiso.relmongo.exception.RelMongoConfigurationException: Missing or misconfigured @JoinProperty annotation on Field cars from Class class com.spring.mongodb.demo.demo.entity.Person at io.github.kaiso.relmongo.util.AnnotationsUtils.getJoinProperty(AnnotationsUtils.java:45) ~[relmongo-2.2.0-RC1.jar:na] at io.github.kaiso.relmongo.events.callback.PersistentPropertySavingCallback.saveAssociation(PersistentPropertySavingCallback.java:64) ~[relmongo-2.2.0-RC1.jar:na] at io.github.kaiso.relmongo.events.callback.PersistentPropertySavingCallback.doWith(PersistentPropertySavingCallback.java:55) ~[relmongo-2.2.0-RC1.jar:na] at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:729) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:708) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE] at io.github.kaiso.relmongo.events.processor.RelMongoProcessor.onBeforeSave(RelMongoProcessor.java:65) ~[relmongo-2.2.0-RC1.jar:na] at org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener.onApplicationEvent(AbstractMongoEventListener.java:89) ~[spring-data-mongodb-2.0.9.RELEASE.jar:2.0.9.RELEASE] at org.springframework.data.mongodb.core.mapping.event.AbstractMongoEventListener.onApplicationEvent(AbstractMongoEventListener.java:31) ~[spring-data-mongodb-2.0.9.RELEASE.jar:2.0.9.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE] at org.springframework.data.mongodb.core.ReactiveMongoTemplate.maybeEmitEvent(ReactiveMongoTemplate.java:2009) ~[spring-data-mongodb-2.0.9.RELEASE.jar:2.0.9.RELEASE] at org.springframework.data.mongodb.core.ReactiveMongoTemplate.lambda$doInsert$21(ReactiveMongoTemplate.java:995) ~[spring-data-mongodb-2.0.9.RELEASE.jar:2.0.9.RELEASE] at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:45) ~[reactor-core-3.1.8.RELEASE.jar:3.1.8.RELEASE] at reactor.core.publisher.MonoLog.subscribe(MonoLog.java:51) ~[reactor-core-3.1.8.RELEASE.jar:3.1.8.RELEASE] at reactor.core.publisher.Mono.subscribe(Mono.java:3080) ~[reactor-core-3.1.8.RELEASE.jar:3.1.8.RELEASE] at reactor.core.publisher.Mono.subscribeWith(Mono.java:3188) ~[reactor-core-3.1.8.RELEASE.jar:3.1.8.RELEASE] at reactor.core.publisher.Mono.subscribe(Mono.java:2965) ~[reactor-core-3.1.8.RELEASE.jar:3.1.8.RELEASE] at com.spring.mongodb.demo.demo.DemoApplication.run(DemoApplication.kt:33) ~[classes/:na] at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:791) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:781) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE] at com.spring.mongodb.demo.demo.DemoApplicationKt.main(DemoApplication.kt:42) ~[classes/:na]

Kotlin-GDE commented 6 years ago

with 2 senarion (decomment the seccond line and comment the first) . _ _ /\ / '_ () \ \ \ \ ( ( )\ | ' | '| | ' \/ ` | \ \ \ \ \/ _)| |)| | | | | || (| | ) ) ) ) ' |__| .|| ||| |\, | / / / / =========|_|==============|__/=//// :: Spring Boot :: (v2.0.4.RELEASE)

2018-08-17 15:03:53.242 INFO 7472 --- [ main] c.s.mongodb.demo.demo.DemoApplicationKt : Starting DemoApplicationKt on GHOST with PID 7472 (C:\Users\Halim\Desktop\demo\target\classes started by Halim in C:\Users\Halim\Desktop\demo) 2018-08-17 15:03:53.247 INFO 7472 --- [ main] c.s.mongodb.demo.demo.DemoApplicationKt : No active profile set, falling back to default profiles: default 2018-08-17 15:03:53.329 INFO 7472 --- [ main] onfigReactiveWebServerApplicationContext : Refreshing org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@14fc1f0: startup date [Fri Aug 17 15:03:53 CEST 2018]; root of context hierarchy WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/Halim/.m2/repository/org/springframework/spring-core/5.0.8.RELEASE/spring-core-5.0.8.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2018-08-17 15:03:54.936 INFO 7472 --- [ main] o.s.w.r.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/] onto handler of type [class org.springframework.web.reactive.resource.ResourceWebHandler] 2018-08-17 15:03:54.936 INFO 7472 --- [ main] o.s.w.r.handler.SimpleUrlHandlerMapping : Mapped URL path [/] onto handler of type [class org.springframework.web.reactive.resource.ResourceWebHandler] 2018-08-17 15:03:55.079 INFO 7472 --- [ main] o.s.w.r.r.m.a.ControllerMethodResolver : Looking for @ControllerAdvice: org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext@14fc1f0: startup date [Fri Aug 17 15:03:53 CEST 2018]; root of context hierarchy 2018-08-17 15:03:55.424 INFO 7472 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:6666], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} 2018-08-17 15:03:55.425 INFO 7472 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:6666 to client view of cluster 2018-08-17 15:03:55.575 INFO 7472 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:6666], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} 2018-08-17 15:03:55.575 INFO 7472 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:6666 to client view of cluster 2018-08-17 15:03:55.596 INFO 7472 --- [-localhost:6666] org.mongodb.driver.connection : Opened connection [connectionId{localValue:2, serverValue:29}] to localhost:6666 2018-08-17 15:03:55.600 INFO 7472 --- [-localhost:6666] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:6666, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 1]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=2386311} 2018-08-17 15:03:55.605 INFO 7472 --- [-localhost:6666] org.mongodb.driver.cluster : Discovered cluster type of STANDALONE 2018-08-17 15:03:55.642 INFO 7472 --- [-localhost:6666] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:30}] to localhost:6666 2018-08-17 15:03:55.643 INFO 7472 --- [-localhost:6666] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:6666, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 1]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1506199} 2018-08-17 15:03:55.644 INFO 7472 --- [-localhost:6666] org.mongodb.driver.cluster : Discovered cluster type of STANDALONE 2018-08-17 15:03:55.780 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 15:03:55.782 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'cars' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 15:03:55.782 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 15:03:55.782 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'owner' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 15:03:55.859 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 15:03:55.860 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'cars' in type 'Person' for path 'owner -> cars -> owner' 2018-08-17 15:03:55.860 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field '_id' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 15:03:55.861 INFO 7472 --- [ main] m.c.i.MongoPersistentEntityIndexResolver : Found cycle for field 'owner' in type 'Car' for path 'cars -> owner -> cars' 2018-08-17 15:03:56.031 INFO 7472 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2018-08-17 15:03:56.090 INFO 7472 --- [ctor-http-nio-1] r.ipc.netty.tcp.BlockingNettyContext : Started HttpServer on /0:0:0:0:0:0:0:0:8888 2018-08-17 15:03:56.090 INFO 7472 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 8888 2018-08-17 15:03:56.094 INFO 7472 --- [ main] c.s.mongodb.demo.demo.DemoApplicationKt : Started DemoApplicationKt in 3.241 seconds (JVM running for 4.142) 2018-08-17 15:03:56.142 INFO 7472 --- [ main] reactor.Mono.OnErrorResume.1 : onSubscribe(FluxOnErrorResume.ResumeSubscriber) 2018-08-17 15:03:56.142 INFO 7472 --- [ main] reactor.Mono.OnErrorResume.1 : request(unbounded) 2018-08-17 15:03:56.173 INFO 7472 --- [ntLoopGroup-2-2] org.mongodb.driver.connection : Opened connection [connectionId{localValue:3, serverValue:31}] to localhost:6666 2018-08-17 15:03:56.186 INFO 7472 --- [ntLoopGroup-2-2] reactor.Mono.OnErrorResume.1 : onNext(Car(id=car-1, marque=oodi-7, owner=Person(id=person-1, name=halim, age=36, dateNais=1982-03-18, cars=null))) 2018-08-17 15:03:56.186 INFO 7472 --- [ntLoopGroup-2-2] reactor.Mono.OnErrorResume.1 : onComplete()

so the car instance its saved with success, person instance not saved (car have no cascade to save person instance) also person collection not created

Kotlin-GDE commented 6 years ago

well i tested the @OneToOne -> @OneToOne and i send a report i expected to my report i clear.

good luck.

kaiso commented 6 years ago

Hi

The exception is clear if you look at the stack trace : ˋˋˋjava io.github.kaiso.relmongo.exception.RelMongoConfigurationException: Missing or misconfigured @JoinProperty annotation on Field cars from Class class com.spring.mongodb.demo.demo.entity.Person at io.github.kaiso.relmongo.util.AnnotationsUtils.getJoinProperty(AnnotationsUtils.java:45) ~[relmongo-2.2.0-RC1.jar:na]ˋˋˋ

you are missing the @JoinProperty (and not JsonPropery)

good luck

Kotlin-GDE commented 6 years ago

hi

sory you are right i make this demo quickly so in not see what i code

  1. person collection persist but there no persist of cascade for cars documents (if i use personRepositoty.save(person)

  2. i i use carRepositoty.save(car) -> car persist with owner (person) success but person list cars still empty in person document (no reference for cars)

sans titre

kaiso commented 6 years ago

Hi

you followed exactly what was mentionned in the wiki to do cascading ? normally if you do so, when you persist a person, the cars are persisted automatically by RelMongo. try to follow exactly the usage in the wiki and if you have an issue please open a dedicated issue and close this one because it is not the same issue.