New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Templates: The oneToOneJpaAnnotation should be orphanRemoval if the referenced-to object is not an aggregateRoot #175
Comments
… settings of "cascade.aggregate" and "cascade.aggregate.oneToMany" are working as expected
The test in 11bef26 shows that these settings are working as expected for referenced entities marked as non aggregate root (entities are aggregate roots by default). If you found a configuration which doesn't work as expected then please create a separate issue and attach the corresponding configuration. |
Regarding Sculptors default settings Patrik wrote the following in a forum post as an answer to Pavels suggestion to change the default for cascade for one-to-one relations from
....
So if you need a different default orphan removal strategy for one-to-one relations then specify |
Hi Tjuerge,
Do you have any idea? |
I've no clue (I'm not using JPA). But Btw. a ValueObject can't be a aggregate root, so |
Yes Tjuerge. I think it's another issue that why such a model will be mapped to "ManyToOne" and "ManyToMany" relations? Did I lose some keyword/hints in this model? BTW, what ORM framework are you using? |
Maybe this is due to the Users OneToOne (e.g. in "officialEmailAddress") and OneToMany (e.g. "privateEmailAddresses") relations to the same ValueObject (e.g. "EmailAddress"). This implies a ManyToMany relation between User and the corresponding ValueObject.
I'm using Sculptor without any O/R mapper ("jpa.provider=none"). Depending on the backend the manually implemented repositories are using MyBatis, EJB or web services / REST. |
Adopt the User model makes no sense. The model:
The Result:
|
I tried bi-directional relationships as below. It leads to a OneToMany Relationship.
Result:
|
Quotes from the chapter on collections in the Advanced Tutorial:
:
|
First of all, if I am not wrong, the property settings of "cascade.aggregate" and "cascade.aggregate.oneToMany" in the sculptor-generator.properties file doesn't take effect at all in the lastest versions of SculptorGenerator.
And then, in the DomainObjectReferenceAnnotationTmpl file, the orphanRemoval strategies for OneToOne relationships and OneToMany relationships are quite different for referenced objects which are not aggregateRoot. For OneToMany relationships, the orphanRemoval is marked true for non-aggregateRoot, But for OneToOne relationships, the orphanRemoval is marked as false by default.
I think it's better to keep their default behavior same (that is, orphanRemovel=true for non-aggregateRoot objects).
Below is the original code from DomainObjectReferenceAnnotationTmpl class:
The text was updated successfully, but these errors were encountered: