Inserting with OneToOne association #660
Replies: 7 comments 8 replies
-
The error was coming from my test setup. Will re-raise the question if I run into other issues. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Those two ways are equal and valid. Please give your entity definition and full stack trace.
|
Beta Was this translation helpful? Give feedback.
-
Reopening this as while my tests work because I'm using mock ids, at runtime I keep getting the error:
In my tests I'm able to pass userId in the person structure, but at runtime I won't know that id because it's generated dynamically upon insert (this rules out option 1). Also, of course, without having already saved the user I can't use option 2. I am using insert and have also tried save with INSERT_ONLY and NON_IDEMPOTENT_UPSERT. How can I update my syntax to make this work? |
Beta Was this translation helpful? Give feedback.
-
Neither Id Nor Key
Id is required, key is optional. When the id is auto generated so that the id can be missed, please configure @key for entity type and specify the keys of objects Neither id nor key means the idempotence cannot be guaranteed, so the new version throws an error (Totally refactor, delete and reimplement). However, the developer can
to get the same default behavior of old version*(Old version is designed wrong)* Please view the java doc of aggregate-root save mode |
Beta Was this translation helpful? Give feedback.
-
I will release a new version later. The is very special, it is parent association(Only upsert, never detach), not child association or middle table association After I published the new version, parent association can also be specified by VIOLENTLY_REPLACE
|
Beta Was this translation helpful? Give feedback.
-
Please try |
Beta Was this translation helpful? Give feedback.
-
Is it possible to create 2 objects in a OneToOne relationship via a single save command? I am not using a join table. For instance, when I create a User which is 1-1 with Person can I also create the person? This doesn't seem to work but perhaps my syntax is wrong.
I've tried the following:
I also tried:
user_id
is nullable in the Person table and when I try to execute either of the above options I get this error:java.lang.IllegalArgumentException: The value "USER" cannot be parsed as JSON object"
This is on version 0.8.132.
Any guidance would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions