|
Hibernate example source code file (EntityManagerFactoryImpl.java)
The Hibernate EntityManagerFactoryImpl.java source code/* * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Middleware LLC. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ package org.hibernate.ejb; import javax.persistence.Cache; import javax.persistence.EntityManager; import javax.persistence.PersistenceContextType; import javax.persistence.PersistenceUnitUtil; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.metamodel.Metamodel; import javax.persistence.spi.LoadState; import javax.persistence.spi.PersistenceUnitTransactionType; import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; import org.hibernate.Hibernate; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.ejb.criteria.CriteriaBuilderImpl; import org.hibernate.ejb.metamodel.MetamodelImpl; import org.hibernate.ejb.util.PersistenceUtilHelper; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.mapping.PersistentClass; import org.hibernate.metadata.ClassMetadata; import org.hibernate.service.ServiceRegistry; /** * Actual Hiberate implementation of {@link javax.persistence.EntityManagerFactory}. * * @author Gavin King * @author Emmanuel Bernard * @author Steve Ebersole */ public class EntityManagerFactoryImpl implements HibernateEntityManagerFactory { private final SessionFactory sessionFactory; private final PersistenceUnitTransactionType transactionType; private final boolean discardOnClose; private final Class sessionInterceptorClass; private final CriteriaBuilderImpl criteriaBuilder; private final Metamodel metamodel; private final HibernatePersistenceUnitUtil util; private final Map<String,Object> properties; private final PersistenceUtilHelper.MetadataCache cache = new PersistenceUtilHelper.MetadataCache(); @SuppressWarnings( "unchecked" ) public EntityManagerFactoryImpl( PersistenceUnitTransactionType transactionType, boolean discardOnClose, Class sessionInterceptorClass, Configuration cfg, ServiceRegistry serviceRegistry) { this.sessionFactory = cfg.buildSessionFactory( serviceRegistry ); this.transactionType = transactionType; this.discardOnClose = discardOnClose; this.sessionInterceptorClass = sessionInterceptorClass; final Iterator<PersistentClass> classes = cfg.getClassMappings(); //a safe guard till we are confident that metamodel is wll tested if ( !"disabled".equalsIgnoreCase( cfg.getProperty( "hibernate.ejb.metamodel.generation" ) ) ) { this.metamodel = MetamodelImpl.buildMetamodel( classes, ( SessionFactoryImplementor ) sessionFactory ); } else { this.metamodel = null; } this.criteriaBuilder = new CriteriaBuilderImpl( this ); this.util = new HibernatePersistenceUnitUtil( this ); HashMap<String,Object> props = new HashMap Other Hibernate examples (source code examples)Here is a short list of links related to this Hibernate EntityManagerFactoryImpl.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.