可以啊。 当然可以了。 上Entity类看看。

解决方案 »

  1.   

    package com.luoxudong.entity;import java.util.ArrayList;
    import java.util.List;import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.OneToMany;
    import javax.persistence.SequenceGenerator;
    @Entity
    @SequenceGenerator(name = "SEQ_STORE", sequenceName = "my_sequence_custid", allocationSize = 1)
    public class Customer {
    private Long id;
    private String companyName;
    private String address;
    private String phone;
    private String fax;
    private String url;
    private List<Orders> orders = new ArrayList<Orders>();//订单
    private List<Linkmen> linkmens = new ArrayList<Linkmen>();//联系人
    private List<Record> records = new ArrayList<Record>();//交往记录

    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="SEQ_STORE")
    public Long getId() {
    return id;
    }
    public void setId(Long id) {
    this.id = id;
    }
    public String getCompanyName() {
    return companyName;
    }
    public void setCompanyName(String companyName) {
    this.companyName = companyName;
    }
    public String getAddress() {
    return address;
    }
    public void setAddress(String address) {
    this.address = address;
    }
    public String getPhone() {
    return phone;
    }
    public void setPhone(String phone) {
    this.phone = phone;
    }
    public String getFax() {
    return fax;
    }
    public void setFax(String fax) {
    this.fax = fax;
    }
    public String getUrl() {
    return url;
    }
    public void setUrl(String url) {
    this.url = url;
    }
    @OneToMany
    public List<Orders> getOrders() {
    return orders;
    }
    public void setOrders(List<Orders> orders) {
    this.orders = orders;
    }
    @OneToMany
    public List<Linkmen> getLinkmens() {
    return linkmens;
    }
    public void setLinkmens(List<Linkmen> linkmens) {
    this.linkmens = linkmens;
    }
    @OneToMany
    public List<Record> getRecords() {
    return records;
    }
    public void setRecords(List<Record> records) {
    this.records = records;
    }
    }
      

  2.   

    package com.luoxudong.entity;import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.ManyToOne;
    import javax.persistence.SequenceGenerator;@Entity
    @SequenceGenerator(name="SEQ_STORE", sequenceName="my_sequence_linkmenid",allocationSize=1)
    public class Linkmen {
    private Long id;
    private String name;
    private String sex;
    private String position;
    private String officePhone;
    private String mobilePhone;
    private String re;
    private Customer customer;


    @ManyToOne
    public Customer getCustomer() {
    return customer;
    }
    public void setCustomer(Customer customer) {
    this.customer = customer;
    } @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="SEQ_STORE")
    public Long getId() {
    return id;
    }
    public void setId(Long id) {
    this.id = id;
    }
    public String getMobilePhone() {
    return mobilePhone;
    }
    public void setMobilePhone(String mobilePhone) {
    this.mobilePhone = mobilePhone;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getOfficePhone() {
    return officePhone;
    }
    public void setOfficePhone(String officePhone) {
    this.officePhone = officePhone;
    }
    public String getPosition() {
    return position;
    }
    public void setPosition(String position) {
    this.position = position;
    }
    public String getRe() {
    return re;
    }
    public void setRe(String re) {
    this.re = re;
    }
    public String getSex() {
    return sex;
    }
    public void setSex(String sex) {
    this.sex = sex;
    }
    }
      

  3.   

    inner join a.linkmens b  ,可能是这里有问题不能命名b吧,你既然定义了List<LinkMen>属性,就用隐式的join就行了,where a.linkmens.name。
      

  4.   

    大哥啦! 你不就是一个双向一对多吗? from Linkmen as l where l.name = ? and l.mobilePhone = ? and l.customer.companyName = ?从多这边开始查不就完了吗?
      

  5.   

    还有 在一的这边 @OneToMany(mappedBy = "customer")你要是不这么写会生成中间表的。