I have a database with the following structure:
CREATE TABLE entity (
id SERIAL,
name VARCHAR(255),
PRIMARY KEY (id)
);
CREATE TABLE entity_prop
I guess your entity_property has a composite key (entity_id, name) where entity_id is a foreign key to entity. If so, you can map it as follows:
@Embeddable
public class EntityPropertyPK {
@Column(name = "name")
private String name;
@ManyToOne
@JoinColumn(name = "entity_id")
private Entity entity;
...
}
@Entity
@Table(name="entity_property")
public class EntityProperty {
@EmbeddedId
private EntityPropertyPK id;
@Column(name = "value")
private String value;
...
}