1 24 package org.riotfamily.riot.hibernate.dao; 25 26 import java.util.List ; 27 28 import org.riotfamily.riot.dao.ListParams; 29 import org.riotfamily.riot.dao.SwappableItemDao; 30 31 public class HqlIndexedListDao extends HqlCollectionDao 32 implements SwappableItemDao { 33 34 public void swapEntity(Object entity, Object parent, 35 ListParams params, int swapWith) { 36 37 List items = listInternal(parent, params); 38 Object nextItem = items.get(swapWith); 39 40 List list = (List ) getCollection(parent); 41 list.remove(entity); 42 int pos = list.indexOf(nextItem); 43 list.add(pos, entity); 44 45 getSession().update(parent); 46 } 47 } 48 | Popular Tags |