-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to utilize the metadata model in mappedBy attribute?
PostPosted: Wed Apr 05, 2017 8:59 am 
Newbie

Joined: Wed Jul 13, 2016 10:40 pm
Posts: 17
JPA Metadata Model may generate the atrribute information of the entity class(Topic)
so that I can get the information by the field of metadata model(Topic_) but not String constant
, which really set free for us to modify the attribute name of entity class.

And I found that the mappedBy attribute in @OneToMany.. can not utilize the metadata model.

I have tried this way that

Code:
@OneToMany(mappedBy="${Topic_.person.getName()}")


, but failed.


Top
 Profile  
 
 Post subject: Re: How to utilize the metadata model in mappedBy attribute?
PostPosted: Wed Apr 05, 2017 9:51 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Of course, it failed! That's the expected behavior.

The mappedBy attribute takes the name of the property. You cannot use Metamodel for that. Metamodel is used to construct type-safe entity queries.

So, the JPA annotations have no notation of a dynamic Expression Language (e.g. ${Topic_.person.getName()}). You have to provide the name of the property.

So, what happens you modify a property without renaming the mappedBy attribute? Well, Hibernate will not even bootstrap.


Top
 Profile  
 
 Post subject: Re: How to utilize the metadata model in mappedBy attribute?
PostPosted: Wed Apr 05, 2017 10:19 am 
Newbie

Joined: Wed Jul 13, 2016 10:40 pm
Posts: 17
vlad wrote:
Of course, it failed! That's the expected behavior.

The mappedBy attribute takes the name of the property. You cannot use Metamodel for that. Metamodel is used to construct type-safe entity queries.

So, the JPA annotations have no notation of a dynamic Expression Language (e.g. ${Topic_.person.getName()}). You have to provide the name of the property.

So, what happens you modify a property without renaming the mappedBy attribute? Well, Hibernate will not even bootstrap.


Thanks, I am clear what metadata model use for.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.