package com.imooc.model;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import com.imooc.entity.Seller;
import com.imooc.util.HibernateSessionFactory;
public class SellerTest {
private Session session=null;
@BeforeEach
void setUp() throws Exception {
session=HibernateSessionFactory.getSession();
}
@AfterEach
void tearDown() throws Exception {
session.close();
}
@Test
public void testSeller() {
String hql="from Seller";
Query query=session.createQuery(hql);
List<Seller> sellers=query.list();
for(Seller seller:sellers) {
System.out.println(seller);
}
}
}
你数据库里的表创建 了么?