Skip to content

Problem with <collection> mapping when parent's id is VARBINARY #125

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

Closed
ekravchenko opened this issue Jan 14, 2014 · 4 comments
Closed

Problem with <collection> mapping when parent's id is VARBINARY #125

ekravchenko opened this issue Jan 14, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@ekravchenko
Copy link

Hi guys,

Our team is trying to use MyBatis instead of Hibernate on one of our projects and we picked up an intereseting bug.

We are using legacy DB (no way we can change it's structure) and almost all primary keys are VARBINARY.

The problem that we faced is "Nested Results for Collection" will not work properly when primary key is mapped to array field (VARBINARY gets mapped to byte[] in value object)

We've created a small project with unit tests that explain problem properly. Please find it here:
https://github.com/ekravchenko/testingzone/tree/master/mybatis.collection.mapping.bug

Please consider the following example. Let's say we have PersonVO:
image

ChildVO is very simple:
image

When the following result map is applied - collection mapping works as expected.
image

We will get 3 person items with collections of child items properly populated

However when we try same query with different result map where id is mapped to byte[]:
image

The test will not pass and we will get duplicates (7 person items instead of 3)

Bug can be reproduced using version 3.2.3 and the latest SNAPSHOT as well.

Thanks,
Yevgen Kravchenko

emacarron added a commit that referenced this issue Jan 15, 2014
@emacarron
Copy link
Member

Hi! I have made a change to fix #124 without additional external dependencies. Does that solve this one?

@ghost ghost assigned emacarron Jan 15, 2014
@ekravchenko
Copy link
Author

The test CacheKeyTest.shouldTestCacheKeysWithBinaryArrays is green so I'm pretty sure fix should be fine. However I'll double check on a sample application. Will let you know

@ekravchenko
Copy link
Author

Works as expected now

@emacarron
Copy link
Member

Ok, lets close this one then. The fix will go in the next release.

Thank you for the detailed report and the testing!

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