DefaultComponentSafeNamingStrategy breaks @ElementCollection of @Embeddables
----------------------------------------------------------------------------
Key: HHH-6005
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6005
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Reporter: Artem Troitskiy
Priority: Minor
{{DefaultComponentSafeNamingStrategy}} is incompatible with {{@ElementCollection}} of
{{@Embeddable}} objects.
Given the following classes
{code:java}
@Entity
public class Foo {
@ElementCollection
private List<Bar> bars;
...
}
@Embeddable
public class Bar {
private String name;
...
}
{code}
and DefaultComponentSafeNamingStrategy as a naming strategy, Hibernate generates the
schema with the following incorrect table:
bq. create table Foo_bars (Foo_id bigint not null, bars_collection&&element_name
varchar(255))
{{.collection&&element.}} is an internal placeholder that should be removed before
use of property name. Other naming strategies effectively remove it by using the part of
property name after the last {{.}}, but {{DefaultComponentSafeNamingStrategy}}
doesn't, it just replaces {{.}} with {{_}}.
Here is a workaround:
{code:java}
public class FixedDefaultComponentSafeNamingStrategy extends
DefaultComponentSafeNamingStrategy {
@Override
public String propertyToColumnName(String propertyName) {
return
super.propertyToColumnName(propertyName.replace(".collection&&element.",
"."));
}
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira