當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。