-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with @Embedded and @AttributeOverrides
PostPosted: Thu Nov 23, 2006 7:51 pm 
Newbie

Joined: Thu Nov 23, 2006 7:21 pm
Posts: 1
Using hibernate-annotations-3.2.0-GA.

When using an @Embedded composite element, and overriding the column names like this:

Code:
@Embedded
@AttributeOverrides( {
    @AttributeOverride(name="extention", column = @Column(name="phone1_ext") ),
    @AttributeOverride(name="number", column = @Column(name="phone1_number") )
} )
public PhoneNumber getPrimaryPhone() {
    return _primaryPhone;
}



The schema generator does not obey to the the other annotations in the embedded class. For example:

Code:
@Embeddable
class PhoneNumber {

    @Basic
    @Length(min=0,max=6)
    public String getExtention() {
        return _extention;
    }

}


In this case, the resulting schema looks like:

Code:
phone1_ext varchar(255),


The lenght should be 6, not the default 255.

I don't see any way to override any other annotiation beside the @Column, and in fact, I would prefer not having to do it. Any suggestions?

Thank you.

Cedric


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 26, 2006 4:40 pm 
Beginner
Beginner

Joined: Wed Aug 24, 2005 5:32 am
Posts: 23
Hi,
The @AttributeOverride annotation takes a @Column annotation as an argument. In the sample you sent you set only the @Column's name
argument, but all other arguments of the @Column have default values, for example:
    updateable (true)
    unique (false)
    and so on...


The default value for length is 255 (see ejb-3_0-fr-spec-persistence, page 168). So you actually did mentioned a value for the column's length - 255.

BTW @Length is an Hibernate validator annotation, not an ejb3 annotation. If you only wanted to set the column length (rather than to use the validator) you should use the @Column from start.

Eyal Lupu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 4:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you forgot @Valid

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.