Skip to content
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

An abstract parent of a domain class is now considered as a persistent entity #639

Closed
sgaide opened this issue Feb 4, 2016 · 5 comments
Closed
Assignees
Milestone

Comments

@sgaide
Copy link

sgaide commented Feb 4, 2016

[grails 3.10, grails-datastore-core 5.0.0.RELEASE, mongodb-5.0.0.RC4]

In the case of a domain class (a) inheriting from an abstract class (b), b is now considered as a parent persistent entity in AbstractPersistentEntity.initialize() so that a is no more considered as a root so that all entities are now stored in a common collection named after b.

with [grails-datastore-core 4.0.6] an abstract parent class is not considered as a parent entity, all child classes (a and other classes inheriting from b) are root, and entities are stored in their own collection named after a (from the mapping variable collection field for example).
This is so because of the test: !Modifier.isAbstract(superClass.getModifiers()) that has been removed in 5.0.0

is this the expected behavior since grails-datastore-core 5.0.0 ?
if yes what is recommended to handle such a situation (many domains inheriting from a common abstract class and each one using its own collection).

thanks

Sebastien

@graemerocher
Copy link
Member

Move the abstract entity to src/main/groovy

@sgaide
Copy link
Author

sgaide commented Feb 4, 2016

Hi Graeme, thanks for the tip, but the abstract entity is already in src/main/groovy/[package...]/

S.

@graemerocher
Copy link
Member

hmm... I guess you can use a trait instead of an abstract class

@droggo
Copy link
Contributor

droggo commented Feb 4, 2016

Yes, we had to change abstract classes outside of domain folder to trait and it solved the problems. With abstract parent class not being in domain you may also run in other problems like id is missing in class.

@sgaide
Copy link
Author

sgaide commented Feb 5, 2016

Thanks Graeme, thanks Droggo,

it is now ok with a trait instead of an abstract class.

S.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants