-->
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.  [ 6 posts ] 
Author Message
 Post subject: Bug With Nested @Embeddable Objects?
PostPosted: Thu Oct 26, 2006 11:32 am 
Newbie

Joined: Thu Sep 28, 2006 6:01 pm
Posts: 8
Location: Colorado, USA
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 4:49 pm 
Newbie

Joined: Thu Sep 28, 2006 6:01 pm
Posts: 8
Location: Colorado, USA
Yes, I was afraid this issue would get little attention - a bit too much of an edge case for most. Unfortunately, this edge case is one that I need to exercise.

I'm pretty sure this is a bug in Hibernate. However, I don't know if it's in hibernate-annotations, hbm2ddl, or hibernate-core. I think be taking my first Hibernate spelunking trip. Wish me well.

I'll report back if I get back...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 6:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I would apreciate if you could post a runnign testcase to JIRA, it should work.
@Column( name="B_c" ) is wrong though

_________________
Emmanuel


Top
 Profile  
 
 Post subject: The problem is AccessType
PostPosted: Thu Nov 09, 2006 10:47 pm 
Newbie

Joined: Sat Nov 26, 2005 4:02 pm
Posts: 2
I just ran into this same problem, and the fix for me was to *explicitly* use the annotation "@AccessType("property") on the deepest embedded class.

The bug seems to be that, with a collection of embedded objects that contain embedded objects, for some reason the default access type gets assumed to be "field". You must specify "property" explicitly.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 6:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes, but a running test case would help me fix that :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Bug With Nested @Embeddable Objects?
PostPosted: Fri Mar 23, 2007 12:43 pm 
Newbie

Joined: Sun Jul 30, 2006 6:29 pm
Posts: 1
I just got bit by this bug. It took most of a day to find this answer (first I had to figure out what to look for). Emmanuel has asked for a running test case a couple of times. Has that been provided? And if so, is there a filed bug report?


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

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.