refresh causes duplicate entries

Description

I have a many to many between customer/reservation. getReservations has a cascade of REFRESH. When I execute the following code, the custoemr Bill has multiple reservations listed after the update. It looks like the collection is not being cleared before the refresh.

Customer bill = (Customer)manager.createQuery("FROM Customer c " +
"where c.firstName = 'Bill' and " +
"c.lastName='Burke'").getSingleResult();
Collection<Reservation> reservations = bill.getReservations();
for (Reservation res : reservations)
{
System.out.println("amountPaid: " + res.getAmountPaid());
}

Query query;
query = manager.createQuery("UPDATE Reservation res " +
"SET res.amountPaid = (res.amountPaid + 10) " +
"WHERE EXISTS (" +
"SELECT c FROM res.customers c " +
"where c.firstName = 'Bill' and " +
"c.lastName='Burke')");
query.executeUpdate();
manager.flush();
System.out.println("Show all amount paid for all of Bill's reservations after update:");
/*
bill = (Customer)manager.createQuery("FROM Customer c " +
"where c.firstName = 'Bill' and " +
"c.lastName='Burke'").getSingleResult();
*/
manager.refresh(bill);
reservations = bill.getReservations();
for (Reservation res : reservations)
{
System.out.println("amountPaid: " + res.getAmountPaid());
}

Attachments

1

Activity

Show:

Brett Meyer July 8, 2014 at 3:11 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Brett Meyer April 7, 2014 at 5:40 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Rejected

Details

Assignee

Reporter

Affects versions

Priority

Created January 29, 2006 at 7:56 AM
Updated July 8, 2014 at 3:11 PM
Resolved July 8, 2014 at 3:11 PM