criteria query returns wrong number of objects for one-to-many relationships, multiplied by number of associated instances

Description

For this mapping to subclassed objects (Links)
Container_class
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@IndexColumn(base=1, name="item_position")
@JoinColumn(name="cnt_id", nullable=false)
@ForeignKey(name="cnt_inlk_fk")
public List<AbstractLink> getLinks() {
return links;
}

When only one object is created with 3 links, and then DB is queried via Criteria
cList = s.createCriteria(Container.class).list();

the result contains 3 objects, should be one.

Please see attached reprocase
mvn test
should do if repositories are set correctly

Environment

Hibernate 3.5.5 ORACLE and HSQL databases

Activity

Show:
Gail Badner
September 21, 2010, 12:16 AM

I'm not able to run your test case.

Please do the following:

Thanks,
Gail

Steve Ebersole
October 3, 2013, 4:17 PM

This is actually how queries work atm. The duplicated returns are actually all the same instance and are easily de-duped by using a HashSet

Rejected

Assignee

Unassigned

Reporter

Konstantin Ignatyev

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure