Service Registry in Hibernate -


i see since hibernate 4 in order session factory configuration need make use of serviceregistry.

configuration configuration = new configuration().configure(); serviceregistry serviceregistry = new standardserviceregistrybuilder().applysettings(configuration.getproperties()).build(); sessionfactory factory = configuration.buildsessionfactory(serviceregistry); 

what's purpose of serviceregistry. why required?

they have redesigned sessionfactory pass argument serviceregistry object. explanation there in jira ticket.

currently sessionfactory built throwing bunch of stuff configuration object, stirring it, letting come boil, , pulling out sessionfactory. in seriousness, there few problems way operate within configuration , how use build sessionfactory:

the general issue there no "lifecycle" when various pieces of information available. important omission in number of ways:

1) consider schema generation. cannot know dialect when lot of db object names being determined. nice because allow transparently handle table/column names keywords/reserved-words in dialect, example.

2) static-ness of types , type-mappings. because have nothing scope them. ideally type instance aware of sessionfactory bound. instead, have change api methods quite lot of time add in sessionfactory passed parameter whenever discovered needed.

3) also, (all?) of "static" configuration parameters in hibernate required because of use within these static types; scoping types allow scope config parameters (things bytecode-provider, use of binary streams, etc).

ideally see happening scheme users build org.hibernate.cfg.settings (or similiar) instance themselves. additionally apply metadata registry of sort (lets call metadataregistry now). in order build sessionfactory, supply these 2 pieces of information (via ctor? via builder?). important aspect though information in metadataregistry not dealt until point in time, allow guarentee resolving schema object names, types, etc have access runtime settings (and dialect)

link ticket


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -