There are two methods:
getDataSourceConfigFromJPAClass(String className)
- generates configuration for JPA 1.0 data source. Processes only annotated classes (does not support entity mapping specified in external XML file). Class has to be annotated with one of these annotations: Entity, MappedSuperclass, Embeddable. generateFromPersistenceUnit (String persistenceUnitName)
- generates configuration for JPA 2.0 data source for all entities mapped in specified persistence unit. This method requires JPA 2.0. Make sure you use JPA provider with JPA 2.0 implementation.dsTypeForJavaType
method description for supported types. Modifier and Type | Method and Description |
---|---|
static java.util.Map | generateFromPersistenceUnit(java.lang.String persistenceUnitName) Generates data source configurations for all entities mapped in specified persistent unit. Works only with JPA 2.0 implementation. |
static java.util.Map | getDataSourceConfigFromMetamodel(java.lang.String className, javax.persistence.EntityManager em) Returns data source configuration for specified class. Plural fields (one-to-many relations) will be generated. Works only with JPA 2.0 implementation. |
static java.util.Map | getDataSourceConfigFromMetamodel(java.lang.String className, javax.persistence.EntityManager em, boolean generateRelations, boolean extended) Returns data source configuration for specified class. Works only with JPA 2.0 implementation. |
public static java.util.Map generateFromPersistenceUnit(java.lang.String persistenceUnitName) throws java.lang.Exception
persistenceUnitName
- String
Name of persistence unit to be inspected.Map<String, Map<String, Object>>
key is data source id; value is complete data source configuration.java.lang.Exception
- when this feature is not available.public static java.util.Map getDataSourceConfigFromMetamodel(java.lang.String className, javax.persistence.EntityManager em) throws java.lang.Exception
className
- String
Name of the class.em
- EntityManager
with JPA2 meta-model.Map<String, Object>
data source configuration for specified class.java.lang.Exception
- when this feature is not available or generation failed.public static java.util.Map getDataSourceConfigFromMetamodel(java.lang.String className, javax.persistence.EntityManager em, boolean generateRelations, boolean extended) throws java.lang.Exception
className
- String
Name of the class.em
- EntityManager
with JPA2 meta-model.generateRelations
- boolean
true
- relation fields will be generated; false
- relation fields will be skipped.extended
- boolean
Extended properties will be captured if set to true
.Map<String, Object>
data source configuration for specified class.java.lang.Exception
- when this feature is not available or generation failed.