-->
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.  [ 1 post ] 
Author Message
 Post subject: Bug in Hibernate Annotations and hbm2ddl
PostPosted: Wed Oct 25, 2006 12:57 am 
Newbie

Joined: Thu Sep 28, 2006 6:01 pm
Posts: 8
Location: Colorado, USA
Versions:
hibernate3.2cr4
hibernate-annotations-3.2cr2
hibernate-tools-3.1.0.beta4


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 annotation. 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 exactly what I need to do in my real code.

Any thoughts? Is this a clear bug that needs to be filed or am I missing something?

Thank you,
Sean


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.