Changeset 6675


Ignore:
Timestamp:
Jan 8, 2015, 1:55:01 PM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #1903: Linking a new item to an existing AnyToAny? is not possible in a single transaction

This seems to fix the issue. However, it is important that the new item is created and saved (DbControl.save()) before the AnyToAny link is loaded, since otherwise the id lookup will happen in the incorrect order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.4-stable/src/core/net/sf/basedb/core/AnyToAny.java

    r6127 r6675  
    2828import org.hibernate.mapping.Table;
    2929
    30 import net.sf.basedb.core.Transactional.Action;
    3130import net.sf.basedb.core.data.AnyToAnyData;
    3231import net.sf.basedb.core.hibernate.TypeWrapper;
     
    5251public class AnyToAny
    5352  extends BasicItem<AnyToAnyData>
    54   implements Nameable
     53  implements Nameable, Transactional
    5554{
    5655
     
    480479  {
    481480    super.onBeforeCommit(action);
    482     if (action == Action.CREATE)
     481    if (action == Action.CREATE || action == Action.UPDATE && (getToId() == 0 || getFromId() == 0))
    483482    {
    484483      // In case either the to or from items are also new items
Note: See TracChangeset for help on using the changeset viewer.