[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-3381) Make org.hibernate.cfg.Configuration.typeDefs accessible
Gail Badner (JIRA)
noreply at atlassian.com
Fri Jul 11 17:43:12 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3381?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gail Badner updated HHH-3381:
-----------------------------
Summary: Make org.hibernate.cfg.Configuration.typeDefs accessible (was: org.lds.stack.validator.NotEmptyTrimed is mispelled)
> Make org.hibernate.cfg.Configuration.typeDefs accessible
> --------------------------------------------------------
>
> Key: HHH-3381
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3381
> Project: Hibernate3
> Issue Type: Improvement
> Reporter: Mike Heath
> Attachments: configuration.patch, hibernatepersistence.patch
>
>
> In our applications, we would like to make the "yes_no" Hibernate type the default for all booleans. We currently use @Type("yes_no") everywhere. This is annoying.
> We could use org.hibernate.cfg.Mappings.typeDefs to set a default. Mappings.typeDefs gets populated from org.hibernate.cfg.Configuration.typeDefs. However, Configuration.typeDefs only gets referenced by Configuration.reset(), Configuration.createMappings(), and AnnotationConfiguration.createExtendedMappings(). Configuration.typeDefs could be very useful but currently it's a waste of an object reference.
> Adding the following method (or something similar) to Configuration would give us a good first step to making they typeDefs field usable and would open the door to allowing us to make "yes_no" the default for all boolean fields:
> public void addTypeDef(String className, TypeDef typeDef) {
> typeDefs.put(className, typeDef)
> }
> Even if we had Configuration.addTypeDef, there would be now way to add a TypeDef to the configuration before the EntityManagerFactory gets created. org.hibernate.ejb.HibernatePersistence creates an Ejb3Configuration object (which holds a Configuration instance) and immediately creates the EntityManagerFactory. If the call to "new Ejb3Configuration()" were placed in a protected method, we could override that method and there obtain the Configuration instance and invoke addTypeDef().
> We currently have our own PersistenceProvider that is based on HibernatePersistence. After we create the Ejb3Configuration instance, we use reflection to get to Configure.typeDefs to add "yes_no" TypeDefs for "boolean" and "java.lang.Boolean" and it works very well... except for the fact that it's an egregious hack.
> I've attached a patch for core, and a patch for entitymanager.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list