[jbosstools-dev] Unpredictable NamingStrategy interpretation
Andersen Max
max.andersen at redhat.com
Wed May 12 12:02:27 EDT 2010
On May 12, 2010, at 16:54, Dmitry Geraskov wrote:
> Hi, Emmanuel,
>
> The problem is in interpretation of specified names with dots.
>
> I created naming strategy where all method just join all passed parameters with "_".
> For example
> @Override
> public String collectionTableName(String ownerEntity, String ownerEntityTable, String associatedEntity,
> String associatedEntityTable, String propertyName) {
> return ownerEntity + "_"+ associatedEntity+ "_" + associatedEntityTable + "_" + associatedEntity +
> "_" +propertyName;
> }
>
>
> And what I have found:
>
> @Entity(name = "e.M11")
> public class ManyToMany1 implements Serializable {
>
> }
>
but that is not a collection table - its an Entity Table ...
> What do you think will be DB table name? The correct answer is "e.M11".
I would have assumed e_M11 ....so yeah thats a bit surprising.
> The same for @Entity @Table(name = "e.M11")
>
Here you are overriding namingstrategy so that shouldn't be surprising.
> But when this entity is used in relationship mapping as target entity things become different:
> for @Entity(name = "e.M11") entity.ManyToMany2_entity.ManyToMany1_M11_entity.ManyToMany1_mtm1
> for @Table(name = "e.M11") entity.ManyToMany2_entity.ManyToMany1_e.M11_entity.ManyToMany1_mtm1
I'm not seeing this as different. In one case you are saying naming strategy should do its thing Entity(name="e.M11")
and in the other you override it (i.e. @Table(name="e.M11").
Remember name on entity is for *entity*-name not table name.
> I didn't see any specification for how NamingStrategy should be used. And I even *fear* to compare this behaviour with core hibernate behaviour. I guess there will be some differences too.
I remember emmanuel having fun with mapping JPA naming standards over to Hibernate NamingStrategy especially when
it came to collections and entity names ...but I don't recall the conclusion.
Surprised entity name's doesn't seem to be processed on equal footing as class names. (i.e. why does @Entity(name="e.M11") not reasult in e_M11 as table name ?
/max
More information about the jbosstools-dev
mailing list