-->
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: @Column @AttributeOverride
PostPosted: Wed Jun 25, 2008 1:57 pm 
Newbie

Joined: Wed Jun 25, 2008 12:59 pm
Posts: 9
Location: Belgium
Hibernate version: 3.2.6.ga

Name and version of the database you are using: Oracle 10g

Hi,

I have the following @Embeddable UserEntity class:
Code:
@Embeddable
public class UserEntity implements Serializable{
...
@Column(nullable = false, length = 8)
public String getName(){ return name; }
...
}

The Provider class embeds the UserEntity class and overrides the name of the column via the AttributeOverride annotation:
Code:
@Entity
public class Provider implements Serializable{
...
@Embedded
@AttributeOverrides({
    @AttributeOverride(name = "name", column = @Column(name = "prov_created_usr"))
})
public UserEntity getCreated(){ return created; }
...
}

The hbm2ddl generates the following:
Code:
create table provider (prov_created_usr varchar2(255) ...);

and not this:
Code:
create table provider (prov_created_usr varchar2(8) not null ...);

The name of the column comes from the Provider class and the datatype, length and not null attributes should come from the @Embeddable UserEntity class.
Is this possible ?

regards,
Tim


Top
 Profile  
 
 Post subject: Re: @Column @AttributeOverride
PostPosted: Thu Jun 26, 2008 4:29 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Tim,

tt wrote:
The name of the column comes from the Provider class and the datatype, length and not null attributes should come from the @Embeddable UserEntity class.
Is this possible ?


No that's not possible. Even though you just specify a new name, all the other default values for @Column (see http://www.hibernate.org/hib_docs/ejb3-api/javax/persistence/Column.html) are applied as well. You have to redefine the properties.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 26, 2008 12:50 pm 
Newbie

Joined: Wed Jun 25, 2008 12:59 pm
Posts: 9
Location: Belgium
thanks Hardy

too bad you can't override specific column attributes :(


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.