Hibernate一对多的关系

时间:2012-03-16 13:11:03

标签: hibernate one-to-many

我有1对多的关系

@Entity
@Table(name = "job")
public class JobBean implements Serializable{

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", updatable = false, nullable = false)
    private Long id;

    @Column(name = "name")
    protected String name;

    @Column(name = "state")
    protected String state;
.......



@Entity
@Table(name = "task")
public class TaskBean implements Serializable{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "tid", updatable = false, nullable = false)
    protected Long tid;

    @Column(name = "id")
    protected Long id;

    @Column(name = "state")
    protected String state;

    @Column(name = "progress")
    protected int progress;

在Task中,id是来自Job的外键。

我想获得所有工作及其相关任务。我的hibernate util怎么样?

0 个答案:

没有答案