gao634209276
2016-04-02 23:28
You have an error in your Sql syntax;check the manual that corresponds to your MySql server version fro the right syntax to use near'( ORDER order0_where exists(select orderitems1_
public class OrderTest { Session session = null; @Test public void testWhere1() { String hql = "from Order o where o.orderItems is not empty"; Query query = session.createQuery(hql); List<Order> list = query.list(); for (Order order : list) { System.out.println(order.getCustomer().getName()); System.out.println(order.getAmount()); System.out.println(order.getTradeDate()); } } @Before public void setUp() throws Exception { session = HibernateSessionFactory.getCurrentSession(); } @After public void tearDown() throws Exception { session.close(); } }
.ID from ORDERITEM orderitems1_ w' at line 1
你的order对应的映射文件order.hbm.xml里设置了orderitem的一对多关系么?
Order对应的应该是数据库中orderform这张表, 可是老师给的该表中没有ORDERITEM字段. 自己创建一个.
from Order o where o.orderItems is not null
HQL数据查询基础
41151 学习 · 90 问题
相似问题