我有一个使用Hibernate进行数据库事务的应用程序,我已经映射了数据库中的所有表,当我尝试从一个表中获取数据时出现以下错误,请帮忙,
Jan 18, 2012 1:19:57 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Initial SessionFactory creation failed.org.hibernate.MappingException: entity class not found: mappings.Log
Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at org.ofm.mnu.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:25)
at org.ofm.mnu.persistence.HibernateUtil.<clinit>(HibernateUtil.java:14)
at org.ofm.mnu.CRUD.GrnMainCrud.retrive(GrnMainCrud.java:15)
at org.ofm.mnu.views.functions.GRN.fillGrnTable(GRN.java:224)
at org.ofm.mnu.views.functions.GRN.<init>(GRN.java:36)
at org.ofm.mnu.views.home.main.MainFrame.btnSample_2ActionPerformed(MainFrame.java:233)
at org.ofm.mnu.views.home.main.MainFrame.access$500(MainFrame.java:31)
at org.ofm.mnu.views.home.main.MainFrame$6.actionPerformed(MainFrame.java:185)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6504)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6269)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4860)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4686)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4686)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: org.hibernate.MappingException: entity class not found: mappings.Log
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:168)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:123)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.ofm.mnu.persistence.HibernateUtil.buildSessionFactory(HibernateUtil.java:20)
... 43 more
Caused by: java.lang.ClassNotFoundException: mappings.Log
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
... 52 more
这是我的配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">123789</property>
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/ofm_mnu_jvs</property>
<property name="hibernate.connection.username">user1</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<mapping resource="org/ofm/mnu/mappings/StOls2.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcIcsYear.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcFarmerCompany.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcFarmerCrop.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Ledger.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/SysUpdate.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/IcmtSub.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/VwJcsummary.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StRds.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StOls5.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Company.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/SrnSub.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Supplier.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/CostCenters.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StSpg.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/JcInOutCrop.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/EEmail.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/IcmtMain.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ImtMain.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcUser.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Temp.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Factory.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/VwAllStokMove.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/OldStock.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StFgs.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StOls1.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/CostVariable.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/JcMain.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/EdnSub.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Commission.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ItemCode.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StOls4.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/MonthEndBalance.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/GrnSub.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/RunningNo.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/VwAllStock.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcTemfarCrop.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcBlock.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/VwAllStokMove1.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/San.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Log.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/VwLedger.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ItemGrade.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Stocktype.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcFarmerCer.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcCetification.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/VwExcropBalance.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcFarmerAccount.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ActMonths.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Batchno.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Certification.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Uom.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/AUser.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/DesNote.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StOls3.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcSociety.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ItemLedger.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcFarmerReg.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StBfg.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ImtSub.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Mtn.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StRaw.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/GrnMain.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/Ccn.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/VwTotOutQty.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/EdnMain.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/SrnMain.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ItemCost.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/StOgs.hbm.xml"/>
<mapping resource="org/ofm/mnu/mappings/ZcTemfarMain.hbm.xml"/>
</session-factory>
</hibernate-configuration>
答案 0 :(得分:1)
可能是因为映射中缺少某些内容。 检查是否所有Pojos都使用限定的类名映射到表中。 如果您可以提供可以提供帮助的配置文件。