我有一个维护AdGroupInterfaces列表的课程广告系列。即将继续实施
@Entity
@Table(name = "campaigns")
public class Campaign implements Serializable,Comparable<Object>,CampaignInterface {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany (
cascade = {CascadeType.ALL},
fetch = FetchType.EAGER,
targetEntity=AdGroupInterface.class
)
@org.hibernate.annotations.Cascade(
value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN
)
@org.hibernate.annotations.IndexColumn(name = "CHOICE_POSITION")
private List<AdGroupInterface> AdGroup;
public Campaign() {
super();
}
public List<AdGroupInterface> getAdGroup() {
return AdGroup;
}
public void setAdGroup(List<AdGroupInterface> adGroup) {
AdGroup = adGroup;
}
public void set1AdGroup(AdGroupInterface adGroup) {
if(AdGroup==null)
AdGroup=new LinkedList<AdGroupInterface>();
AdGroup.add(adGroup);
}
}
AdGroupInterface的实施是AdGroups。当我在广告系列的列表中添加广告组时,
广告系列c; c.getAdGroupList()。add(new AdGroups())等 和 保存广告系列
它说“无法实例化抽象类或接口:”AdGroupInterface
它在持续存在之前没有认识到实施......
而持久化广告组分开运作。当它是另一个实体的成员时,它不会被持久化。
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
@Entity
@DiscriminatorValue("1")
@Table(name = "AdGroups")
public class AdGroups implements Serializable,Comparable,AdGroupInterface{
/**
*
*/
private static final long serialVersionUID = 1L;
private Long Id;
private String Name;
private CampaignInterface Campaign;
private MonetaryValue DefaultBid;
public AdGroups(){
super();
}
public AdGroups( String name, CampaignInterface campaign) {
super();
this.Campaign=new Campaign();
Name = name;
this.Campaign = campaign;
DefaultBid = defaultBid;
AdList=adList;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="AdGroup_Id")
public Long getId() {
return Id;
}
public void setId(Long id) {
Id = id;
}
@Column(name="AdGroup_Name")
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
@ManyToOne
@JoinColumn (name="Cam_ID", nullable = true,insertable = false)
public CampaignInterface getCampaign() {
return Campaign;
}
public void setCampaign(CampaignInterface campaign) {
this.Campaign = campaign;
}
}
我错过了什么?请调查一下......