Hi,
I am new Hibernate and i am trying to write annotated class. I have two domain objects.
(1) HandsetDeliveryMethod
(2) DeliveryMethod
The DeliveryMethod class :
Code:
@Entity
@Table(name = "DELIVERY_METHODS")
public class DeliveryMethod {
private Integer id;
private String name;
private String description;
private Set<HandsetDeliveryMethod> handsetDeliveryMethods;
public Set<HandsetDeliveryMethod> getHandsetDeliveryMethods() {
return handsetDeliveryMethods;
}
public void setHandsetDeliveryMethods(
Set<HandsetDeliveryMethod> handsetDeliveryMethods) {
this.handsetDeliveryMethods = handsetDeliveryMethods;
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(name = "delivery_method_name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "description")
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
And the HandsetDeliveryMethod Class :
Code:
@Entity
@Table(name = "HANDSET_DELIVERY_METHODS")
public class HandsetDeliveryMethod {
private Integer id;
private DeliveryMethod deliveryMethod;
private Integer priority;
@Column(name = "priority")
public Integer getPriority() {
return priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
public DeliveryMethod getDeliveryMethod() {
return deliveryMethod;
}
public void setDeliveryMethod(DeliveryMethod deliveryMethod) {
this.deliveryMethod = deliveryMethod;
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
Here I have done the simple attributes mapping But I want to establish a relationship between the
deliveryMethod inside "
HandsetDeliveryMethod" and "
handsetDeliveryMethods" in "
DeliveryMethod".
Any ideas?
Thanks in Advance..