2024年5月11日发(作者:)

package ate;

import ;

import ;

import ;

import n;

import nFactory;

import tionConfiguration;

import Export;

import lass;

import Class;

import ;

public class HibernateQLTest {

private static SessionFactory sf;

@BeforeClass

public static void beforeClass() {

sf = new

AnnotationConfiguration().configure().buildSessionFactory();

}

@AfterClass

public static void afterClass() {

();

}

@Test

public void testSchemaExport() {

new SchemaExport(new

AnnotationConfiguration().configure()).create(false, true);

}

@Test

public void testSave() {

Session session = ssion();

ransaction();

for(int i=0; i<10; i++) {

Category c = new Category();

e("c" + i);

(c);

}

for(int i=0; i<10; i++) {

Category c = new Category();

(1);

Topic t = new Topic();

egory(c);

le("t" + i);

ateDate(new Date());

(t);

}

for(int i=0; i<10; i++) {

Topic t = new Topic();

(1);

Msg m = new Msg();

t("m" + i);

ic(t);

(m);

}

nsaction().commit();

();

}

@Test

public void testHQL_01() {

Session session = ssion();

ransaction();

Query q = Query("from Category");

List categories = (List)();

for(Category c : categories) {

n(e());

}

nsaction().commit();

();

}

@Test

public void testHQL_02() {

Session session = ssion();

ransaction();

Query q = Query("from Category c where > 'c5'");

List categories = (List)();

for(Category c : categories) {

n(e());

}

nsaction().commit();

();

}

@Test

public void testHQL_03() {

Session session = ssion();

ransaction();

Query q = Query("from Category c order by desc");

List categories = (List)();

for(Category c : categories) {

n(e());

}

nsaction().commit();

();

}

@Test