I posted this on the main Hibernate forum two days ago (Oct 24) and just realized that this was the forum it should be in. Sorry for the cross-post.
Versions:
hibernate3.2cr4
hibernate-annotations-3.2cr2
The DDL that is generated via hdm2ddl from the following annotated classes is flawed:
Code:
@Entity
public final class A
{
private B[] m_b;
private long m_pk;
@Id
public long getPk()
{
return m_pk;
}
@CollectionOfElements
@IndexColumn( name="A_b_index" )
public B[] getB()
{
return m_b;
}
}
@Embeddable
public final class B
{
private C m_c;
@Column( name="B_c" )
public C getC()
{
return m_c;
}
}
@Embeddable
public final class C
{
private int m_int;
@Column( name="C_int" )
public int getInt()
{
return m_int;
}
}
Here is the resulting DDL:
Code:
create table A (
pk bigint not null,
primary key (pk)
);
create table A_b (
A_pk bigint not null,
m_int integer not null,
A_b_index integer not null,
primary key (A_pk, A_b_index)
);
Why is the second row of table A_b using a column name of m_int? This is the private identifier for a class that is using method-level annotations. In fact, that class explicitly sets the column name to be
C_int. This is not used.
Using @AttributeOverrides in class A or B also does not stick. The DDL keeps using the field name - and it should not.
This seems to be a consequence to referencing an Embedded object from within an Embedded object that is stored in an array. Unfortunately, that's exactly what I need to do in my real code.
Any thoughts? Is this a bug or am I missing something?
Thank you,
Sean