Skip to content

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

@ekravchenko

Description

@ekravchenko

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions