日期:2014-05-19 浏览次数:20686 次
Configuration cfg = new AnnotationConfiguration();//用了注解的方式 sf = cfg.configure("/hibernate.cfg.xml").buildSessionFactory(); Session session = sf.getCurrentSession(); session.beginTransaction(); String hql="from Number"; Query query = session.createQuery(hql); List<Number> a = query.list(); for(Number number:a) System.out.println(number.getMoney()); session.getTransaction().commit(); sf.close();
] 控制台日志 !SESSION 2012-05-21 00:13:57.791 ----------------------------------------------- eclipse.buildId=unknown java.version=1.6.0_13 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CN Framework arguments: -product com.xinluke.caipiao.product Command-line arguments: -product com.xinluke.caipiao.product -data C:\Users\Administrator\Desktop\Workspaces\MyEclipse Blue Edition/../runtime-com.xinluke.caipiao.product -dev file:C:/Users/Administrator/Desktop/Workspaces/MyEclipse Blue Edition/.metadata/.plugins/org.eclipse.pde.core/com.xinluke.caipiao.product/dev.properties -os win32 -ws win32 -arch x86 -consoleLog !ENTRY org.eclipse.ui 2 0 2012-05-21 00:13:59.476 !MESSAGE Warnings while parsing the action sets from the 'org.eclipse.ui.actionSets' extension point !SUBENTRY 1 org.eclipse.ui 2 0 2012-05-21 00:13:59.476 !MESSAGE There was no class provided, and the action is not retargettable: plug-in='com.xinluke.caipiao', id='com.xinluke.caipiao.action.count' !ENTRY org.eclipse.ui.workbench 4 0 2012-05-21 00:13:59.945 !MESSAGE Unable to create view ID com.xinluke.caipiao.ui.sales: org/hibernate/cfg/Configuration !STACK 0 java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at com.xinluke.caipiao.ui.Sales.createPartControl(Sales.java:51) at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375) at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:229) at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595) at org.eclipse.ui.internal.WorkbenchPage$ActivationList.setActive(WorkbenchPage.java:4317) at org.eclipse.ui.internal.WorkbenchPage$18.runWithException(WorkbenchPage.java:3359) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757) at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803) at org.eclipse.ui.internal.Workbench$33.runWithException(Workbench.java:159