Skip to content

Impossible to customise Hibernate RegionFactory [SPR-11056] #15683

Closed
@spring-projects-issues

Description

@spring-projects-issues

nigel magnay opened SPR-11056 and commented

This is really painful.

If you want to create Hibernate Session Factories with a cache object (and not through a brain-damaged class-name property string - you know, because it might be a bean with @Inject dependencies), it's impossible to do so.

What you'd like to be able to do some sort of customisation of the Configuration through LocalSessionFactoryBuilder. E.g:

class MyLocalSessionFactoryBuilder extends LocalSessionFactoryBuilder {

@Override
public Settings buildSettings(ServiceRegistry serviceRegistry) {

Settings settings = super.buildSettings(serviceRegistry);
settings.setRegionFactory ( /* whatever I like */
// possibly other settings

return settings;
}

Sounds good. But LocalSessionFactoryBean itself is manufactured, in one class only, in line LocalSessionFactoryBean:277.

Overriding 372 looks promising :
protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) {
return sfb.buildSessionFactory();
}

But by this point it's too late. I can't even override afterPropertiesSet, as every member varible is private rather than protected.

All I can do is clone the entire class, simply to create a different subclass in Line 278.

If this were configurable (I.E: the localsessionfactorybuilder was a property that could be passed in) this would be way more usable.


Affects: 3.2.4

Issue Links:

Referenced from: commits 00474ce

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions