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

Calling get on base class after building subclass instance does not work #82

Open
piotrgajow opened this issue Jan 3, 2018 · 1 comment

Comments

@piotrgajow
Copy link

Having two domain classes, when one extends the other using tablePerHierarchy mechanism produces strange results when building test data.

How to reproduce:

  1. Create base domain class Base
  2. Create domain class Subclass extending Base
  3. Inside test build instance of Subclass def instance = Subclass.build()
  4. Running Base.get(instance.id) results in null whereas it should return instance object

Workaround:

Running Base.list() or Subclass.list() before the get fixes the issue.

GitHub with reproduction:

https://github.com/piotrgajow/Sandbox/tree/grails-BuildTestDataPlugin-InheritanceIssue

All of tests from this specification pass.

Environment:

Plugin: 3.0.1
OS: Windows 10
Gradle: 3.4.1
Grails: 3.2.8
Groovy: 2.4.7
JVM: 1.8.0_131

@piotrgajow piotrgajow changed the title Building domain subclasses does not add base instance properly Calling get on base class after building subclass instance does not work Jan 4, 2018
@piotrgajow
Copy link
Author

I have also found out, that calling load or findById methods do work.

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

No branches or pull requests

1 participant