本文整理汇总了Java中org.hibernate.proxy.LazyInitializer.getIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java LazyInitializer.getIdentifier方法的具体用法?Java LazyInitializer.getIdentifier怎么用?Java LazyInitializer.getIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.proxy.LazyInitializer
的用法示例。
在下文中一共展示了LazyInitializer.getIdentifier方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIdentifier
import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public Serializable getIdentifier(Object object) throws HibernateException {
errorIfClosed();
checkTransactionSynchStatus();
if ( object instanceof HibernateProxy ) {
LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
if ( li.getSession() != this ) {
throw new TransientObjectException( "The proxy was not associated with this session" );
}
return li.getIdentifier();
}
else {
EntityEntry entry = persistenceContext.getEntry(object);
if ( entry == null ) {
throw new TransientObjectException( "The instance was not associated with this session" );
}
return entry.getId();
}
}
示例2: getIdentifier
import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
public Serializable getIdentifier(Object object) throws HibernateException {
errorIfClosed();
checkTransactionSynchStatus();
if ( object instanceof HibernateProxy ) {
LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
if ( li.getSession() != this ) {
throw new TransientObjectException( "The proxy was not associated with this session" );
}
return li.getIdentifier();
}
else {
EntityEntry entry = persistenceContext.getEntry(object);
if ( entry == null ) {
throw new TransientObjectException( "The instance was not associated with this session" );
}
return entry.getId();
}
}
示例3: getIdentifier
import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
@Override
public Object getIdentifier(Object entity) {
if (entity instanceof org.hibernate.proxy.HibernateProxy) {
LazyInitializer initializer
= ((org.hibernate.proxy.HibernateProxy)entity).getHibernateLazyInitializer();
return initializer.getIdentifier();
} else {
return persistenceUnitUtil.getIdentifier(entity);
}
}
示例4: reassociateProxy
import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
* Associate a proxy that was instantiated by another session with this session
*
* @param li The proxy initializer.
* @param proxy The proxy to reassociate.
*/
private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
if ( li.getSession() != this.getSession() ) {
EntityPersister persister = session.getFactory().getEntityPersister( li.getEntityName() );
EntityKey key = new EntityKey( li.getIdentifier(), persister, session.getEntityMode() );
// any earlier proxy takes precedence
if ( !proxiesByKey.containsKey( key ) ) {
proxiesByKey.put( key, proxy );
}
proxy.getHibernateLazyInitializer().setSession( session );
}
}
示例5: getIdentifier
import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
* Get the identifier value of an instance or proxy.
* <p/>
* Intended only for loggin purposes!!!
*
* @param object The object from which to extract the identifier.
* @param persister The entity persister
* @param entityMode The entity mode
* @return The extracted identifier.
*/
private static Serializable getIdentifier(Object object, EntityPersister persister, EntityMode entityMode) {
if (object instanceof HibernateProxy) {
HibernateProxy proxy = (HibernateProxy) object;
LazyInitializer li = proxy.getHibernateLazyInitializer();
return li.getIdentifier();
}
else {
return persister.getIdentifier( object, entityMode );
}
}
示例6: getId
import org.hibernate.proxy.LazyInitializer; //导入方法依赖的package包/类
/**
* extract the id from the proxy without initializing it
*/
public static Long getId(AbstractModel model) {
if (model instanceof HibernateProxy) {
LazyInitializer lazyInitializer = ((HibernateProxy) model).getHibernateLazyInitializer();
if (lazyInitializer.isUninitialized()) {
return (Long) lazyInitializer.getIdentifier();
}
}
return model.getId();
}