一条hql语句 可以啊。 当然可以了。 上Entity类看看。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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; }} 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; }} inner join a.linkmens b ,可能是这里有问题不能命名b吧,你既然定义了List<LinkMen>属性,就用隐式的join就行了,where a.linkmens.name。 大哥啦! 你不就是一个双向一对多吗? from Linkmen as l where l.name = ? and l.mobilePhone = ? and l.customer.companyName = ?从多这边开始查不就完了吗? 还有 在一的这边 @OneToMany(mappedBy = "customer")你要是不这么写会生成中间表的。 跟着老师做例子,遇到的类不能继承问题。请教 我用struts2做了个插入小实验报出了个奇怪的问题小大家帮我解决下 用axis2下面的wsdl2java工具把WSDL转换成java jsp页面里面使用${变量}是什么时候开始的? hibernate自带的指南有段话看不懂,谁给我说道说道 Tapestry写计数器问题 ■■■■■■用weblogic 还是websphere为好呢■■■■■■ 手机短信接口的编写问题! easy struts for jbuilder高手快来指点!!!! EJB简单问题一个,100分... java timer不起作用 求java网站url重写(实现伪静态)
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;
}
}
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;
}
}