Java 无法分析来自资源hbm/xml/Items.hbm.xml和重复的类/实体映射bean.ItemTable的映射文档
这是我的第一个Hibernate应用程序。被困在这里两天了。我需要帮助。包裹上方视图:小写字母:包裹大写字母:类别 src->dao->OPERATIONS.javasrc->hbm.xml->items.hbm.xml src->Hibernate.cfg.xmlJava 无法分析来自资源hbm/xml/Items.hbm.xml和重复的类/实体映射bean.ItemTable的映射文档,java,xml,hibernate,Java,Xml,Hibernate,这是我的第一个Hibernate应用程序。被困在这里两天了。我需要帮助。包裹上方视图:小写字母:包裹大写字母:类别 src->dao->OPERATIONS.javasrc->hbm.xml->items.hbm.xml src->Hibernate.cfg.xml public class Operations { public static void main(String [] args){ Configuration cfg=new Configuration();
public class Operations {
public static void main(String [] args){
Configuration cfg=new Configuration();
cfg.configure("Hibernate.cfg.xml");
SessionFactory sf=null;
sf=cfg.configure().buildSessionFactory();
Session sess=sf.openSession();
if(sess==null)
System.out.println("Session Object : NULL: "+sess);
Transaction tx=sess.beginTransaction();
ItemTable ob=new ItemTable();
ob.setItemCode(1);
ob.setItemName("ATTA");
sess.save(ob);
sess.flush();//generates SQL queries
tx.commit();
sess.close();
}
}
Hibernate.cfg.xml文件
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:Oracle:thin:@localhost:1521:xe</property>
<property name ="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.username">system</property>
<property name="hibernate.connection.password">admin1234</property>
<property name="show_sql">true</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- To display the sql generated in console -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
<!-- For JDBC transactions -->
<mapping resource="hbm/xml/Items.hbm.xml"/>
</session-factory>
</hibernate-configuration>
oracle.jdbc.driver.OracleDriver
jdbc:Oracle:thin:@localhost:1521:xe
org.hibernate.dialen.oraclealent
系统
管理员1234
真的
假的
org.hibernate.transaction.jdbc事务工厂
真的
真的
真的
Items.hfm.xml文件
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping auto-import ="true">
<class name="bean.ItemTable" table ="items">
<!-- Every class must have an Id(Primary Key) or Composite_Id -->
<id name ="itemCode" column="ITEMCODE" type="integer">
<generator class="assigned"></generator>
</id>
<property name="itemName" column="ITEMNAME" type="string"/>
</class>
</hibernate-mapping>