+-------+---------+----------+----------+------------+--------+----------------------+-----+-------+
| id | address | bankAccN | clientId | contactTel | isLeaf | name | zip | pid |
+-------+---------+----------+----------+------------+--------+----------------------+-----+-------+
| 1 | NULL | NULL | NULL | 0 | | | 0 | NULL |
| 10000 | NULL | NULL | NULL | 0 | N | 所有分销商 | 0 | 1 |
| 10001 | NULL | NULL | A0001 | 0 | Y | 北京医药股份有限公司 | 0 | 10000 |
| 10002 | NULL | NULL | B0001 | 0 | Y | 北京中医医院 | 0 | 10000 |
+-------+---------+----------+----------+------------+--------+----------------------+-----+-------+
| id | address | bankAccN | clientId | contactTel | isLeaf | name | zip | pid |
+-------+---------+----------+----------+------------+--------+----------------------+-----+-------+
| 1 | NULL | NULL | NULL | 0 | | | 0 | NULL |
| 10000 | NULL | NULL | NULL | 0 | N | 所有分销商 | 0 | 1 |
| 10001 | NULL | NULL | A0001 | 0 | Y | 北京医药股份有限公司 | 0 | 10000 |
| 10002 | NULL | NULL | B0001 | 0 | Y | 北京中医医院 | 0 | 10000 |
+-------+---------+----------+----------+------------+--------+----------------------+-----+-------+
解决方案 »
- s2sh项目tomcat运行没有问题,使用resin部署异常无法启动 感谢!
- Double保留两位小数
- 求救:关于定时器任务的问题。
- 请问怎么在日志中打印出hql语句对应的参数啊?
- 一个action,多个input的webwork验证问题
- 在eclipse里无法正常打开jsp页。MyEclipse的简单问题~!
- 请问javaMail中发送邮件时如何设置一个邮件的优先级?
- 用ant编译EJB工程时如何写classpath格式?
- 如何将一用java开发的软件利用opentools技术将其集成进JBuilder?
- 编译converter.java出错。找不到EJBObject接口
- 将XML文件的节点拆分出来,求解决
- 最近服务器总是出现这样的问题
有人说是下标越界,
我查了原码:
public char charAt(int index) {
if ((index < 0) || (index >= value.length)) {
throw new StringIndexOutOfBoundsException(index);
}
return value[index];
}
我不明白,它为什么会跑到这里,
我换了多种hql写法,比如:
String hql= "select c1.client from Clevel c1 where c1.client.id=?";
Client client =(Client)session.createQuery(hql)
.setParameter(0, id)
.uniqueResult();
都出现:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
我的数据库也有数据啊!以下是我的Client类:
@Entity
@Component
public class Client {
@Id
@GeneratedValue(generator="assigned")
@GenericGenerator(name = "assigned", strategy = "assigned")
private int id;
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="pid")
private Client clientN;
@OneToMany(mappedBy="clientN")
private Set<Client> clients;
private String clientId;
private String name;
@OneToOne(cascade=CascadeType.ALL,mappedBy="clientRegion")
private Region region;
@OneToMany(mappedBy="client")
private Set<Clevel> clevels=new HashSet<Clevel>();
private String bankAccN;
private int contactTel;
private String address;
private int zip;
private char isLeaf; public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
} public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Region getRegion() {
return region;
}
public void setRegion(Region region) {
this.region = region;
}
public String getBankAccN() {
return bankAccN;
}
public void setBankAccN(String bankAccN) {
this.bankAccN = bankAccN;
}
public int getContactTel() {
return contactTel;
}
public void setContactTel(int contactTel) {
this.contactTel = contactTel;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getZip() {
return zip;
}
public void setZip(int zip) {
this.zip = zip;
}
public Set<Client> getClients() {
return clients;
}
public void setClients(Set<Client> clients) {
this.clients = clients;
}
public char getIsLeaf() {
return isLeaf;
}
public void setIsLeaf(char isLeaf) {
this.isLeaf = isLeaf;
}
public Client getClientN() {
return clientN;
}
public void setClientN(Client clientN) {
this.clientN = clientN;
}
public Set<Clevel> getClevels() {
return clevels;
}
public void setClevels(Set<Clevel> clevels) {
this.clevels = clevels;
} public Client(int id, String clientId, String name, Region region,
String bankAccN, int contactTel,
String address, int zip,Set<Clevel> clevels) {
super();
this.id = id;
this.clientId = clientId;
this.name = name;
this.region = region;
this.bankAccN = bankAccN;
this.contactTel = contactTel;
this.address = address;
this.zip = zip;
this.clevels = clevels;
}
public Client() {
super();
}}