-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: JPA metamodel is not initialized for overriden attribute
PostPosted: Wed Aug 31, 2016 5:02 am 
Newbie

Joined: Wed Aug 31, 2016 4:49 am
Posts: 3
In our project we have a overridden attribute in an sub class of a mapped superclass.
Doing so to add a BeanValidation @NotEmpty annotation.

With Hibernate Version 4.3.1 everything was OK

We updated to hibernate 5.0.10 (coming with wildfly 10.1).
After that the metamodel for the overridden attribute of the sub class is not initialized and staying null.
Only the metamodel attribute for the mapped superclass is initialized.

I am not sure is this a bug in hibernate or if we do something we should not do?

Happy about any suggestions.
Thanks,
Oliver


Top
 Profile  
 
 Post subject: Re: JPA metamodel is not initialized for overriden attribute
PostPosted: Wed Aug 31, 2016 10:20 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Can you post your mappings, the persistence logic, and the actual stack trace?


Top
 Profile  
 
 Post subject: Re: JPA metamodel is not initialized for overriden attribute
PostPosted: Thu Sep 01, 2016 5:52 am 
Newbie

Joined: Wed Aug 31, 2016 4:49 am
Posts: 3
Hello Vlad,
thank you for your time.
I altered the test MappedSuperclassWithAttributesTest a little bit to demonstrate my problem.

https://github.com/hibernate/hibernate-orm/commit/03fbf2c4e2fa309ebcc45bacb5fa354905001a05

In line 50 of MappedSuperclassWithAttributesTest Product_.overridenName is null.

Best regards,
Oliver


Top
 Profile  
 
 Post subject: Re: JPA metamodel is not initialized for overriden attribute
PostPosted: Thu Sep 01, 2016 5:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
As far as I know, properties cannot be overridden with different a mapping, so I'm not sure why you are overriding the base class property. What is your use case?


Top
 Profile  
 
 Post subject: Re: JPA metamodel is not initialized for overriden attribute
PostPosted: Thu Sep 01, 2016 6:38 am 
Newbie

Joined: Wed Aug 31, 2016 4:49 am
Posts: 3
I donot change the mapping. I add an additional bean validation annotation.
My usecase is to add a @NotEmpty annotation.

The test case simplifies a little bit, the real class structure is more complex.

In the base class the property is not required, but it is in the extending class. So the metamodel for both classes contains the same property.
With hibernate 4.3.11, both were initialized, with 5.x that is not the case for the extending class.
So I bumped into this because of upgrading our wildfly to version 10.1.

So if I am doing something forbidden should not hibernate fail some where earlier with an appropriate message?


Top
 Profile  
 
 Post subject: Re: JPA metamodel is not initialized for overriden attribute
PostPosted: Thu Sep 01, 2016 7:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
I asked Gunnar and he explained to me that the BV rules are cumulative from base class to the extended one, so your use case is valid.

I think you should open a Jira ticket and add a replicated test case for your issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.