Hibernate查询。演员班

时间:2018-04-24 09:23:26

标签: java hibernate hql

拥有hql查询

developers = {ArrayList@4889} size = 4 
 \/ 0 = {object[2]4897} //what does this do in ArrayList<**Developer**>>??
    -> 0 = {Developer@4901} //This is exactly the class I expect in ArrayList
    -> 1 = {ProjectDeveloper}//?????
 -> 1 = {object[2]4898}

它工作并获得对象列表,但不是开发人员

实际上,i get的对象看起来像一个数组列表,其中包括对象数组,其中包括开发人员类对象和ProjectDeveloper(mtm类)。不幸的是我无法在图像上放置链接,但Schema看起来像:

@Table(name = "developers")
@Entity
public class Developer implements GenerallyTable{

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private long id;
    @Column(name = "first_name")
    private String name;     
    @Column(name = "age")
    private int age;     
    @Column(name = "sex")
    private boolean sex;    
    @Column(name = "salary")
    private BigDecimal salary;
//...getters + setters
}

开发人员课程:

{{1}}

如何不可能(Developer.class如何在具有未知结构的数组中转换),以及如何准确获取开发人员的ArrayList?

1 个答案:

答案 0 :(得分:1)

尝试使用createQuery类型定义的List<Developer> developers = session.createQuery("select d from Developer d " + "left join ProjectDeveloper pd on pd.developer.id = d.id " + "where pd.project.id = " + project.getId(), Developer.class) .getResultList();

setParameter

此外,您应该使用List<Developer> developers = session.createQuery("select d from Developer d " + "left join ProjectDeveloper pd on pd.developer.id = d.id " + "where pd.project.id = :proj_id", Developer.class) .setParameter("proj_id", project.getId()) .getResultList(); 方法

reg myclk;
always@(clk) begin
    if(clk) begin
        myclk = clockEdge? 1 : 0; #1 myclk = 0;
    end else begin
        myclk = clockEdge? 0 : 1; #1 myclk = 0;
    end
end     

always@(posedge myclk or posedge reset) begin
    if(reset)
        cnt <= 0;
    else
        cnt <= cnt+1;
end