本文整理汇总了Java中org.hibernate.engine.SessionImplementor类的典型用法代码示例。如果您正苦于以下问题:Java SessionImplementor类的具体用法?Java SessionImplementor怎么用?Java SessionImplementor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SessionImplementor类属于org.hibernate.engine包,在下文中一共展示了SessionImplementor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSessionProxy
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
/**
* Create a close-suppressing proxy for the given Hibernate Session.
* The proxy also prepares returned Query and Criteria objects.
* @param session the Hibernate Session to create a proxy for
* @return the Session proxy
* @see org.hibernate.Session#close()
* @see #prepareQuery
* @see #prepareCriteria
*/
protected Session createSessionProxy(Session session) {
Class<?>[] sessionIfcs;
Class<?> mainIfc = (session instanceof org.hibernate.classic.Session ?
org.hibernate.classic.Session.class : Session.class);
if (session instanceof EventSource) {
sessionIfcs = new Class<?>[] {mainIfc, EventSource.class};
}
else if (session instanceof SessionImplementor) {
sessionIfcs = new Class<?>[] {mainIfc, SessionImplementor.class};
}
else {
sessionIfcs = new Class<?>[] {mainIfc};
}
return (Session) Proxy.newProxyInstance(
session.getClass().getClassLoader(), sessionIfcs,
new CloseSuppressingInvocationHandler(session));
}
示例2: nullSafeGet
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
public Object nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
Object permission = null;
String className = resultSet.getString(names[0]);
String name = resultSet.getString(names[1]);
String actions = resultSet.getString(names[2]);
try {
// TODO optimize performance by caching the constructors
Class permissionClass = PermissionUserType.class.getClassLoader().loadClass(className);
@SuppressWarnings("unchecked")
Constructor constructor = permissionClass.getDeclaredConstructor(NAME_ACTIOS_CONSTRUCTOR_PARAMETER_TYPES);
permission = constructor.newInstance(new Object[]{name, actions});
} catch (Exception e) {
throw new HibernateException("couldn't create permission from database record ["+className+"|"+name+"|"+actions+"]. Does the permission class have a (String name,String actions) constructor ?", e);
}
return permission;
}
示例3: getConnection
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
/**
* Returns the connection used by the hibernate session.
*
* @param doFlush
* if true then the current actions are first flushed.
*
* @return the current database connection
* @see #flush()
*/
public Connection getConnection(boolean doFlush) {
if (doFlush) {
// before returning a connection flush all other hibernate actions
// to the database.
flush();
}
// NOTE: workaround for this issue:
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529
final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader());
final Connection connection = ((SessionImplementor) SessionHandler.getInstance().getSession())
.connection();
return connection;
} finally {
Thread.currentThread().setContextClassLoader(currentLoader);
}
}
示例4: openSession
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
/**
* Note method sets user session information in the database and opens a connection for this.
*/
public Session openSession(Connection connection, Interceptor interceptor) {
// NOTE: workaround for this issue:
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529
final Session session = delegateSessionFactory.openSession(connection, interceptor);
final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader());
Connection conn = ((SessionImplementor) session).connection();
SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties()
.getProperty("bbdd.rdbms"));
SessionInfo.setDBSessionInfo(conn);
} finally {
Thread.currentThread().setContextClassLoader(currentLoader);
}
return session;
}
示例5: openStatelessSession
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
/**
* Note method sets user session information in the database and opens a connection for this.
*/
public StatelessSession openStatelessSession(Connection connection) {
// NOTE: workaround for this issue:
// http://opensource.atlassian.com/projects/hibernate/browse/HHH-3529
final StatelessSession session = delegateSessionFactory.openStatelessSession(connection);
final ClassLoader currentLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(BorrowedConnectionProxy.class.getClassLoader());
Connection conn = ((SessionImplementor) session).connection();
SessionInfo.initDB(conn, OBPropertiesProvider.getInstance().getOpenbravoProperties()
.getProperty("bbdd.rdbms"));
SessionInfo.setDBSessionInfo(conn);
} finally {
Thread.currentThread().setContextClassLoader(currentLoader);
}
return session;
}
示例6: identityRemove
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
static void identityRemove(
Collection list,
Object object,
String entityName,
SessionImplementor session)
throws HibernateException {
if ( object!=null && ForeignKeys.isNotTransient(entityName, object, null, session) ) {
Type idType = session.getFactory().getEntityPersister(entityName).getIdentifierType();
Serializable idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, object, session);
Iterator iter = list.iterator();
while ( iter.hasNext() ) {
Serializable idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, iter.next(), session);
if ( idType.isEqual( idOfCurrent, idOfOld, session.getEntityMode(), session.getFactory() ) ) {
iter.remove();
break;
}
}
}
}
示例7: performScroll
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
public ScrollableResults performScroll(
QueryParameters queryParameters,
SessionImplementor session) throws HibernateException {
if ( log.isTraceEnabled() ) {
log.trace( "iterate: " + getSourceQuery() );
queryParameters.traceParameters( session.getFactory() );
}
if ( translators.length != 1 ) {
throw new QueryException( "implicit polymorphism not supported for scroll() queries" );
}
if ( queryParameters.getRowSelection().definesLimits() && translators[0].containsCollectionFetches() ) {
throw new QueryException( "firstResult/maxResults not supported in conjunction with scroll() of a query containing collection fetches" );
}
return translators[0].scroll( queryParameters, session );
}
示例8: replace
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
public Object replace(
Object original,
Object target,
SessionImplementor session,
Object owner,
Map copyCache,
ForeignKeyDirection foreignKeyDirection)
throws HibernateException {
boolean include;
if ( isAssociationType() ) {
AssociationType atype = (AssociationType) this;
include = atype.getForeignKeyDirection()==foreignKeyDirection;
}
else {
include = ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT==foreignKeyDirection;
}
return include ? replace(original, target, session, owner, copyCache) : target;
}
示例9: injectFieldInterceptor
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
public static FieldInterceptor injectFieldInterceptor(
Object entity,
String entityName,
Set uninitializedFieldNames,
SessionImplementor session) {
if ( entity != null ) {
Class[] definedInterfaces = entity.getClass().getInterfaces();
for ( int i = 0; i < definedInterfaces.length; i++ ) {
if ( "net.sf.cglib.transform.impl.InterceptFieldEnabled".equals( definedInterfaces[i].getName() ) ) {
// we have a CGLIB enhanced entity
return CGLIBHelper.injectFieldInterceptor( entity, entityName, uninitializedFieldNames, session );
}
else if ( "org.hibernate.bytecode.javassist.FieldHandled".equals( definedInterfaces[i].getName() ) ) {
// we have a Javassist enhanced entity
return JavassistHelper.injectFieldInterceptor( entity, entityName, uninitializedFieldNames, session );
}
}
}
return null;
}
示例10: isModified
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session)
throws HibernateException {
if ( current == null ) {
return old != null;
}
if ( old == null ) {
return current != null;
}
Object[] currentValues = getPropertyValues( current, session );
Object[] oldValues = ( Object[] ) old;
int loc = 0;
for ( int i = 0; i < currentValues.length; i++ ) {
int len = propertyTypes[i].getColumnSpan( session.getFactory() );
boolean[] subcheckable = new boolean[len];
System.arraycopy( checkable, loc, subcheckable, 0, len );
if ( propertyTypes[i].isModified( oldValues[i], currentValues[i], subcheckable, session ) ) {
return true;
}
loc += len;
}
return false;
}
示例11: doQueryAndInitializeNonLazyCollections
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
/**
* Execute an SQL query and attempt to instantiate instances of the class mapped by the given
* persister from each row of the <tt>ResultSet</tt>. If an object is supplied, will attempt to
* initialize that object. If a collection is supplied, attempt to initialize that collection.
*/
private List doQueryAndInitializeNonLazyCollections(final SessionImplementor session,
final QueryParameters queryParameters,
final boolean returnProxies)
throws HibernateException, SQLException {
final PersistenceContext persistenceContext = session.getPersistenceContext();
persistenceContext.beforeLoad();
List result;
try {
result = doQuery( session, queryParameters, returnProxies );
}
finally {
persistenceContext.afterLoad();
}
persistenceContext.initializeNonLazyCollections();
return result;
}
示例12: getOptionalObjectKey
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
private static EntityKey getOptionalObjectKey(QueryParameters queryParameters, SessionImplementor session) {
final Object optionalObject = queryParameters.getOptionalObject();
final Serializable optionalId = queryParameters.getOptionalId();
final String optionalEntityName = queryParameters.getOptionalEntityName();
if ( optionalObject != null && optionalEntityName != null ) {
return new EntityKey(
optionalId,
session.getEntityPersister( optionalEntityName, optionalObject ),
session.getEntityMode()
);
}
else {
return null;
}
}
示例13: bindPositionalParameters
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
/**
* Bind positional parameter values to the <tt>PreparedStatement</tt>
* (these are parameters specified by a JDBC-style ?).
*/
private int bindPositionalParameters(final PreparedStatement st,
final QueryParameters queryParameters, final int start,
final SessionImplementor session) throws SQLException,
HibernateException {
final Object[] values = queryParameters
.getFilteredPositionalParameterValues();
final Type[] types = queryParameters
.getFilteredPositionalParameterTypes();
int span = 0;
for (int i = 0; i < values.length; i++) {
types[i].nullSafeSet( st, values[i], start + span, session );
span += types[i].getColumnSpan( session.getFactory() );
}
return span;
}
示例14: EntityUpdateAction
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
public EntityUpdateAction(
final Serializable id,
final Object[] state,
final int[] dirtyProperties,
final boolean hasDirtyCollection,
final Object[] previousState,
final Object previousVersion,
final Object nextVersion,
final Object instance,
final Object rowId,
final EntityPersister persister,
final SessionImplementor session) throws HibernateException {
super( session, id, instance, persister );
this.state = state;
this.previousState = previousState;
this.previousVersion = previousVersion;
this.nextVersion = nextVersion;
this.dirtyFields = dirtyProperties;
this.hasDirtyCollection = hasDirtyCollection;
this.rowId = rowId;
}
示例15: assemble
import org.hibernate.engine.SessionImplementor; //导入依赖的package包/类
public Object assemble(
Serializable oid,
SessionImplementor session,
Object owner) throws HibernateException {
//TODO: currently broken for unique-key references (does not detect
// change to unique key property of the associated object)
Serializable id = assembleId( oid, session );
if ( isNotEmbedded( session ) ) {
return id;
}
if ( id == null ) {
return null;
}
else {
return resolveIdentifier( id, session );
}
}