Package org.springframework.boot.orm.jpa
Class EntityManagerFactoryBuilder.Builder
- java.lang.Object
- org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.Builder
- Enclosing class:
- EntityManagerFactoryBuilder
public final class EntityManagerFactoryBuilder.Builder extends Object
A fluent builder for a LocalContainerEntityManagerFactoryBean.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
build()
EntityManagerFactoryBuilder.Builder
jta(boolean jta)
Configure if using a JTADataSource
, i.e.EntityManagerFactoryBuilder.Builder
mappingResources(String... mappingResources)
The mapping resources (equivalent to<mapping-file>
entries inpersistence.xml
) for the persistence unit.EntityManagerFactoryBuilder.Builder
packages(Class<?>... basePackageClasses)
The classes whose packages should be scanned for@Entity
annotations.EntityManagerFactoryBuilder.Builder
packages(String... packagesToScan)
The names of packages to scan for@Entity
annotations.EntityManagerFactoryBuilder.Builder
persistenceUnit(String persistenceUnit)
The name of the persistence unit.EntityManagerFactoryBuilder.Builder
properties(Map<String,?> properties)
Generic properties for standard JPA or vendor-specific configuration.
Method Detail
packages
public EntityManagerFactoryBuilder.Builder packages(String... packagesToScan)
The names of packages to scan for@Entity
annotations.- Parameters:
packagesToScan
- packages to scan- Returns:
- the builder for fluent usage
packages
public EntityManagerFactoryBuilder.Builder packages(Class<?>... basePackageClasses)
The classes whose packages should be scanned for@Entity
annotations.- Parameters:
basePackageClasses
- the classes to use- Returns:
- the builder for fluent usage
persistenceUnit
public EntityManagerFactoryBuilder.Builder persistenceUnit(String persistenceUnit)
The name of the persistence unit. If only building one EntityManagerFactory you can omit this, but if there are more than one in the same application you should give them distinct names.- Parameters:
persistenceUnit
- the name of the persistence unit- Returns:
- the builder for fluent usage
properties
public EntityManagerFactoryBuilder.Builder properties(Map<String,?> properties)
Generic properties for standard JPA or vendor-specific configuration. These properties override any values provided in the constructor.- Parameters:
properties
- the properties to use- Returns:
- the builder for fluent usage
mappingResources
public EntityManagerFactoryBuilder.Builder mappingResources(String... mappingResources)
The mapping resources (equivalent to<mapping-file>
entries inpersistence.xml
) for the persistence unit.Note that mapping resources must be relative to the classpath root, e.g. "META-INF/mappings.xml" or "com/mycompany/repository/mappings.xml", so that they can be loaded through
ClassLoader.getResource()
.- Parameters:
mappingResources
- the mapping resources to use- Returns:
- the builder for fluent usage
jta
public EntityManagerFactoryBuilder.Builder jta(boolean jta)
Configure if using a JTADataSource
, i.e. ifsetDataSource
orsetJtaDataSource
should be called on theLocalContainerEntityManagerFactoryBean
.- Parameters:
jta
- if the data source is JTA- Returns:
- the builder for fluent usage
build
public org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean build()