Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to add hibernate type definitions to a LocalSessionFactoryBean [SPR-885] #5612

Closed
spring-projects-issues opened this issue Apr 18, 2005 · 11 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

matthew inger opened SPR-885 and commented

There is currently no way to add a TypeDef instance to a LocalSessionFactory bean. I am including a patch which will allow the addition of TypeDef objects. There will be a "typeDefinitions"
property on the LocalSessionFactoryBean:

public void setTypeDefinitions(TypeDefinitionBean typeDefinitions[]);

The "TypeDefinitionBean" class contains the name, type class, and parameters for the type definition:

<bean class="org.springframework.orm.hibernate3.TypeDefinitionBean">
<property name="name"><value>myType</value></property>
<property name="typeClass"><value>MyTypeFQCN</value></property>
</bean>


Affects: 1.2 RC2

Attachments:

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

Patch for LocalSessionFactoryBean to add the TypeDef objects.

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

TypeDefinitionBean which holds type type name, type class, and parameters for a type definition.

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

Newer version. The "typeClass" on TypeDefinitionBean is now a string.

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

Change "typeClass" to a string

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

Use attachments #2 & #4

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

fixed one issue

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

make that #3 & #5

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I'm reluctant to add this to LocalSessionFactoryBean. Typedefs are usually defined in Hibernate mapping files, not in the Hibernate configuration file. But LocalSessionFactoryBean's local properties are mainly intended as replacement for "hibernate.cfg.xml"...

Wouldn't it be good enough to define the typedefs with the standard Hibernate <typedef> tag in some core mapping file of your application?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

On the contrary, I think typedef makes more sense in the
hibernate.cfg.xml than anywhere else. the reason for a typedef is to have a type that is globally available. Given this, having it in a mapping file makes no sense to me, as it forces that mapping file to be loaded before all other mapping files which use that typedef.
Hence, it makes more sense to me that typedefs be in the session factory bean.

@spring-projects-issues
Copy link
Collaborator Author

matthew inger commented

PS: I realize that hibernate itself doesn't allow the "typedef"
element in the hibernate.cfg.xml, but I view that as an oversight, and I see no reason why Spring can't provide something that would
indeed be very useful to the user.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

OK, I agree that it makes sense to specify those at the SessionFactory level. Effectively, this is the same issue as with filter definitions, which we already support at the SessionFactory level too.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants