To simplify this, is what you're asking to have two classes to map to one database table with
Hibernate? You're Client and Strategy to one single table?
I've got a little
Hibernate on this topic, you should really check it out.
Mapping Two Classes to One DB Table with Hibernate3 and JPA Annotations
The key is the @Embeddable annotation. You embed one class into the other, namely the strategy into the client.
Code:
package com.examscam.mappings;
import javax.persistence.Embeddable;
@Embeddable
public class ThingDetail {
private String alias;
private int count;
public String getAlias() {return alias;}
public void setAlias(String alias) {
this.alias = alias;
}
public int getCount() {return count;}
public void setCount(int count) {
this.count = count;
}
}
Code:
package com.examscam.mappings;
import javax.persistence.*;
import org.hibernate.Session;
import com.examscam.HibernateUtil;
@Entity
public class Thing {
private long id;
private String name;
private ThingDetail thingDetail;
@Embedded
public ThingDetail getThingDetail(){
return thingDetail;
}
public void setThingDetail(ThingDetail detail) {
this.thingDetail = detail;
}
@Id
@GeneratedValue
public long getId() {return id;}
public void setId(long id) {this.id = id;}
public String getName() {return name;}
public void setName(String name) {this.name = name;}
}
As I said, check out the full tutorial:
Mapping Two Classes to One DB Table with Hibernate3 and JPA Annotations