Hibernate映射问题ManyToOne和OneToMany

时间:2012-09-18 07:25:05

标签: hibernate hibernate-mapping many-to-one

我有一个现有的Dao课程:     宾语     (ID,     名称,     警报,     flagId,     警告)

我想创建另一个这样的DAO类:     旗     (ID,     flagId,     客户名称,     类别,     注释)

然后,我想把OBJECT.flagId依赖于FLAG.flagId,这是我的问题。

我已尝试使用@OneToMany进行多次编辑,级联... 但无法找到将现有字段链接到新表/ Dao的方法。

在这里你可以找到我的DAO的代码:

ObjectDAO:

@Entity
@Table(name = "Object")
public class ObjectDao {
@Id
@Column(length = 36)
@GeneratedValue(generator = HibernateIdGenerator.NAME)
@GenericGenerator(name = HibernateIdGenerator.NAME, strategy = HibernateIdGenerator.STRATEGY)
private String id;
    private String name;
private boolean alert;
@Basic
private String flagId;
private boolean warning = false;

    //getters and setters ...

SenderDAO:

@Entity
@Table(name = "Flag")
public class FlagDao {

@Id
@Column(length = 36)
@GeneratedValue(generator = HibernateIdGenerator.NAME)
@GenericGenerator(name = HibernateIdGenerator.NAME, strategy = HibernateIdGenerator.STRATEGY)
private String id;

//@OneToMany(cascade = { CascadeType.ALL })
private String flagId;

    private String clientName;

@Basic
private int category;

@Basic
private String details;

    //getters and setters

所以我的问题是:如何将OBJECT.flagId链接到FLAG.flagId?

谢谢!

0 个答案:

没有答案