-->
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.  [ 2 posts ] 
Author Message
 Post subject: Implementing prefix for @Embedded
PostPosted: Thu May 25, 2017 3:55 am 
Newbie

Joined: Fri Sep 15, 2006 2:09 am
Posts: 11
I recently stumbled again over the lack of being able to provide a prefix for an @Embeddable in the using class.
I know about @AttributeOverrides, but this is really cumbersome having to provide it manually each time.
Having the new naming strategies provides a little better support with the ImplicitNamingStrategy, prefixing all embeddables.
But prefixing all embeddables isn't what I'm looking for (sorry) :). What I would like to have is something like this, proposed in the JPA spec:

https://github.com/javaee/jpa-spec/issues/23

or already implemented by:

https://github.com/ebean-orm/javax-pers ... i/issues/2

Although from my point of view "prefix" would be perfect, the experts tend to provide a custom naming strategy hook like you guys already provide to handle this.
Are there any plans to implement that upfront :)?

The problem with the existing naming strategies you guys have, is that I can't implement my own to provide a case specific prefix.
I tried to implement my own naming strategy, but in there I didn't find a way to get e.g. annotation information to decide whether to add
a prefix or not (e.g. by a custom annotation). Also in the interesting methods there's no information about the current entity which is currently processed.
I even tried to get that kind of information from the Ejb3Column Impl (bad, but looks promising for that purpose) but since it's an anonymous class that is passed
as an argument to the strategy, I can't get hold of it.

So my question is, is there currently any way to get that "prefix" somehow working? Maybe I've overlooked something in the naming strategies?


Top
 Profile  
 
 Post subject: Re: Implementing prefix for @Embedded
PostPosted: Thu May 25, 2017 4:49 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
That JPA issue is just a request proposal. It never made into the JPA specs. Hibernate does not provide support for this either.

Now, since the database is supposed to drive the schema changes, you already have the columns and justs need to map them to JPA entities, embeddable or basic types. So, realistically speaking, how many embedabbles will you have in a single entity?

Having more than one is more the exception than the rule. Since you can map all the columns manually, using @AttributeOverride, you already can handle this atypical use case. I don't think that adding a JPA feature just for this use case pays off.

To conclude, you need to assign the mapping manually, and it's unlikely that this will change anytime soon.


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