<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
12/05/2010 19:32, Andersen Max wrote:
<blockquote cite="mid:CF3A626E-5FFC-4A3A-833A-577FBAE3E5BA@redhat.com"
type="cite">
<pre wrap="">We integrated naming strategy into Eclipse JPA tooling so when it checks if a table/column
exists it won't just use the JPA defaults.
And I assume Dimitry found some inconsistency in that work.
But yeah, i'm also not fully following what Dimitry's problem is beyond
why @Entity(name="e.M11") doesn't result in e_M11 as table name ?
</pre>
</blockquote>
I created a table to show you what I think:<br>
<br>
<table border="1" cellpadding="2" cellspacing="2" height="112"
width="457">
<tbody>
<tr>
<td valign="top">NSMethod /Annotation</td>
<td align="center" valign="top">@Entity(name="x.y")<br>
</td>
<td align="center" valign="top">@Tablename="(x.y")<br>
</td>
</tr>
<tr>
<td valign="top">classToTableName<br>
</td>
<td align="center" valign="top"><font color="#ff0000">x.y</font><br>
</td>
<td align="center" valign="top">-<br>
</td>
</tr>
<tr>
<td valign="top">tableName<br>
</td>
<td align="center" valign="top">-<br>
</td>
<td align="center" valign="top">x.y<br>
</td>
</tr>
<tr>
<td valign="top">collectionTableName<br>
</td>
<td align="center" valign="top">y<br>
</td>
<td align="center" valign="top">x.y<br>
</td>
</tr>
<tr>
<td valign="top">foreignKeyColumnName<br>
</td>
<td align="center" valign="top">y<br>
</td>
<td align="center" valign="top">x.y<br>
</td>
</tr>
</tbody>
</table>
<br>
I expect to see the same values for whole column. @Table is ok -
hibernate leaves "x.y" to the NamingStrategy implementator. He will
decide what to do with the dot.<br>
But what about @Entity? Sometimes we say him the "name of the package",
sometimes not. This is strange and looks like a bug.<br>
<br>
Dmitry.<br>
<blockquote cite="mid:CF3A626E-5FFC-4A3A-833A-577FBAE3E5BA@redhat.com"
type="cite">
<pre wrap="">
/max
On May 12, 2010, at 18:12, Emmanuel Bernard wrote:
</pre>
<blockquote type="cite">
<pre wrap="">You guys lost me, I'm out of context.
Any change I get the actual naming strategy code, the Hibernate Annotations and Core version you are talking about and more important what are you guys trying to do :)
On 12 mai 2010, at 18:02, Andersen Max wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
On May 12, 2010, at 16:54, Dmitry Geraskov wrote:
</pre>
<blockquote type="cite">
<pre wrap="">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 {
}
</pre>
</blockquote>
<pre wrap="">
but that is not a collection table - its an Entity Table ...
</pre>
<blockquote type="cite">
<pre wrap="">What do you think will be DB table name? The correct answer is "e.M11".
</pre>
</blockquote>
<pre wrap="">
I would have assumed e_M11 ....so yeah thats a bit surprising.
</pre>
<blockquote type="cite">
<pre wrap="">The same for @Entity @Table(name = "e.M11")
</pre>
</blockquote>
<pre wrap="">
Here you are overriding namingstrategy so that shouldn't be surprising.
</pre>
<blockquote type="cite">
<pre wrap="">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
</pre>
</blockquote>
<pre wrap="">
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.
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
<pre wrap="">
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
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
</body>
</html>