-
Notifications
You must be signed in to change notification settings - Fork 456
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
doesn't auto create index for entities that's mapped in the subpackage #1197
Comments
subpackages aren't actually a thing in java. "com.foo.bar" is a distinct entity from "com.foo" and is not nested under. As such, there's no cheap discoverability of these "nested" packages short of classpath scanning. In short, you'll have to call |
I see. perhaps a note in the docs to highlight this? it confused me because the mapping part worked, though the index didn't. |
Now, it's interesting you bring that up. Even as I was writing about how terrible it would be for performance, there was a part of me that was remembering that ... something already did that. That should probably be made consistent either way. I'll poke around and see. It's been a long time since I've been in this code. |
it was in here. I did check first to make sure mapping subpackage would worked |
+1. I knew it sounded familiar. Thanks. |
I have a class that has some Morphia index annotations. When mapped with |
@evanchooly first of all many thanks for the revival and reactivation of the project. And your intensive participation and support. We are users of morphia from the very beginning. |
This is the last issue tagged for 1.5.0. Ideally, I'll fix this tonight or at least this week and by next week at the latest we'd have a 1.5.0 published. |
@evanchooly many thx for the fast reply. Great to hear that! |
Can you test with a 1.5.0-SNAPSHOT build? I wrote a test first to show the problem before fixing it. But my test works here without any changes to Morphia. Make sure you've set |
@evanchooly I would like to support and put it into our backlog, but we will probably not be able to give feedback so quickly, because unfortunately the change will take a little longer with us. Hopefully e.g. the issue creator can support here. |
then what I might do is mark the issue as fixed and close out 1.5.0. If there's some nuance to the issue I've missed, it could always be corrected in a 1.5.1. |
Yes, I think this is a valid approach. If we then find anything during our migration to 1.5, we would report it. Which could then be included in 1.5.1 bug fix release. |
@evanchooly |
@wmacgyver oh, good! Maybe i'll hold off on the release then. I have some conference preparation I should be doing anyway. |
@wmacgyver any update? If not, I'm inclined to close out 1.5.0 and move onward. |
@evanchooly will give you an update in the next few hours |
@evanchooly sadly, it didn't work first I tested it using morphia 1.3.2, if I add map of sub package, it created indexes for them correctly. if I don't. it didn't work then I tested using dev.morphia.morphia:core:1.5.0-SNAPSHOT, with mongo driver 3.10.1 without mapping the subpackage, it does NOT create the indexes |
well, right. unless you map the subpackage, it's not going to know about the classes to create the indexes. The indexing is driven by the classes that have been mapped. |
@evanchooly no no, I take that back. it worked. I did the MapperOptions.setMapSubPackages(true); part wrong I just fixed it, and now with dev.morphia.morphia:core:1.5.0-SNAPSHOT, with mongo driver 3.10.1 even without explict mapping subpackage, the indexes still are created. so your fix worked yay! |
excellent! thanks for double checking that for me. I'll close this out and release 1.5.0 tomorrowish then. |
while morphia will map correctly for subpackage
.mapPackage("package")
it will map all the classes in package.subpackage
but any class in package.subpackage that has @indexes is not processed.
but if I add
.mapPackage("package.subpackage"
the .ensureIndexes call create the indexes for subpackage classes correctly.
The text was updated successfully, but these errors were encountered: