Java Code Examples for org.hibernate.engine.spi.QueryParameters#setPositionalParameterValues()
The following examples show how to use
org.hibernate.engine.spi.QueryParameters#setPositionalParameterValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactiveDynamicBatchingEntityLoaderBuilder.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
private static QueryParameters buildMultiLoadQueryParameters( OuterJoinLoadable persister, Serializable[] ids, LockOptions lockOptions) { Type[] types = new Type[ids.length]; Arrays.fill( types, persister.getIdentifierType() ); QueryParameters qp = new QueryParameters(); qp.setOptionalEntityName( persister.getEntityName() ); qp.setPositionalParameterTypes( types ); qp.setPositionalParameterValues( ids ); qp.setLockOptions( lockOptions ); qp.setOptionalObject( null ); qp.setOptionalId( null ); return qp; }
Example 2
Source File: ReactiveBatchingEntityLoader.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 6 votes |
protected QueryParameters buildQueryParameters( Serializable id, Serializable[] ids, Object optionalObject, LockOptions lockOptions, Boolean readOnly) { Type[] types = new Type[ids.length]; Arrays.fill( types, persister().getIdentifierType() ); QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( types ); qp.setPositionalParameterValues( ids ); qp.setOptionalObject( optionalObject ); qp.setOptionalEntityName( persister().getEntityName() ); qp.setOptionalId( id ); qp.setLockOptions( lockOptions ); if ( readOnly != null ) { qp.setReadOnly( readOnly ); } return qp; }
Example 3
Source File: BatchingEntityLoader.java From lams with GNU General Public License v2.0 | 6 votes |
protected QueryParameters buildQueryParameters( Serializable id, Serializable[] ids, Object optionalObject, LockOptions lockOptions) { Type[] types = new Type[ids.length]; Arrays.fill( types, persister().getIdentifierType() ); QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( types ); qp.setPositionalParameterValues( ids ); qp.setOptionalObject( optionalObject ); qp.setOptionalEntityName( persister().getEntityName() ); qp.setOptionalId( id ); qp.setLockOptions( lockOptions ); return qp; }
Example 4
Source File: DynamicBatchingEntityLoaderBuilder.java From lams with GNU General Public License v2.0 | 6 votes |
public static QueryParameters buildMultiLoadQueryParameters( OuterJoinLoadable persister, Serializable[] ids, LockOptions lockOptions) { Type[] types = new Type[ids.length]; Arrays.fill( types, persister.getIdentifierType() ); QueryParameters qp = new QueryParameters(); qp.setOptionalEntityName( persister.getEntityName() ); qp.setPositionalParameterTypes( types ); qp.setPositionalParameterValues( ids ); qp.setLockOptions( lockOptions ); qp.setOptionalObject( null ); qp.setOptionalId( null ); return qp; }
Example 5
Source File: BatchingEntityLoader.java From lams with GNU General Public License v2.0 | 6 votes |
protected QueryParameters buildQueryParameters( Serializable id, Serializable[] ids, Object optionalObject, LockOptions lockOptions) { Type[] types = new Type[ids.length]; Arrays.fill( types, persister().getIdentifierType() ); QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( types ); qp.setPositionalParameterValues( ids ); qp.setOptionalObject( optionalObject ); qp.setOptionalEntityName( persister().getEntityName() ); qp.setOptionalId( id ); qp.setLockOptions( lockOptions ); return qp; }
Example 6
Source File: AbstractLoadPlanBasedEntityLoader.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Object load(Serializable id, Object optionalObject, SharedSessionContractImplementor session, LockOptions lockOptions) { final Object result; try { final QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( new Type[] { entityPersister.getIdentifierType() } ); qp.setPositionalParameterValues( new Object[] { id } ); qp.setOptionalObject( optionalObject ); qp.setOptionalEntityName( entityPersister.getEntityName() ); qp.setOptionalId( id ); qp.setLockOptions( lockOptions ); final List results = executeLoad( session, qp, staticLoadQuery, false, null ); result = extractEntityResult( results, id ); } catch ( SQLException sqle ) { throw session.getJdbcServices().getSqlExceptionHelper().convert( sqle, "could not load an entity: " + MessageHelper.infoString( entityPersister, id, entityPersister.getIdentifierType(), getFactory() ), staticLoadQuery.getSqlStatement() ); } log.debugf( "Done entity load : %s#%s", getEntityName(), id ); return result; }
Example 7
Source File: AbstractLoadPlanBasedCollectionInitializer.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void initialize(Serializable id, SharedSessionContractImplementor session) throws HibernateException { if ( log.isDebugEnabled() ) { log.debugf( "Loading collection: %s", MessageHelper.collectionInfoString( collectionPersister, id, getFactory() ) ); } final Serializable[] ids = new Serializable[]{id}; try { final QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( new Type[]{ collectionPersister.getKeyType() } ); qp.setPositionalParameterValues( ids ); qp.setCollectionKeys( ids ); qp.setLockOptions( lockOptions ); executeLoad( session, qp, staticLoadQuery, true, null ); } catch ( SQLException sqle ) { throw session.getJdbcServices().getSqlExceptionHelper().convert( sqle, "could not initialize a collection: " + MessageHelper.collectionInfoString( collectionPersister, id, getFactory() ), staticLoadQuery.getSqlStatement() ); } log.debug( "Done loading collection" ); }
Example 8
Source File: AbstractLoadPlanBasedEntityLoader.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Called by wrappers that batch load entities * @param persister only needed for logging * @param lockOptions */ public final List loadEntityBatch( final SharedSessionContractImplementor session, final Serializable[] ids, final Type idType, final Object optionalObject, final String optionalEntityName, final Serializable optionalId, final EntityPersister persister, LockOptions lockOptions) throws HibernateException { if ( log.isDebugEnabled() ) { log.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister, ids, getFactory() ) ); } final Type[] types = new Type[ids.length]; Arrays.fill( types, idType ); List result; try { final QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( types ); qp.setPositionalParameterValues( ids ); qp.setLockOptions( lockOptions ); result = executeLoad( session, qp, staticLoadQuery, false, null ); } catch ( SQLException sqle ) { throw getFactory().getSQLExceptionHelper().convert( sqle, "could not load an entity batch: " + MessageHelper.infoString( entityPersister, ids, getFactory() ), staticLoadQuery.getSqlStatement() ); } log.debug( "Done entity batch load" ); return result; }
Example 9
Source File: Loader.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Called by subclasses that load entities */ protected final List loadEntity( final SharedSessionContractImplementor session, final Object id, final Type identifierType, final Object optionalObject, final String optionalEntityName, final Serializable optionalIdentifier, final EntityPersister persister, LockOptions lockOptions) throws HibernateException { if ( LOG.isDebugEnabled() ) { LOG.debugf( "Loading entity: %s", MessageHelper.infoString( persister, id, identifierType, getFactory() ) ); } List result; try { QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( new Type[] {identifierType} ); qp.setPositionalParameterValues( new Object[] {id} ); qp.setOptionalObject( optionalObject ); qp.setOptionalEntityName( optionalEntityName ); qp.setOptionalId( optionalIdentifier ); qp.setLockOptions( lockOptions ); result = doQueryAndInitializeNonLazyCollections( session, qp, false ); } catch (SQLException sqle) { final Loadable[] persisters = getEntityPersisters(); throw factory.getJdbcServices().getSqlExceptionHelper().convert( sqle, "could not load an entity: " + MessageHelper.infoString( persisters[persisters.length - 1], id, identifierType, getFactory() ), getSQLString() ); } LOG.debug( "Done entity load" ); return result; }
Example 10
Source File: Loader.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Called by wrappers that batch load entities */ public final List loadEntityBatch( final SharedSessionContractImplementor session, final Serializable[] ids, final Type idType, final Object optionalObject, final String optionalEntityName, final Serializable optionalId, final EntityPersister persister, LockOptions lockOptions) throws HibernateException { if ( LOG.isDebugEnabled() ) { LOG.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister, ids, getFactory() ) ); } Type[] types = new Type[ids.length]; Arrays.fill( types, idType ); List result; try { QueryParameters qp = new QueryParameters(); qp.setPositionalParameterTypes( types ); qp.setPositionalParameterValues( ids ); qp.setOptionalObject( optionalObject ); qp.setOptionalEntityName( optionalEntityName ); qp.setOptionalId( optionalId ); qp.setLockOptions( lockOptions ); result = doQueryAndInitializeNonLazyCollections( session, qp, false ); } catch (SQLException sqle) { throw factory.getJdbcServices().getSqlExceptionHelper().convert( sqle, "could not load an entity batch: " + MessageHelper.infoString( getEntityPersisters()[0], ids, getFactory() ), getSQLString() ); } LOG.debug( "Done entity batch load" ); return result; }