Class ORMConfigDto
java.lang.Object
org.broadleafcommerce.common.extensibility.jpa.ORMConfigDto
- All Implemented Interfaces:
Serializable
Holder for mapping files (orm.xml) and entity classes to be contributed to the MergePersistenceUnitManager
without being specified directly
in a persistence.xml file. Use cases this is designed to support:
- Prividing a fully-qualified-classname to add to the managed classes of the persistence unit (like an additional @Entity class)
- Providing a classpath-relative location to an orm.xml file to add to the mapping files for additional queries
Generally, this will be registered conditionally within an @Conditional. Example:
@Bean @ConditionalOnClass("com.broadleafcommerce.somemodule.domain.DomainClass") public ORMConfigDto newManagedDomainClass() { return new ORMConfigDto("blPU") .addClassName("com.broadleafcommerce.somemodule.domain.DomainClass"); }
Note that this functionality can also be achieved by creating multiple persistence.xml
files and conditionally adding it to
blMergedPersistenceXmlLocations
like so:
@Merge("blMergedPersistenceXmlLocations") @ConditionalOnClass("com.broadleafcommerce.somemodule.domain.DomainClass") public ORMConfigDto newManagedDomainClass() { return Arrays.asList("persistence-domainclass.xml"); }
This can be attractive if you have a large set of classes or mapping files to dynamically add to a persistence unit.
- Author:
- Nick Crum ncrum, Phillip Verheyden (phillipuniverse)
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddClassName
(String className) Adds the given class name o the persistence unit.addMappingFile
(String mappingFile) Adds the given mapping file to the persistence unitsetClassNames
(List<String> classNames) setMappingFiles
(List<String> mappingFiles)
-
Field Details
-
puName
-
classNames
-
mappingFiles
-
-
Constructor Details
-
ORMConfigDto
- Parameters:
puName
- the persistence unit that this should be apart of (usually"blPU"
-
-
Method Details
-
getPuName
- Returns:
- the persistence unit that this should be apart of
-
addClassName
Adds the given class name o the persistence unit. Note that this should generally not reference the class name byDomainClass.class.getName()
. Doing so will trigger the class to be loaded which can cause it to skip class transformation- Parameters:
className
- a fully-qualfied classname that should be added to this persistence unit's managed classes. This is equivalent to specifying an additional<class></class>
entry in apersistence.xml
- Returns:
this
-
getClassNames
-
setClassNames
- See Also:
-
addMappingFile
Adds the given mapping file to the persistence unit- Parameters:
mappingFile
- a classpath-relative location to a .orm.xml file that contains additional HQL queries or other XML configuration. This is equivalent to using the<mapping-file></mapping-file>
entry in a persistence.xml- Returns:
this
-
getMappingFiles
-
setMappingFiles
- See Also:
-