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

mapPackage() does not work with subpackages #898

Closed
ulrichcech opened this issue Feb 22, 2016 · 5 comments
Closed

mapPackage() does not work with subpackages #898

ulrichcech opened this issue Feb 22, 2016 · 5 comments
Labels
Milestone

Comments

@ulrichcech
Copy link
Contributor

Hi all,

I don't want to map every single Entity-class only to have the indexes created correctly (at the moment, if you don't map a class explicitly, the application works, but no index is created other then the index on "_id").
What I want to have is the folloing:

morphia.getMapper().getOptions().setMapSubPackages(true);
morphia.mapPackage("<basicPackageName>", true);

I think, that the method "ReflectionUtils.isSubPackage()" has a problem, because the comparison would work, but currently, there is added a period to the parentPackgeName, so the equals()-method will fail (without the period, everything would work fine)...

Or do I oversee something here?

Thanks in advance,
Ulrich

@evanchooly
Copy link
Member

Are you saying the subpackages aren't getting mapped properly? The tests are all green at the moment.

@ulrichcech
Copy link
Contributor Author

< The tests are all green at the moment>
:-) Yes, because the test does not check for a class in a subpackage. The resulting set only contains classes from the parent "org.junit".
For example: org/junit/rules results in "false" in the method "isSubPackage()" with "org/junit" as parent, but you see, that it should result in "true".

private static boolean isSubPackage(final String fullPackageName, final String parentPackageName) {
        return fullPackageName.startsWith(parentPackageName + ".");
}

The period at the end breaks the "startWith()".

@ulrichcech ulrichcech changed the title mapPackage() does not work with subpackes mapPackage() does not work with subpackages Feb 22, 2016
@evanchooly
Copy link
Member

Got it. I'll take another look at the test then. Thanks.

@ulrichcech
Copy link
Contributor Author

I provided a pull-request for this issue. Perhaps, you can take a look at that.

@evanchooly evanchooly added the bug label Feb 23, 2016
@evanchooly evanchooly added this to the 1.2.0 milestone Feb 23, 2016
@evanchooly
Copy link
Member

Looks good. Thanks for the patch.

fixed 04c9a0c

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

No branches or pull requests

2 participants