[hibernate-issues] [Hibernate-JIRA] Created: (HHH-6590) Allow for exclusion of persisted classes by package in metamodel
Robert Brady (JIRA)
noreply at atlassian.com
Fri Aug 19 12:28:02 EDT 2011
Allow for exclusion of persisted classes by package in metamodel
----------------------------------------------------------------
Key: HHH-6590
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6590
Project: Hibernate Core
Issue Type: Improvement
Components: entity-manager
Affects Versions: 3.5.5
Environment: Hibernate 3.5.5, PostgreSQL 8.4
Reporter: Robert Brady
This improvement would work around the need for "any" mapping support as given in HHH-6589.
I am upgrading from Hibernate 3.2.x to 3.5.5 and getting UnsupportedOperationExceptions thrown when Hibernate is trying to create the metamodel. This is due to the dependency of my application upon jBPM 3.x, which uses "any" mappings for some of its classes.
If Hibernate can not support "any" mappings then it could workaround this limitation by allowing for the exclusion of persistent classes by package name. For example, in my application I have no need for the metamodel to include the jBPM classes (don't need criteria api to be applied to them). These classes contain "any" mappings that break the generation of the metamodel. The metamodel boundaries could be cleanly set if all the jBPM classes (packages org.jbpm.*) were excluded from the generation of the metamodel. This could be done like so in org.hibernate.ejb.EntityManagerFactoryImpl constructor:
{noFormat}
...
List<PersistentClass> persistentClasses = new ArrayList<PersistentClass>();
while (classes.hasNext()) {
PersistentClass persistentClass = classes.next();
// Hardcode jBPM classes for now, but make tidy with a property like "hibernate.ejb.metamodel.excluded.pkgs"
if (persistentClass.getClassName().startsWith("org.jbpm")) {
continue;
} else {
persistentClasses.add(persistentClass);
}
}
// a safe guard till we are confident that metamodel is wll tested
if (!"disabled".equalsIgnoreCase(cfg.getProperty("hibernate.ejb.metamodel.generation"))) {
this.metamodel = MetamodelImpl.buildMetamodel(persistentClasses.iterator(),
(SessionFactoryImplementor) sessionFactory);}
...
{noFormat}
A configuration list property with items being the package root names to exclude should work.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list