spring+hibernate 沒報錯,可就是不能插入資料庫,急急急!!

Jxqy發表於2009-04-04
程式碼如下:
測試類:
package com.test;

import com.dao.PersonDao;
import com.po.Person;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;


public class PersonDaoTest {
public static void main(String[] args) throws Exception {
ApplicationContext applicationContext=new FileSystemXmlApplicationContext("WebRoot/WEB-INF/classes/applicationContext.xml");
PersonDao personDao=(PersonDao)applicationContext.getBean("personDaoImpl");

Person person=new Person();
person.setAge(22);
person.setName("xqy1");

System.out.println("匯入資料開始.......");
personDao.insert(person);
System.out.println("匯入資料結束.......");



}
}

配置檔案:Person.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">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.po.Person" table="person">
<id name="id" type="java.lang.String">
<column name="id" length="32" />
<generator class="uuid.hex"></generator>
</id>
<property name="name" type="java.lang.String">
<column name="name" length="32" />
</property>
<property name="age" type="java.lang.Integer">
<column name="age" />
</property>
</class>
</hibernate-mapping>

執行結果:
log4j:WARN No appenders could be found for logger (org.springframework.context.support.FileSystemXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
匯入資料開始.......
匯入資料結束.......

我用的是mysql,資料庫就是沒資料,急死俺列!!

相關文章