001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.orm.jpa; 018 019import javax.persistence.EntityManager; 020import javax.persistence.EntityManagerFactory; 021import javax.persistence.spi.PersistenceProvider; 022import javax.persistence.spi.PersistenceUnitInfo; 023import javax.sql.DataSource; 024 025/** 026 * Metadata interface for a Spring-managed JPA {@link EntityManagerFactory}. 027 * 028 * <p>This facility can be obtained from Spring-managed EntityManagerFactory 029 * proxies through casting the EntityManagerFactory handle to this interface. 030 * 031 * @author Rod Johnson 032 * @author Juergen Hoeller 033 * @since 2.0 034 */ 035public interface EntityManagerFactoryInfo { 036 037 /** 038 * Return the raw underlying EntityManagerFactory. 039 * @return the unadorned EntityManagerFactory (never {@code null}) 040 */ 041 EntityManagerFactory getNativeEntityManagerFactory(); 042 043 /** 044 * Return the underlying PersistenceProvider that the underlying 045 * EntityManagerFactory was created with. 046 * @return the PersistenceProvider used to create this EntityManagerFactory, 047 * or {@code null} if the standard JPA provider autodetection process 048 * was used to configure the EntityManagerFactory 049 */ 050 PersistenceProvider getPersistenceProvider(); 051 052 /** 053 * Return the PersistenceUnitInfo used to create this 054 * EntityManagerFactory, if the in-container API was used. 055 * @return the PersistenceUnitInfo used to create this EntityManagerFactory, 056 * or {@code null} if the in-container contract was not used to 057 * configure the EntityManagerFactory 058 */ 059 PersistenceUnitInfo getPersistenceUnitInfo(); 060 061 /** 062 * Return the name of the persistence unit used to create this 063 * EntityManagerFactory, or {@code null} if it is an unnamed default. 064 * <p>If {@code getPersistenceUnitInfo()} returns non-null, the result of 065 * {@code getPersistenceUnitName()} must be equal to the value returned by 066 * {@code PersistenceUnitInfo.getPersistenceUnitName()}. 067 * @see #getPersistenceUnitInfo() 068 * @see javax.persistence.spi.PersistenceUnitInfo#getPersistenceUnitName() 069 */ 070 String getPersistenceUnitName(); 071 072 /** 073 * Return the JDBC DataSource that this EntityManagerFactory 074 * obtains its JDBC Connections from. 075 * @return the JDBC DataSource, or {@code null} if not known 076 */ 077 DataSource getDataSource(); 078 079 /** 080 * Return the (potentially vendor-specific) EntityManager interface 081 * that this factory's EntityManagers will implement. 082 * <p>A {@code null} return value suggests that autodetection is supposed 083 * to happen: either based on a target {@code EntityManager} instance 084 * or simply defaulting to {@code javax.persistence.EntityManager}. 085 */ 086 Class<? extends EntityManager> getEntityManagerInterface(); 087 088 /** 089 * Return the vendor-specific JpaDialect implementation for this 090 * EntityManagerFactory, or {@code null} if not known. 091 */ 092 JpaDialect getJpaDialect(); 093 094 /** 095 * Return the ClassLoader that the application's beans are loaded with. 096 * <p>Proxies will be generated in this ClassLoader. 097 */ 098 ClassLoader getBeanClassLoader(); 099 100}