我是 Java Hibernate 的新手。我正在编写一个基本程序,但收到此错误“找不到类 pack1.Manager1”... Manager1 是我的主类。任何帮助将不胜感激..
我的文件如下:
1)休眠/src/pack1/Employeeh.hbm.xml:
<hibernate-mapping package="pack1">
<class name="Employeeh" table="EMPLOYEEH">
<id name="empid" column="EMP_ID" type="long">
<generator class="native"/>
</id>
<property name="fname" column="FNAME">
</property>
<property name="email"/>
</class>
</hibernate-mapping>
2)休眠/src/pack1/Employeeh.java:
package pack1;
public class Employeeh
{
private int empid;
private String fname;
private String email;
public int getEmpid()
{
return empid;
}
..
}
3)休眠/src/pack1/Manager1.java:
package pack1;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class Manager1
{
public static void main(String[] args)
{
Configuration c1=new Configuration();
c1.configure();
SessionFactory sf=c1.buildSessionFactory();
Session s1=sf.openSession();
Employeeh e1=new Employeeh();
e1.setEmpid(1);
e1.setFname("gourav");
e1.setEmail("a@b.com");
}
}
4)休眠/src/hibernate.cfg.xml:
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username">gourav</property>
<property name="hibernate.connection.password">baba</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<mapping resource="pack1/Employeeh.hbm.xml"/>
</session-factory>
</hibernate-configuration>
提前致谢..