I am really sorry to double post my question, but I am feeling that my post is quite unregnonized and maybe in the wrong location, so I just try it here again. (You can also tell me, where my post is more correct ;-) )
Hibernate version: 3.2.0
Name and version of the database you are using: postgres 7.4
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.
I have a problem to auto generate the database schema.
So, I just describe my problem:
I have an address:
Code:
@Entity
public class AddressDB {
@ID
Long id;
@Column(name="street")
String street;
@Column(name="city")
String city;
....
}
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;
// no need for annotations (will be overwritten
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