java - How to use Integrator service in Hibernate 5 for adding annotated classes -
this reference jpa 2.0: adding entity classes persistenceunit *from different jar* automatically , unable call hibernate/querydsl maven subproject
it seems hibernate 4 had great way dynamically load entity classes using org.hibernate.integrator.spi.integrator service.
now when using hibernate 5, integrator interface's integrate method gives me
public void integrate(metadata metadata, sessionfactoryimplementor sessionfactory, sessionfactoryserviceregistry serviceregistry) { }
where metadata of type org.hibernate.boot.metadata
i unable call addannotatedclass(), neither able obtain original configuration object there in hibernate 4.
how around this?
i using maven , jetty.
i not using spring (so please not provide spring based solution)
this related wrestling on weekend in getting caught on hibernate 5. can read planned changes related configuration
class in latest javadoc hibernate 4. new place getting info on loaded entity classes including annotated entities metadata
class mentioned. has getentitybindings()
method return persistentclass
entity metadata representation known entities. collection
immutable however.
recommendation rethink using integrator
add entity bindings @ runtime. may have worked in past, docs point towards not being intentional should done @ time of initialization. metadata
, sessionfactoryimplementor
part immutable once built, , integrator
's intended purpose not modify these configuration items instead use them information on how configure new service
integrations using sessionfactoryserviceregistry
.
and if you're finding annoying configure session
find annotated classes @ runtime, suggest try using entitymanagerfactory
approach initializing hibernate far more straightforward , uses standard jpa syntax can switched handful of other providers if ever need to. automatically scan annotated entities on behalf. api bit more simplified , limited, if ever need power of native hibernate-specific functionality there way access native underlying api.
Comments
Post a Comment