protected void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException { if ( value == null ) { st.setNull( index, sqlTypes( null )[0] ); } else { byte[] toSet = unWrap( value ); final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob(); if ( useInputStream ) { st.setBinaryStream( index, new ByteArrayInputStream( toSet ), toSet.length ); } else { st.setBlob( index, Hibernate.getLobCreator( session ).createBlob( toSet ) ); } } }
public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException { if ( value != null ) { byte[] toSet; toSet = toBytes( value ); if ( session.getFactory().getDialect().useInputStreamToInsertBlob() ) { st.setBinaryStream( index, new ByteArrayInputStream( toSet ), toSet.length ); } else { st.setBlob( index, Hibernate.getLobCreator( session ).createBlob( toSet ) ); } } else { st.setNull( index, sqlTypes( null )[0] ); } }
public Object replace( Object original, Object target, SessionImplementor session, Object owner, Map copyCache ) throws HibernateException { if ( isEqual( original, target, session.getEntityMode() ) ) return original; return deepCopy( original, session.getEntityMode(), session.getFactory() ); }
private CollectionPersister getPersister(SessionImplementor session) { return session .getFactory() .getCollectionPersister( role ); }
public Object hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { return super.getIdentifierOrUniqueKeyType( session.getFactory() ) .nullSafeGet(rs, names, session, owner); }
public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { if (value==null) { return null; } else { return (Serializable) deepCopy( value, session.getEntityMode(), session.getFactory() ); } }
public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { if ( cached==null ) { return null; } else { return deepCopy( cached, session.getEntityMode(), session.getFactory() ); } }
public int getRowNumber() throws HibernateException { try { return getResultSet().getRow()-1; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( getSession().getFactory().getSQLExceptionConverter(), sqle, "exception calling getRow()" ); } }
private void checkTargetState() { if ( !unwrap ) { if ( target == null ) { getSession().getFactory().getEntityNotFoundDelegate().handleEntityNotFound( entityName, id ); } } }
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) throws HibernateException, SQLException { getIdentifierOrUniqueKeyType( session.getFactory() ) .nullSafeSet(st, getIdentifier(value, session), index, settable, session); }
public boolean isModified(Object old, Object current, SessionImplementor session) throws HibernateException { if (current==null) return old!=null; if (old==null) return current!=null; return getIdentifierOrUniqueKeyType( session.getFactory() ) .isModified( old, getIdentifier(current, session), session ); }
public void execute(Executable executable) { final boolean lockQueryCache = session.getFactory().getSettings().isQueryCacheEnabled(); if ( executable.hasAfterTransactionCompletion() || lockQueryCache ) { executions.add( executable ); } if (lockQueryCache) { session.getFactory() .getUpdateTimestampsCache() .preinvalidate( executable.getPropertySpaces() ); } executable.execute(); }
/** * Associate a proxy that was instantiated by another session with this session */ private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) throws HibernateException { if ( li.getSession() != this ) { EntityPersister persister = session.getFactory().getEntityPersister( li.getEntityName() ); EntityKey key = new EntityKey( li.getIdentifier(), persister, session.getEntityMode() ); if ( !proxiesByKey.containsKey(key) ) proxiesByKey.put(key, proxy); // any earlier proxy takes precedence proxy.getHibernateLazyInitializer().setSession(session); } }
private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session) throws HibernateException { final PersistenceContext persistenceContext = session.getPersistenceContext(); CollectionEntry entry = persistenceContext.getCollectionEntry(coll); log.debug( "Found collection with unloaded owner: " + MessageHelper.collectionInfoString( entry.getLoadedPersister(), entry.getLoadedKey(), session.getFactory() ) ); entry.setCurrentPersister( entry.getLoadedPersister() ); entry.setCurrentKey( entry.getLoadedKey() ); prepareCollectionForUpdate( coll, entry, session.getEntityMode(), session.getFactory() ); }
private Timestamp getCurrentTimestamp(SessionImplementor session) { Dialect dialect = session.getFactory().getDialect(); String timestampSelectString = dialect.getCurrentTimestampSelectString(); if ( dialect.isCurrentTimestampSelectStringCallable() ) { return useCallableStatement( timestampSelectString, session ); } else { return usePreparedStatement( timestampSelectString, session ); } }
public void execute() throws HibernateException { getPersister().recreate( collection, getKey(), getSession() ); evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .recreateCollection( getPersister().getRole() ); } }
public final void beforeExecutions() throws CacheException { // we need to obtain the lock before any actions are // executed, since this may be an inverse="true" // bidirectional association and it is one of the // earlier entity actions which actually updates // the database (this action is resposible for // second-level cache invalidation only) final CacheKey ck = new CacheKey( key, persister.getKeyType(), persister.getRole(), session.getEntityMode(), session.getFactory() ); if ( persister.hasCache() ) lock = persister.getCache().lock(ck, null); }
public boolean isNull(Object owner, SessionImplementor session) { if ( propertyName != null ) { EntityPersister ownerPersister = session.getFactory().getEntityPersister(entityName); Serializable id = session.getEntityIdentifier(owner); EntityKey entityKey = new EntityKey( id, ownerPersister, session.getEntityMode() ); return session.getPersistenceContext().isPropertyNull( entityKey, getPropertyName() ); } else { return false; } }
protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SessionImplementor session) { return new SubselectOneToManyLoader( this, subselect.toSubselectString( getCollectionType().getLHSPropertyName() ), subselect.getResult(), subselect.getQueryParameters(), session.getFactory(), session.getEnabledFilters() ); }
public void execute() throws HibernateException { final PersistentCollection collection = getCollection(); getPersister().recreate( collection, getKey(), getSession() ); getSession().getPersistenceContext() .getCollectionEntry(collection) .afterAction(collection); evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .recreateCollection( getPersister().getRole() ); } }