[hibernate-dev] Accessing metadata when SF is build the legacy way

Steve Ebersole steve at hibernate.org
Wed Nov 18 09:19:00 EST 2015


This is a list for the discussion of HIbernate development.  Your question
is not a Hibernate development discussion, its a user question.  In the
future, please refrain from asking usage questions on a developer list.
Thanks.

I will address this one quickly though...

Unfortunately that method is not coming back.  The reasoning has been
discussed many times, many places so I won't get back into all the details
again.

As for Spring and their decision to keep using the legacy bootstrapping
approach...  Well that was their call.  I would assume their logic had more
to do with easiness on their side since the same calls work on 4.x and 5.x
more-or-less in terms of a straight-line building of the SF.  I have to
assume because I was never asked about it,. nor were any other Hibernate
developers as far as I know.  And you're right... it is unfortunate because
that decision probably affects a lot of people.

All that said, as discussed in the the documents I linked in the original
response the legacy bootstrap (Configuration) simply delegates to the new
bootstrapping APIs.  The new APIs have a lot of hook points, many of which
can be automatically discovered (java.util.ServiceLoader).  For
example, org.hibernate.boot.spi.MetadataContributor is one that would best
suit your needs.

On Wed, Nov 18, 2015 at 4:21 AM Koen Serneels <ks at error.be> wrote:

> Hi. I'm digging up an older question
> (
> https://www.mail-archive.com/hibernate-dev@lists.jboss.org/msg12872.html)I
> asked about modifying mapping metadata in H5. In short; I want to change
> the
> mutability flag of mappings programmatically.
>
>
>
> Using H4 there was a method called "getClassMappings" on
> org.hibernate.cfg.Configuration. This method no longer exist in H5.
>
> >From the previous answers/docu I understand that when using the new way of
> building the SF one can interact with the metadata after building it using
> the MetadataBuilder (but  before building the SF) this would solve my
> problem as I would be able to access the metadata at that point and change
> the behavior.
>
>
>
> Unfortunately, when using H5 through Spring4, the SF is built as what the
> manual describes the "legacy way"; Spring's LocalSessionFactoryBean uses
> Spring's LocalSessionFactoryBuilder which on its turn extends
> org.hibernate.cfg.Configuration and calls  org.hibernate.cfg.Configuration
> #buildSessionFactory to build the SF.
>




> Both metadata and sessionfactory are build in that single method leaving no
> hook to modify the metadata.
>
>
>
> At this point I don't see a normal/clean way in accessing the metadata
> before the SF is build using the legacy way. So, am I missing something? Is
> there maybe another way to access the metadata?
>
>
>
> Thanks
>
>
>
> Koen
>
>
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list