在Hibernate中,我在运行时收到以下错误
1.employee.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package ="com.hibernate.basic">
<class name="Employee" table="Employee" lazy="false">
<id name="id" column="EMPID" type ="int">
<generator class="increment"></generator>
</id>
<property name="firstName" column="NAME"></property>
<property name="lastName"column="LNAME"></property>
</class>
<?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="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@172.16.3.94:1521:EAMABP</property>
<property name="connection.username">EAM</property>
<property name="connection.password">EAM</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="current_session_context_class">thread</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping resource="employee.hbm.xml" />
</session-factory>
</hibernate-configuration>
package com.hibernate.basic;
public class Employee {
private int id;
private String FName, LName;
public String getFName() {
return FName;
}
public void setFName(String FName) {
this.FName = FName;
}
public String getLName() {
return LName;
}
public void setLName(String LName) {
this.LName = LName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
4.storedata.java
package com.hibernate.basic;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class StoreData {
public static void main(String[] args) {
// creating configuration object
Configuration cfg = new Configuration();
cfg.configure("hibernate.cfg.xml");// populates the data of the
// configuration file
// creating seession factory object
SessionFactory factory = cfg.buildSessionFactory();
// creating session object
Session session = factory.openSession();
// creating transaction object
Transaction t = session.beginTransaction();
Employee e1 = new Employee();
e1.setId(115);
e1.setFName("sonoo");
e1.setLName("jaiswal");
session.persist(e1);// persisting the object
t.commit();// transaction is commited
session.close();
System.out.println("successfully saved");
}
}
执行后出错:
log4j:警告找不到logger(org.hibernate.cfg.environment)的附加程序。log4j:警告请正确初始化log4j系统。线程“main”org.hibernate.invalidmappingException中的异常:无法解析来自资源employee.hbm.xml(位于org.hibernate.cfg.configuration.java:569)(位于org.hibernate.cfg.configuration.parseMappingElement(配置.java:1587)(位于org.hibernate.cfg.configuration.parseSessionFactory(配置.java:1555)(位于org.hibernate.cfg.configuration.doConfigure(配置.java:1534)(位于通过属性规范,“>”或“/>”。嵌套异常:元素类型“property”后面必须跟属性规范“>”或“/>”。在org.dom4j.io.saxreader.read(saxreader.java:482)在org.hibernate.cfg.configuration.addInputStream(configuration.java:499)...7更多
name=“lastname”
和column
之间缺少空格。
好吧,我遇到了一个错误,我不太清楚为什么,希望您能提供帮助。当我尝试运行它时,会遇到以下问题。 线程“main”java中出现异常。util。java中的NoSuchElementException。util。扫描仪。java上的throwFor(Scanner.java:907)。util。扫描仪。下一步(Scanner.java:1530)在java。util。扫描仪。nextInt(Scan
Traceback(最近一次调用last):File " c:\ users \ administrator \ appdata \ local \ programs \ python \ python 36 \ lib \ runpy。py”,第193行,in _ run _ module _ as _ main“main”,mod_spec)文件“c:\ users \ administrat
SQL错误[42601]:在“”后面发现意外标记“(标签CHAR(30),值VARCHAR(1))”。所需的标记可能包括:“E@DateType TABLE”..SQLCODE=-104,SQLSTATE=42601,Driver=4.21.29
错误:任务“:app:ProcessDebugResources”执行失败。 com.android.ide.common.Process.processException:org.gradle.Process.internal.exeception:Process“command”c:\users\mohamed sallam\appdata\local\android\sdk\build-to
异常线程"main"java.lang.IllegalStateExcture:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统属性设置;有关详细信息,请参阅https://github.com/mozilla/geckodriver.最新版本可以从https://github.com/mozilla/geckodriver/releases下载 这是我的密码。