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


Java SessionFactoryImplementor类代码示例

本文整理汇总了Java中org.hibernate.engine.SessionFactoryImplementor的典型用法代码示例。如果您正苦于以下问题:Java SessionFactoryImplementor类的具体用法?Java SessionFactoryImplementor怎么用?Java SessionFactoryImplementor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: updateDatabaseSchema

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
/**
 * Execute schema update script, determined by the Configuration object
 * used for creating the SessionFactory. A replacement for Hibernate's
 * SchemaUpdate class, for automatically executing schema update scripts
 * on application startup. Can also be invoked manually.
 * <p>Fetch the LocalSessionFactoryBean itself rather than the exposed
 * SessionFactory to be able to invoke this method, e.g. via
 * {@code LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean) ctx.getBean("&mySessionFactory");}.
 * <p>Uses the SessionFactory that this bean generates for accessing a
 * JDBC connection to perform the script.
 * @throws DataAccessException in case of script execution errors
 * @see #setSchemaUpdate
 * @see org.hibernate.cfg.Configuration#generateSchemaUpdateScript
 * @see org.hibernate.tool.hbm2ddl.SchemaUpdate
 */
public void updateDatabaseSchema() throws DataAccessException {
	logger.info("Updating database schema for Hibernate SessionFactory");
	DataSource dataSource = getDataSource();
	if (dataSource != null) {
		// Make given DataSource available for the schema update.
		configTimeDataSourceHolder.set(dataSource);
	}
	try {
		SessionFactory sessionFactory = getSessionFactory();
		final Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect();
		HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
		hibernateTemplate.setFlushMode(HibernateTemplate.FLUSH_NEVER);
		hibernateTemplate.execute(
			new HibernateCallback<Object>() {
				@Override
				public Object doInHibernate(Session session) throws HibernateException, SQLException {
					@SuppressWarnings("deprecation")
					Connection con = session.connection();
					DatabaseMetadata metadata = new DatabaseMetadata(con, dialect);
					String[] sql = getConfiguration().generateSchemaUpdateScript(dialect, metadata);
					executeSchemaScript(con, sql);
					return null;
				}
			}
		);
	}
	finally {
		if (dataSource != null) {
			configTimeDataSourceHolder.remove();
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:LocalSessionFactoryBean.java

示例2: dropDatabaseSchema

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
/**
 * Execute schema drop script, determined by the Configuration object
 * used for creating the SessionFactory. A replacement for Hibernate's
 * SchemaExport class, to be invoked on application setup.
 * <p>Fetch the LocalSessionFactoryBean itself rather than the exposed
 * SessionFactory to be able to invoke this method, e.g. via
 * {@code LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean) ctx.getBean("&mySessionFactory");}.
 * <p>Uses the SessionFactory that this bean generates for accessing a
 * JDBC connection to perform the script.
 * @throws org.springframework.dao.DataAccessException in case of script execution errors
 * @see org.hibernate.cfg.Configuration#generateDropSchemaScript
 * @see org.hibernate.tool.hbm2ddl.SchemaExport#drop
 */
public void dropDatabaseSchema() throws DataAccessException {
	logger.info("Dropping database schema for Hibernate SessionFactory");
	SessionFactory sessionFactory = getSessionFactory();
	final Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect();
	HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
	hibernateTemplate.execute(
		new HibernateCallback<Object>() {
			@Override
			public Object doInHibernate(Session session) throws HibernateException, SQLException {
				@SuppressWarnings("deprecation")
				Connection con = session.connection();
				String[] sql = getConfiguration().generateDropSchemaScript(dialect);
				executeSchemaScript(con, sql);
				return null;
			}
		}
	);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:LocalSessionFactoryBean.java

示例3: render

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) {
    // 1 arguments is the date field to use
    if (arguments.size() != 2) {
        throw new QueryException(
                "Need exactly two arguments for day of date function, but got only "
                        + arguments.size()
                        + " args=" + arguments);
    }
    DateField dateField;
    try {
        dateField = DateField.valueOf(arguments.get(0).toString());
    } catch (Exception e) {
        throw new QueryException(
                "Invalid datefield used: " + arguments.get(0) + ". " + e.getMessage(), e);
    }

    String sql = "date_part('" + dateField + "'," + arguments.get(1) + ")";
    return sql;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:24,代码来源:PostgreSQLDatePartFunction.java

示例4: render

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) {
    // 2 arguments without locale, 3 with locale; however locale not used
    if (arguments.size() < 2 || arguments.size() > 3) {
        throw new QueryException("Need 2 or 3 arguments for fulltext function, but got only "
                + arguments.size() + " args=" + arguments);
    }

    // see KENMEI-4643 for details why this way complicated
    // see KENMEI-4678 why to uses simple as default
    String sql = "to_tsvector(" + textSearchConfigurationNameQueryPart + ", "
            + arguments.get(0) + ") @@ tsquery(plainto_tsquery("
            + textSearchConfigurationNameQueryPart + ", " + arguments.get(1)
            + ") :: varchar || ':*')";
    return sql;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:20,代码来源:PostgreSQLFulltextFunction.java

示例5: getQueryableCollection

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
protected QueryableCollection getQueryableCollection(String entityName, String propertyName, SessionFactoryImplementor factory)
        throws HibernateException {
	PropertyMapping ownerMapping = ( PropertyMapping ) factory.getEntityPersister( entityName );
	Type type = ownerMapping.toType( propertyName );
	if ( !type.isCollectionType() ) {
		throw new MappingException(
		        "Property path [" + entityName + "." + propertyName + "] does not reference a collection"
		);
	}

	String role = ( ( CollectionType ) type ).getRole();
	try {
		return ( QueryableCollection ) factory.getCollectionPersister( role );
	}
	catch ( ClassCastException cce ) {
		throw new QueryException( "collection role is not queryable: " + role );
	}
	catch ( Exception e ) {
		throw new QueryException( "collection role not found: " + role );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:AbstractEmptinessExpression.java

示例6: getListaFile

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public StreamedContent getListaFile() {
    try {
        if(turma == null){
            addMessage(getSeverityWarn(),"Por favor selecione a turma!");
            return null;
        }
        InputStream inputStream = getClass().getResourceAsStream("/br/edu/ifnmg/ifad/report/lista_ata_assinatura.jrxml");
        HashMap<String, Object> map  = new HashMap<String, Object>();
        map.put("COD_TURMA", turma.getId());
        SessionFactoryImplementor factoryImplementor = (SessionFactoryImplementor) HibernateUtil.getSessionFactory();
        map.put("REPORT_CONNECTION",factoryImplementor.getConnectionProvider().getConnection());
        StringBuilder nome = new StringBuilder("lista_ata_");
        nome.append(turma.getNome().replaceAll(" ", "_"));
        nome.append(".pdf");
        StreamedContent streamedContent = new DefaultStreamedContent(new ByteArrayInputStream(ReportUtil.reportToPDF(null, inputStream, map)), "application/pdf", nome.toString());
        return streamedContent;
    } catch (Exception ex) {
        addMessage(getSeverityError(),"Erro ao emitir arquivo com senhas! Detalhes: "+ex.getMessage());
        Logger.getLogger(EmissaoReportsBean.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:dsalinux,项目名称:web-ifad,代码行数:23,代码来源:EmissaoReportsBean.java

示例7: getAssociatedEntityName

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public String getAssociatedEntityName(SessionFactoryImplementor factory)
		throws MappingException {
	try {
		
		QueryableCollection collectionPersister = (QueryableCollection) factory
				.getCollectionPersister( role );
		
		if ( !collectionPersister.getElementType().isEntityType() ) {
			throw new MappingException( 
					"collection was not an association: " + 
					collectionPersister.getRole() 
				);
		}
		
		return collectionPersister.getElementPersister().getEntityName();
		
	}
	catch (ClassCastException cce) {
		throw new MappingException( "collection role is not queryable " + role );
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:CollectionType.java

示例8: set

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public void set(Object target, Object value, SessionFactoryImplementor factory) 
throws HibernateException {
	Element owner = ( Element ) target;
	Element element = owner.element(elementName);
	if (value==null) {
		if (element!=null) element.detach();
	}
	else {
		Attribute attribute;
		if (element==null) {
			element = owner.addElement(elementName);
			attribute = null;
		}
		else {
			attribute = element.attribute(attributeName);
		}
		
		if (attribute==null) {
			element.addAttribute(attributeName, "null");
			attribute = element.attribute(attributeName);
		}				
		super.propertyType.setToXMLNode(attribute, value, factory);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:25,代码来源:Dom4jAccessor.java

示例9: getFichaAvaliacaoDocenteFile

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public StreamedContent getFichaAvaliacaoDocenteFile() {
    try {
        InputStream inputStream = getClass().getResourceAsStream("/br/edu/ifnmg/ifad/report/ficha_avaliacao_docente.jrxml");
        HashMap<String, Object> map  = new HashMap<String, Object>();
        InputStream isSubReport = getClass().getResourceAsStream("/br/edu/ifnmg/ifad/report/media_respostas_avaliadas_subreport.jrxml");
        map.put("SUBREPORT_DIR", ReportUtil.compileReport(isSubReport));
        SessionFactoryImplementor factoryImplementor = (SessionFactoryImplementor) HibernateUtil.getSessionFactory();
        map.put("REPORT_CONNECTION",factoryImplementor.getConnectionProvider().getConnection());
        StringBuilder nome = new StringBuilder("ficha_avaliacao_docente_");
        nome.append(new SimpleDateFormat("yyyy_MM_dd").format(new Date()));
        nome.append(".pdf");
        StreamedContent streamedContent = new DefaultStreamedContent(new ByteArrayInputStream(ReportUtil.reportToPDF(null, inputStream, map)), "application/pdf", nome.toString());
        return streamedContent;
    } catch (Exception ex) {
        addMessage(getSeverityError(),"Erro ao emitir arquivo com senhas! Detalhes: "+ex.getMessage());
        Logger.getLogger(EmissaoReportsBean.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:dsalinux,项目名称:web-ifad,代码行数:20,代码来源:EmissaoReportsBean.java

示例10: JoinEntityLoader

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
JoinEntityLoader(
		org.hibernate.persister.entity.OuterJoinLoadable persister,
		int batchSize,
		LockMode lockMode,
		SessionFactoryImplementor factory,
		LoadQueryInfluencers loadQueryInfluencers, java.util.List<String> joins) throws MappingException {
	this(
			persister,
			persister.getIdentifierColumnNames(),
			persister.getIdentifierType(),
			batchSize,
			lockMode,
			factory,
			loadQueryInfluencers,
			joins
		);
}
 
开发者ID:webdsl,项目名称:webdsl,代码行数:18,代码来源:SingleTableEntityPersister.java

示例11: OneToManyLoader

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public OneToManyLoader(
		QueryableCollection oneToManyPersister, 
		int batchSize, 
		String subquery, 
		SessionFactoryImplementor factory, 
		Map enabledFilters)
throws MappingException {

	super(oneToManyPersister, factory, enabledFilters);
	
	JoinWalker walker = new OneToManyJoinWalker(
			oneToManyPersister, 
			batchSize, 
			subquery, 
			factory, 
			enabledFilters
		);
	initFromWalker( walker );

	postInstantiate();

	log.debug( "Static select for one-to-many " + oneToManyPersister.getRole() + ": " + getSQLString() );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:24,代码来源:OneToManyLoader.java

示例12: isEqual

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public boolean isEqual(Object x, Object y, EntityMode entityMode, SessionFactoryImplementor factory)
		throws HibernateException {
	if ( x == y ) {
		return true;
	}
	if ( x == null || y == null ) {
		return false;
	}
	Object[] xvalues = getPropertyValues( x, entityMode );
	Object[] yvalues = getPropertyValues( y, entityMode );
	for ( int i = 0; i < propertySpan; i++ ) {
		if ( !propertyTypes[i].isEqual( xvalues[i], yvalues[i], entityMode, factory ) ) {
			return false;
		}
	}
	return true;
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:ComponentType.java

示例13: runClassicTranslator

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
protected void runClassicTranslator(String hql) throws Exception {
	SessionFactoryImplementor factory = getSessionFactoryImplementor();
	Map replacements = new HashMap();
	QueryTranslator oldQueryTranslator = null;
	try {
		QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
		oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
		oldQueryTranslator.compile( replacements, false );
	}
	catch ( Exception e ) {
		e.printStackTrace();
		throw e;
	}
	String oldsql = oldQueryTranslator.getSQLString();
	System.out.println( "HQL    : " + hql );
	System.out.println( "OLD SQL: " + oldsql );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:QueryTranslatorTestCase.java

示例14: createBatchingOneToManyInitializer

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public static CollectionInitializer createBatchingOneToManyInitializer(
	final QueryableCollection persister,
	final int maxBatchSize,
	final SessionFactoryImplementor factory,
	final Map enabledFilters)
throws MappingException {

	if ( maxBatchSize>1 ) {
		int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize);
		Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
		for ( int i=0; i<batchSizesToCreate.length; i++ ) {
			loadersToCreate[i] = new OneToManyLoader(persister, batchSizesToCreate[i], factory, enabledFilters);
		}
		return new BatchingCollectionInitializer(persister, batchSizesToCreate, loadersToCreate);
	}
	else {
		return new OneToManyLoader(persister, factory, enabledFilters);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:BatchingCollectionInitializer.java

示例15: createBatchingCollectionInitializer

import org.hibernate.engine.SessionFactoryImplementor; //导入依赖的package包/类
public static CollectionInitializer createBatchingCollectionInitializer(
	final QueryableCollection persister,
	final int maxBatchSize,
	final SessionFactoryImplementor factory,
	final Map enabledFilters)
throws MappingException {

	if ( maxBatchSize>1 ) {
		int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize);
		Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
		for ( int i=0; i<batchSizesToCreate.length; i++ ) {
			loadersToCreate[i] = new BasicCollectionLoader(persister, batchSizesToCreate[i], factory, enabledFilters);
		}
		return new BatchingCollectionInitializer(persister, batchSizesToCreate, loadersToCreate);
	}
	else {
		return new BasicCollectionLoader(persister, factory, enabledFilters);
	}
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:BatchingCollectionInitializer.java


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