protected Object getAnything() { return IdentityMap.instantiate( 10 ); }
/** * Workaround for a JDK 1.4.1 bug where <tt>IdentityHashMap</tt>s are not * correctly deserialized. * * @param o * @return Map */ public static Map deserialize(Object o) { return new IdentityMap( (Map) o ); }
/** * Return the map entries (as instances of <tt>Map.Entry</tt> in a collection that * is safe from concurrent modification). ie. we may safely add new instances to * the underlying <tt>Map</tt> during iteration of the <tt>entries()</tt>. * * @param map * @return Collection */ public static Map.Entry[] concurrentEntries(Map map) { return ( (IdentityMap) map ).entryArray(); }
/** * Constructs a PersistentContext, bound to the given session. * * @param session The session "owning" this context. */ public StatefulPersistenceContext(SessionImplementor session) { this.session = session; entitiesByKey = new HashMap( INIT_COLL_SIZE ); entitiesByUniqueKey = new HashMap( INIT_COLL_SIZE ); proxiesByKey = new ReferenceMap( ReferenceMap.HARD, ReferenceMap.WEAK ); entitySnapshotsByKey = new HashMap( INIT_COLL_SIZE ); entityEntries = IdentityMap.instantiateSequenced( INIT_COLL_SIZE ); collectionEntries = IdentityMap.instantiateSequenced( INIT_COLL_SIZE ); collectionsByKey = new HashMap( INIT_COLL_SIZE ); arrayHolders = IdentityMap.instantiate( INIT_COLL_SIZE ); nullifiableEntityKeys = new HashSet(); initTransientState(); }
public static Iterator keyIterator(Map map) { return ( (IdentityMap) map ).keyIterator(); }
/** * Initialize the flags of the CollectionEntry, including the * dirty check. */ private void prepareCollectionFlushes(SessionImplementor session) throws HibernateException { // Initialize dirty flags for arrays + collections with composite elements // and reset reached, doupdate, etc. log.debug("dirty checking collections"); final List list = IdentityMap.entries( session.getPersistenceContext().getCollectionEntries() ); final int size = list.size(); for ( int i = 0; i < size; i++ ) { Map.Entry e = ( Map.Entry ) list.get( i ); ( (CollectionEntry) e.getValue() ).preFlush( (PersistentCollection) e.getKey() ); } }
/** * process cascade save/update at the start of a flush to discover * any newly referenced entity that must be passed to saveOrUpdate(), * and also apply orphan delete */ private void prepareEntityFlushes(SessionImplementor session) throws HibernateException { log.debug("processing flush-time cascades"); final Map.Entry[] list = IdentityMap.concurrentEntries( session.getPersistenceContext().getEntityEntries() ); //safe from concurrent modification because of how entryList() is implemented on IdentityMap final int size = list.length; for ( int i=0; i<size; i++ ) { Map.Entry me = list[i]; EntityEntry entry = (EntityEntry) me.getValue(); Status status = entry.getStatus(); if ( status == Status.MANAGED || status == Status.SAVING ) { cascadeOnFlush( session, entry.getPersister(), me.getKey() ); } } }
public void putAll(Map otherMap) { Iterator iter = otherMap.entrySet().iterator(); while ( iter.hasNext() ) { Map.Entry me = (Map.Entry) iter.next(); put( me.getKey(), me.getValue() ); } }
public static List entries(Map map) { return ( (IdentityMap) map ).entryList(); }
rtn.entityEntries = IdentityMap.instantiateSequenced( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count ); for ( int i = 0; i < count; i++ ) { Object entity = ois.readObject();
/** * Constructs a PersistentContext, bound to the given session. * * @param session The session "owning" this context. */ public PersistenceContext(SessionImplementor session) { this.session = session; entitiesByKey = new HashMap(INIT_MAP_SIZE); entitiesByUniqueKey = new HashMap(INIT_MAP_SIZE); proxiesByKey = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK); entitySnapshotsByKey = new HashMap(INIT_MAP_SIZE); //nonExistantEntityKeys = new HashSet(INIT_MAP_SIZE); //nonExistentEntityUniqueKeys = new HashSet(INIT_MAP_SIZE); entityEntries = IdentityMap.instantiateSequenced(INIT_MAP_SIZE); collectionEntries = IdentityMap.instantiateSequenced(INIT_MAP_SIZE); collectionsByKey = new HashMap(INIT_MAP_SIZE); arrayHolders = IdentityMap.instantiate(INIT_MAP_SIZE); initTransientState(); }
public static Iterator keyIterator(Map map) { return ( (IdentityMap) map ).keyIterator(); }
/** * Initialize the flags of the CollectionEntry, including the * dirty check. */ private void prepareCollectionFlushes(SessionImplementor session) throws HibernateException { // Initialize dirty flags for arrays + collections with composite elements // and reset reached, doupdate, etc. log.debug("dirty checking collections"); final List list = IdentityMap.entries( session.getPersistenceContext().getCollectionEntries() ); final int size = list.size(); for ( int i = 0; i < size; i++ ) { Map.Entry e = ( Map.Entry ) list.get( i ); ( (CollectionEntry) e.getValue() ).preFlush( (PersistentCollection) e.getKey() ); } }
/** * process cascade save/update at the start of a flush to discover * any newly referenced entity that must be passed to saveOrUpdate(), * and also apply orphan delete */ private void prepareEntityFlushes(EventSource session) throws HibernateException { log.debug("processing flush-time cascades"); final Map.Entry[] list = IdentityMap.concurrentEntries( session.getPersistenceContext().getEntityEntries() ); //safe from concurrent modification because of how entryList() is implemented on IdentityMap final int size = list.length; final Object anything = getAnything(); for ( int i=0; i<size; i++ ) { Map.Entry me = list[i]; EntityEntry entry = (EntityEntry) me.getValue(); Status status = entry.getStatus(); if ( status == Status.MANAGED || status == Status.SAVING ) { cascadeOnFlush( session, entry.getPersister(), me.getKey(), anything ); } } }
public void putAll(Map otherMap) { Iterator iter = otherMap.entrySet().iterator(); while ( iter.hasNext() ) { Map.Entry me = (Map.Entry) iter.next(); put( me.getKey(), me.getValue() ); } }
public static List entries(Map map) { return ( (IdentityMap) map ).entryList(); }
public IdentitySet() { this.map = IdentityMap.instantiate( 10 ); }
/** * Workaround for a JDK 1.4.1 bug where <tt>IdentityHashMap</tt>s are not * correctly deserialized. * * @param o * @return Map */ public static Map deserialize(Object o) { return new IdentityMap( (Map) o ); }
/** * Get the collection entry for a collection passed to filter, * which might be a collection wrapper, an array, or an unwrapped * collection. Return null if there is no entry. */ public CollectionEntry getCollectionEntryOrNull(Object collection) { PersistentCollection coll; if ( collection instanceof PersistentCollection ) { coll = (PersistentCollection) collection; //if (collection==null) throw new TransientObjectException("Collection was not yet persistent"); } else { coll = getCollectionHolder(collection); if ( coll == null ) { //it might be an unwrapped collection reference! //try to find a wrapper (slowish) Iterator wrappers = IdentityMap.keyIterator(collectionEntries); while ( wrappers.hasNext() ) { PersistentCollection pc = (PersistentCollection) wrappers.next(); if ( pc.isWrapper(collection) ) { coll = pc; break; } } } } return (coll == null) ? null : getCollectionEntry(coll); }