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


Java ClassMetadata.getEntityName方法代码示例

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


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

示例1: main

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
    final Session session = getSession();
    try {
        System.out.println("querying all the managed entities...");
        final Map metadataMap = session.getSessionFactory().getAllClassMetadata();
        for (Object key : metadataMap.keySet()) {
            final ClassMetadata classMetadata = (ClassMetadata) metadataMap.get(key);
            final String entityName = classMetadata.getEntityName();
            final Query query = session.createQuery("from " + entityName);
            System.out.println("executing: " + query.getQueryString());
            for (Object o : query.list()) {
                System.out.println("  " + o);
            }
        }
    } finally {
        session.close();
    }
}
 
开发者ID:jonashao,项目名称:ssh,代码行数:19,代码来源:Main.java

示例2: main

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
        final Session session = getSession();
        try {
            System.out.println("querying all the managed entity...");
            final Map metadataMap = session.getSessionFactory().getAllClassMetadata();
            for (Object key : metadataMap.keySet()) {
                final ClassMetadata classMetadata = (ClassMetadata) metadataMap.get(key);
                final String entityName = classMetadata.getEntityName();
                for (Object o : getQuery("from " + entityName)) {
                    System.out.println("  " + o);
                }
//                for (Object o : getData(entityName)) {
//                    System.out.println("  " + o);
//                }
            }

        } finally {
            session.close();
        }
    }
 
开发者ID:free-memory,项目名称:lucas,代码行数:21,代码来源:DBConnectionUtil.java

示例3: getClassMetadata

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
private ClassMetadata getClassMetadata(String entityName) {
    Map<String,ClassMetadata> classMetadatas=sessionFactory.getAllClassMetadata();
    ClassMetadata classMetadata=null;


    for(String fqcn:classMetadatas.keySet()) {
        if (fqcn.endsWith("."+entityName) || (fqcn.equals(entityName))) {

            if (classMetadata!=null) {
                throw new RuntimeException("Existen 2 entidades con el mismo nombre:"+ fqcn + " y " + classMetadata.getEntityName() + " para la solicitud de " + entityName);
            }

            classMetadata=classMetadatas.get(fqcn);
        }
    }

    return classMetadata;
}
 
开发者ID:ix3,项目名称:ix3,代码行数:19,代码来源:MetaDataFactoryImplHibernate.java

示例4: deleteByMap

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
/**
 * 根据HaloMap删除
 * 
 * @param parameter
 * @return 返回行数 失败返回-1
 */
public final int deleteByMap(HaloMap parameter) {
	if(null==parameter){
		parameter= new HaloMap();
	}
	ClassMetadata cm = sessionFactory.getClassMetadata(this.entityType);
	String entityName = cm.getEntityName();
	String selectHql = String.format("delete %s ", entityName);
	HqlWithParameter hqlWithParameter = createQueryHql(parameter, selectHql);
	String hql = hqlWithParameter.getHql();
	HaloMap hqlPrmMap = hqlWithParameter.getParamterMap();
	if (hqlPrmMap.isEmpty()) {
		logger.warn("不允许无条件删除!防止全表更新(可通过条件实现)");
		return -1;
	}
	Query query = createQuery(hql, hqlPrmMap);
	return query.executeUpdate();
}
 
开发者ID:VonChange,项目名称:haloDao-Hibernate3,代码行数:24,代码来源:HaloDao.java

示例5: printAllData

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
/**
 * Print all data that is held in this database
 *
 * @throws org.hibernate.HibernateException
 */
public static void printAllData() throws HibernateException {
	Session session = getSession();

	try {
		System.out.println("querying all the managed entities...");

		final Map<String, ClassMetadata> metadataMap = session.getSessionFactory().getAllClassMetadata();

		for (String key : metadataMap.keySet()) {
			final ClassMetadata classMetadata = metadataMap.get(key);
			final String entityName = classMetadata.getEntityName();
			final Query query = session.createQuery("from " + entityName);

			System.out.println("executing: " + query.getQueryString());
			for (Object o : query.list()) {
				System.out.println("  " + o);
			}
		}

	} finally {
		session.close();
	}
}
 
开发者ID:jcreason,项目名称:brewninja,代码行数:29,代码来源:HibernateUtil.java

示例6: toString

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
/**
 * @param entity an actual entity object, not a proxy!
 */
public String toString(Object entity, EntityMode entityMode) throws HibernateException {

	// todo : this call will not work for anything other than pojos!
	ClassMetadata cm = factory.getClassMetadata( entity.getClass() );

	if ( cm==null ) return entity.getClass().getName();

	Map result = new HashMap();

	if ( cm.hasIdentifierProperty() ) {
		result.put(
			cm.getIdentifierPropertyName(),
			cm.getIdentifierType().toLoggableString( cm.getIdentifier( entity, entityMode ), factory )
		);
	}

	Type[] types = cm.getPropertyTypes();
	String[] names = cm.getPropertyNames();
	Object[] values = cm.getPropertyValues( entity, entityMode );
	for ( int i=0; i<types.length; i++ ) {
		if ( !names[i].startsWith("_") ) {
			String strValue = values[i]==LazyPropertyInitializer.UNFETCHED_PROPERTY ?
				values[i].toString() :
				types[i].toLoggableString( values[i], factory );
			result.put( names[i], strValue );
		}
	}
	return cm.getEntityName() + result.toString();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:33,代码来源:Printer.java

示例7: findForeignKey

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
/**
 * Find a foreign key matching the given property, by looking in the fkMap.
 * The property may be defined on the class or a superclass, so this function calls itself recursively.
 * @param propName Name of the property e.g. "Product"
 * @param meta Class metadata, for traversing the class hierarchy
 * @return The name of the foreign key, e.g. "ProductID"
 */
private String findForeignKey(String propName, ClassMetadata meta) {
    String relKey = meta.getEntityName() + '.' + propName;
    if (fkMap.containsKey(relKey)) {
        return fkMap.get(relKey);
    } else if (meta.isInherited() && meta instanceof AbstractEntityPersister) {
        String superEntityName = ((AbstractEntityPersister) meta).getMappedSuperclass();
        ClassMetadata superMeta = sessionFactory.getClassMetadata(superEntityName);
        return findForeignKey(propName, superMeta);
    } else {
        throw new IllegalArgumentException("Foreign Key '" + relKey + "' could not be found.");
    }
}
 
开发者ID:Breeze,项目名称:breeze.server.java,代码行数:20,代码来源:RelationshipFixer.java

示例8: initMetadata

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
/** Renseigne l'attribut _metadataList. */
protected void initMetadata() {
	this.metadataList = new ArrayList<Metadata>();
	Map<?, ?> allClassesMetadata = HibernateUtil.getSessionFactory().getAllClassMetadata();

	for (Object key : allClassesMetadata.keySet()) {
		if (GeodatabaseHibernate.logger.isDebugEnabled()) {
			GeodatabaseHibernate.logger.debug("key = " + key);
		}
		ClassMetadata classMetadata = (ClassMetadata) allClassesMetadata.get(key);
		if (GeodatabaseHibernate.logger.isDebugEnabled()) {
			GeodatabaseHibernate.logger.debug("metadata = " + classMetadata);
		}
		String className = (classMetadata.getEntityName());
		if (GeodatabaseHibernate.logger.isDebugEnabled()) {
			GeodatabaseHibernate.logger.debug("entity name = " + className);
		}

		Metadata metadataElt = new Metadata();
		metadataElt.setClassName(className);
		String[] propertyNames = classMetadata.getPropertyNames();
		if (GeodatabaseHibernate.logger.isDebugEnabled()) {
			for (int i = 0; i < propertyNames.length; i++) {
				GeodatabaseHibernate.logger.debug("property name " + i + " = " + propertyNames[i]);
			}
		}

		if (classMetadata instanceof AbstractEntityPersister) {
			metadataElt.setTableName(((AbstractEntityPersister) classMetadata).getRootTableName());
			metadataElt.setIdFieldName(((AbstractEntityPersister) classMetadata).getIdentifierPropertyName());
			metadataElt.setIdColumnName(((AbstractEntityPersister) classMetadata).getIdentifierColumnNames()[0]);

			// FIXME a revoir: aussi l'enveloppe, les srid, la dimension, et
			// d'autres...
			metadataElt.setGeomColumnName("geom");

			if (GeodatabaseHibernate.logger.isDebugEnabled()) {
				GeodatabaseHibernate.logger.debug("table name = " + metadataElt.getTableName());
				GeodatabaseHibernate.logger.debug("id field name = " + metadataElt.getIdFieldName());
				GeodatabaseHibernate.logger.debug("id column name = " + metadataElt.getIdColumnName());
			}
		}
		this.metadataList.add(metadataElt);
	}
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:46,代码来源:GeodatabaseHibernate.java

示例9: getEntityClassName

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
/**
 * 获取实体类型名
 * @author FengJianBo
 * @return
 * 2014年3月18日 下午2:33:01
 */
protected String getEntityClassName() {
	ClassMetadata meta = sessionFactory.getCurrentSession().getSessionFactory().getClassMetadata(getEntityClass());
	return meta.getEntityName();
}
 
开发者ID:kanenhan,项目名称:shj_template,代码行数:11,代码来源:BaseDaoImpl.java

示例10: getEntityName

import org.hibernate.metadata.ClassMetadata; //导入方法依赖的package包/类
/**
 * 获取实体名称
 * 
 * @return String
 */
public String getEntityName() {
	ClassMetadata meta = sessionFactory.getClassMetadata(entityClass);
	return meta.getEntityName();
}
 
开发者ID:extion,项目名称:base-framework,代码行数:10,代码来源:BasicHibernateDao.java


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