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