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 025import org.springframework.lang.Nullable; 026 027/** 028 * Metadata interface for a Spring-managed JPA {@link EntityManagerFactory}. 029 * 030 * <p>This facility can be obtained from Spring-managed EntityManagerFactory 031 * proxies through casting the EntityManagerFactory handle to this interface. 032 * 033 * @author Rod Johnson 034 * @author Juergen Hoeller 035 * @since 2.0 036 */ 037public interface EntityManagerFactoryInfo { 038 039 /** 040 * Return the raw underlying EntityManagerFactory. 041 * @return the unadorned EntityManagerFactory (never {@code null}) 042 */ 043 EntityManagerFactory getNativeEntityManagerFactory(); 044 045 /** 046 * Return the underlying PersistenceProvider that the underlying 047 * EntityManagerFactory was created with. 048 * @return the PersistenceProvider used to create this EntityManagerFactory, 049 * or {@code null} if the standard JPA provider autodetection process 050 * was used to configure the EntityManagerFactory 051 */ 052 @Nullable 053 PersistenceProvider getPersistenceProvider(); 054 055 /** 056 * Return the PersistenceUnitInfo used to create this 057 * EntityManagerFactory, if the in-container API was used. 058 * @return the PersistenceUnitInfo used to create this EntityManagerFactory, 059 * or {@code null} if the in-container contract was not used to 060 * configure the EntityManagerFactory 061 */ 062 @Nullable 063 PersistenceUnitInfo getPersistenceUnitInfo(); 064 065 /** 066 * Return the name of the persistence unit used to create this 067 * EntityManagerFactory, or {@code null} if it is an unnamed default. 068 * <p>If {@code getPersistenceUnitInfo()} returns non-null, the result of 069 * {@code getPersistenceUnitName()} must be equal to the value returned by 070 * {@code PersistenceUnitInfo.getPersistenceUnitName()}. 071 * @see #getPersistenceUnitInfo() 072 * @see javax.persistence.spi.PersistenceUnitInfo#getPersistenceUnitName() 073 */ 074 @Nullable 075 String getPersistenceUnitName(); 076 077 /** 078 * Return the JDBC DataSource that this EntityManagerFactory 079 * obtains its JDBC Connections from. 080 * @return the JDBC DataSource, or {@code null} if not known 081 */ 082 @Nullable 083 DataSource getDataSource(); 084 085 /** 086 * Return the (potentially vendor-specific) EntityManager interface 087 * that this factory's EntityManagers will implement. 088 * <p>A {@code null} return value suggests that autodetection is supposed 089 * to happen: either based on a target {@code EntityManager} instance 090 * or simply defaulting to {@code javax.persistence.EntityManager}. 091 */ 092 @Nullable 093 Class<? extends EntityManager> getEntityManagerInterface(); 094 095 /** 096 * Return the vendor-specific JpaDialect implementation for this 097 * EntityManagerFactory, or {@code null} if not known. 098 */ 099 @Nullable 100 JpaDialect getJpaDialect(); 101 102 /** 103 * Return the ClassLoader that the application's beans are loaded with. 104 * <p>Proxies will be generated in this ClassLoader. 105 */ 106 ClassLoader getBeanClassLoader(); 107 108}