当前位置: 首页>>代码示例>>Java>>正文


Java HibernateProxyHelper.getClassWithoutInitializingProxy方法代码示例

本文整理汇总了Java中org.hibernate.proxy.HibernateProxyHelper.getClassWithoutInitializingProxy方法的典型用法代码示例。如果您正苦于以下问题:Java HibernateProxyHelper.getClassWithoutInitializingProxy方法的具体用法?Java HibernateProxyHelper.getClassWithoutInitializingProxy怎么用?Java HibernateProxyHelper.getClassWithoutInitializingProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.proxy.HibernateProxyHelper的用法示例。


在下文中一共展示了HibernateProxyHelper.getClassWithoutInitializingProxy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: equals

import org.hibernate.proxy.HibernateProxyHelper; //导入方法依赖的package包/类
@Override
public boolean equals(Object obj) {
	if (this == obj) {
		return true;
	}
	if (obj == null) {
		return false;
	}
	// hibernate object may have class names like Person_$$_javassist_11
	Class<?> cl1 = HibernateProxyHelper
			.getClassWithoutInitializingProxy(this);
	Class<?> cl2 = HibernateProxyHelper
			.getClassWithoutInitializingProxy(obj);
	if (cl1 != cl2) {
		return false;
	}
	AbstractEntity test = (AbstractEntity) obj;
	// for test use getter here since hibernate may need to load it first
	if (isTransient()) {
		return transientId.equals(test.getTransientId());
	}
	return id.equals(test.getId());
}
 
开发者ID:markkohdev,项目名称:oStorybook,代码行数:24,代码来源:AbstractEntity.java

示例2: analyze

import org.hibernate.proxy.HibernateProxyHelper; //导入方法依赖的package包/类
private void analyze(T aObject)
{
    if (aObject != null) {
        entityClass = HibernateProxyHelper.getClassWithoutInitializingProxy(aObject);

        String idProperty = null;
        Metamodel metamodel = getEntityManager().getMetamodel();
        EntityType entity = metamodel.entity(entityClass);
        Set<SingularAttribute> singularAttributes = entity.getSingularAttributes();
        for (SingularAttribute singularAttribute : singularAttributes) {
            if (singularAttribute.isId()) {
                idProperty = singularAttribute.getName();
                break;
            }
        }
        if (idProperty == null) {
            throw new RuntimeException("id field not found");
        }

        DirectFieldAccessor accessor = new DirectFieldAccessor(aObject);
        id = (Number) accessor.getPropertyValue(idProperty);
    }
    else {
        entityClass = null;
        id = null;
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:28,代码来源:EntityModel.java

示例3: guessType

import org.hibernate.proxy.HibernateProxyHelper; //导入方法依赖的package包/类
private Type guessType(Object param) throws HibernateException {
	Class clazz = HibernateProxyHelper.getClassWithoutInitializingProxy( param );
	return guessType( clazz );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:AbstractQueryImpl.java

示例4: getEntityClass

import org.hibernate.proxy.HibernateProxyHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Transient
final public Class<Entity<K>> getEntityClass()
{
  return HibernateProxyHelper.getClassWithoutInitializingProxy(this);
}
 
开发者ID:hmsiccbl,项目名称:screensaver,代码行数:7,代码来源:AbstractEntity.java

示例5: writeObjects

import org.hibernate.proxy.HibernateProxyHelper; //导入方法依赖的package包/类
/**
 * @param writer
 * @param includeHistory
 * @param session
 * @throws DataAccessException
 * @throws HibernateException
 */
private void writeObjects(final Writer writer, final boolean includeHistory, final Session session, final boolean preserveIds)
    throws DataAccessException, HibernateException
    {
  // Container für die Objekte
  final List<Object> all = new ArrayList<Object>();
  final XStream stream = initXStream(session, true);
  final XStream defaultXStream = initXStream(session, false);

  session.flush();
  // Alles laden
  final List<Class< ? >> entities = new ArrayList<Class< ? >>();
  entities.addAll(HibernateEntities.instance().getOrderedEntities());
  entities.addAll(HibernateEntities.instance().getOrderedHistoryEntities());
  for (final Class< ? > entityClass : entities) {
    final String entitySimpleName = entityClass.getSimpleName();
    final String entityType = entityClass.getName();
    if (includeHistory == false && entityType.startsWith("de.micromata.hibernate.history.") == true) {
      // Skip history entries.
      continue;
    }
    List< ? > list = session.createQuery("select o from " + entityType + " o").setReadOnly(true).list();
    list = (List< ? >) CollectionUtils.select(list, PredicateUtils.uniquePredicate());
    final int size = list.size();
    log.info("Writing " + size + " objects");
    for (final Iterator< ? > it = list.iterator(); it.hasNext();) {
      final Object obj = it.next();
      if (log.isDebugEnabled()) {
        log.debug("loaded object " + obj);
      }
      Hibernate.initialize(obj);
      final Class< ? > targetClass = HibernateProxyHelper.getClassWithoutInitializingProxy(obj);
      final ClassMetadata classMetadata = session.getSessionFactory().getClassMetadata(targetClass);
      if (classMetadata == null) {
        log.fatal("Can't init " + obj + " of type " + targetClass);
        continue;
      }
      // initalisierung des Objekts...
      defaultXStream.marshal(obj, new CompactWriter(new NullWriter()));

      if (preserveIds == false) {
        // Nun kann die ID gelöscht werden
        classMetadata.setIdentifier(obj, null, EntityMode.POJO);
      }
      if (log.isDebugEnabled()) {
        log.debug("loading evicted object " + obj);
      }
      if (this.ignoreFromTopLevelListing.contains(targetClass) == false) {
        all.add(obj);
      }
    }
  }
  // und schreiben
  try {
    writer.write("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
  } catch (final IOException ex) {
    // ignore, will fail on stream.marshal()
  }
  log.info("Wrote " + all.size() + " objects");
  final MarshallingStrategy marshallingStrategy = new ProxyIdRefMarshallingStrategy();
  stream.setMarshallingStrategy(marshallingStrategy);
  stream.marshal(all, new PrettyPrintWriter(writer));
    }
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:70,代码来源:HibernateXmlConverter.java

示例6: getEntityClass

import org.hibernate.proxy.HibernateProxyHelper; //导入方法依赖的package包/类
@Override
public Class<?> getEntityClass(IEntity<?> entity) {
    return HibernateProxyHelper.getClassWithoutInitializingProxy(entity);
}
 
开发者ID:solita,项目名称:query-utils,代码行数:5,代码来源:HibernateTypeProvider.java

示例7: getDomainClass

import org.hibernate.proxy.HibernateProxyHelper; //导入方法依赖的package包/类
/**
 * Returns the domain class of this entity (e.g. Subscription.class).
 * WARNING: Never use the method entity.getClass(), because JPA might create
 * dynamic proxy classes during runtime (byte code injection). Always, use
 * this method instead.
 */
public static Class<?> getDomainClass(Object entityOrProxy) {
    return HibernateProxyHelper
            .getClassWithoutInitializingProxy(entityOrProxy);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:11,代码来源:DomainObject.java


注:本文中的org.hibernate.proxy.HibernateProxyHelper.getClassWithoutInitializingProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。