[hibernate-dev] Replacement for SessionFactoryImplementor#getClassMetadata ?

Sanne Grinovero sanne at hibernate.org
Mon Jul 10 06:26:58 EDT 2017


On 7 July 2017 at 18:53, Steve Ebersole <steve at hibernate.org> wrote:
> I'd drop the getClassMetadata part.  It just returns itself.  I will
> deprecate that contract and remove it eventually

At that point could you make
`org.hibernate.persister.entity.EntityPersister` extend
`org.hibernate.metadata.ClassMetadata` ?

I understand the method just returns itself, but from an SPI user
point of view I otherwise have to cast.
The current method reassures me that this is safe to do.

Thanks,
Sanne


>
>
> On Fri, Jul 7, 2017, 7:59 AM Sanne Grinovero <sanne at hibernate.org> wrote:
>>
>> On 7 July 2017 at 13:11, andrea boriero <andrea at hibernate.org> wrote:
>> > hi Sanne,
>> > what about sfi.getMetamodel().entityPersister( x ).getClassMetadata(); ?
>>
>> Thanks! I totally missed that one.
>>
>> >
>> > On 7 July 2017 at 12:55, Sanne Grinovero <sanne at hibernate.org> wrote:
>> >>
>> >> Hi all,
>> >>
>> >> Hibernate Search is using this method, but it's deprecated with the
>> >> following comment:
>> >> "Use the descriptors from #getMetamodel() instead".
>> >>
>> >> I'm a bit lost about how to reach the same by using the Metamodel.
>> >>
>> >> I found this solution:
>> >>
>> >> SessionFactoryImplementor sfi =..
>> >> ClassMetadata cm = (ClassMetadata) sfi.getMetamodel().entityPersister(
>> >> x
>> >> );
>> >>
>> >> But it's requiring a suspicious casting, which I was hoping to avoid
>> >> as I'm already working at SPI level?
>> >>
>> >>
>> >> My goal is to ultimately read
>> >> `ClassMetadata#getIdentifierPropertyName()`. Maybe there's a better
>> >> approach?
>> >>
>> >> Thanks,
>> >> Sanne
>> >> _______________________________________________
>> >> hibernate-dev mailing list
>> >> hibernate-dev at lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>> >
>> >
>> _______________________________________________
>> 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