-->
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: Embedded Components with OneToOne
PostPosted: Thu Jun 29, 2006 6:44 am 
Newbie

Joined: Thu Jun 29, 2006 5:43 am
Posts: 5
Hi,

like I've seen here:

http://forum.hibernate.org/viewtopic.php?t=947826&highlight=onetoone+embedded

somebody had nearly the same problem like I, but i have not seen a solution.

So, I just sdescribe my problem:

I have an address:

Code:
@Entity
public class AddressDB {

   @ID
   Long id;   

   @Column(name="street")
   String street;
....


I need to store for each value, if this value is visible:

Code:
@Embeddable
public class VisibleComponentAddressDB{
   
   @OneToOne(cascade=CascadeType.ALL)
   @JoinColumn(name="address_fk")
   private AddressDB value;
   private boolean visible;


So and these VisibleComponents are strored in a profile:

Code:
@Entity
@Table(name="profile")
public class ProfileDB{
   @Embedded
   @AttributeOverrides( {
      @AttributeOverride(name="visible", column = @Column(name="name_visible") ),
      @AttributeOverride(name="value", column = @Column(name="name_value") )
   } )
   String name;
   
   @Embedded
   @AttributeOverrides( {
      @AttributeOverride(name = "visible", column = @Column(name = "delivery_address_visible")),
      @AttributeOverride(name = "address_fk", column = @Column(name = "delivery_address_fk"))
   })
   
   VisibleComponentAddressDB deliveryAddress;

....
}


But when the schema is generated, I get always something like that:

Code:
[hibernatetool]     create table address (
[hibernatetool]         id int8 not null,
[hibernatetool]         city varchar(255),
[hibernatetool]         street varchar(255),
[hibernatetool]         zip_code varchar(255),
[hibernatetool]         primary key (id)
[hibernatetool]     );

[hibernatetool]     create table profile (
[hibernatetool]         id int8 not null,
[hibernatetool]         name_value varchar(255),
[hibernatetool]         name_visible bool,
[hibernatetool]         delivery_address_visible bool,
[hibernatetool]         address_fk int8,
[hibernatetool]         primary key (id)
[hibernatetool]     );



So, when I want to use several different addresses, it won't work, because they all will have the same column name. What I am doing wrong?

Appreciate help a lot.

Thanks in advance.

Stefan


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.