public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key) { if ( session.getEntityMode()==EntityMode.DOM4J ) { return new PersistentListElementHolder(session, persister, key); } else { return new PersistentList(session); } }
public PersistentCollection wrap(SessionImplementor session, Object collection) { if ( session.getEntityMode()==EntityMode.DOM4J ) { return new PersistentListElementHolder( session, (Element) collection ); } else { return new PersistentList( session, (List) collection ); } }
public void testWriteMethodDirtying() { ListOwner parent = new ListOwner( "root" ); ListOwner child = new ListOwner( "c1" ); parent.getChildren().add( child ); child.setParent( parent ); ListOwner otherChild = new ListOwner( "c2" ); Session session = openSession(); session.beginTransaction(); session.save( parent ); session.flush(); // at this point, the list on parent has now been replaced with a PersistentList... PersistentList children = ( PersistentList ) parent.getChildren(); assertFalse( children.remove( otherChild ) ); assertFalse( children.isDirty() ); ArrayList otherCollection = new ArrayList(); otherCollection.add( child ); assertFalse( children.retainAll( otherCollection ) ); assertFalse( children.isDirty() ); otherCollection = new ArrayList(); otherCollection.add( otherChild ); assertFalse( children.removeAll( otherCollection ) ); assertFalse( children.isDirty() ); children.clear(); session.delete( child ); assertTrue( children.isDirty() ); session.flush(); children.clear(); assertFalse( children.isDirty() ); session.delete( parent ); session.getTransaction().commit(); session.close(); }
/** * */ protected PortfolioRepositoryHandler() { supportedTypes = new ArrayList<String>(1); supportedTypes.add(EPTemplateMapResource.TYPE_NAME); myStream.alias("defaultMap", EPDefaultMap.class); myStream.alias("structureMap", EPStructuredMap.class); myStream.alias("templateMap", EPStructuredMapTemplate.class); myStream.alias("structure", EPStructureElement.class); myStream.alias("page", EPPage.class); myStream.alias("structureToArtefact", EPStructureToArtefactLink.class); myStream.alias("structureToStructure", EPStructureToStructureLink.class); myStream.alias("collectionRestriction", CollectRestriction.class); myStream.alias("org.olat.resource.OLATResourceImpl", OLATResourceImpl.class); myStream.alias("OLATResource", OLATResourceImpl.class); myStream.alias("org.olat.basesecurity.SecurityGroupImpl", SecurityGroupImpl.class); myStream.alias("SecurityGroupImpl", SecurityGroupImpl.class); myStream.alias("org.olat.basesecurity.SecurityGroup", SecurityGroup.class); myStream.alias("SecurityGroup", SecurityGroup.class); myStream.alias("org.olat.core.id.Persistable", Persistable.class); myStream.alias("Persistable", Persistable.class); myStream.alias("org.hibernate.proxy.HibernateProxy", HibernateProxy.class); myStream.alias("HibernateProxy", HibernateProxy.class); myStream.omitField(EPStructuredMapTemplate.class, "ownerGroup"); myStream.addDefaultImplementation(PersistentList.class, List.class); myStream.addDefaultImplementation(ArrayList.class, List.class); myStream.registerConverter(new CollectionConverter(myStream.getMapper()) { @Override public boolean canConvert(final Class type) { return PersistentList.class == type; } }); }
public void init() { collectionMap.put(PersistentBag.class, ArrayList.class); collectionMap.put(PersistentList.class, ArrayList.class); collectionMap.put(PersistentMap.class, HashMap.class); collectionMap.put(PersistentSet.class, HashSet.class); collectionMap.put(PersistentSortedMap.class, TreeMap.class); collectionMap.put(PersistentSortedSet.class, TreeSet.class); }