java中的delete语句_求助,hibernate 的delete语句

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

Cart 和Customer 两个类似一对一的关系

Cart类

@Entity(name="cart")

public class Cart {

private int id;

private Customer customer;

@Id

@GeneratedValue

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

@OneToOne

public Customer getCustomer() {

return customer;

}

public void setCustomer(Customer customer) {

this.customer = customer;

}

}

Customer:

@Entity(name="customer")

public class Customer {

private int id;

private String name;

private String password;

private int type;

@Id

@GeneratedValue

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getPassword() {

return password;

}

public void setPassword(String password) {

this.password = password;

}

public int getType() {

return type;

}

public void setType(int type) {

this.type = type;

}

}

想这样删除Cart

hql="delete cart c where c.customer.name=?"

session.createQuery(hql).setParameter(0,customer.getName()).executeUpdate();

执行后报错:

Hibernate: delete from cart cross join customer customer1_ where name=?

ERROR: 关键字 'cross' 附近有语法错误。

org.hibernate.exception.SQLGrammarException: could not execute statement

求助

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值