JiveJdon Community Forums
在线179人   首页   主题表   培训咨询   标签   查搜   注册    登陆 RSS
首页 » 论坛 » 语言平台技术讨论
???en_US.forumThreadPrev.name??? 上一主题
RSS google yahoo 365Key网摘 CSDN网摘 添加到百度搜藏 POCO网摘 新浪ViVi QQ网摘
???en_US.forumThreadNext.name??? 下一主题
Go 共有 2 回复(1页) 阅读50次
 发表新帖子   回复该主题贴
Jxqy



发表文章:
注册时间: 2009年01月03日
悄悄话
个人博客
在线? 当前离线
我要关注该作者发言
spring+hibernate 没报错,可就是不能插入数据库,急急急!! 2009年04月04日 14:53 收藏关注本主题 到本帖网址 加入本帖到收藏夹 请用鼠标选择需要回复的文字再点按本回复键 回复该主题
标签
代码如下:
测试类:
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,数据库就是没数据,急死俺列!!

freebox



发表文章: 369
注册时间: 2008年03月01日
悄悄话
个人博客
在线? 当前离线
我要关注该作者发言
spring+hibernate 没报错,可就是不能插入数据库,急急急!! 2009年04月04日 16:51 收藏关注本主题 到本帖网址 加入本帖到收藏夹 请用鼠标选择需要回复的文字再点按本回复键 回复该主题
请检查事务配置,或更改提交模式。
Jxqy



发表文章: 3
注册时间: 2009年01月03日
悄悄话
个人博客
在线? 当前离线
我要关注该作者发言
回复:spring+hibernate 没报错,可就是不能插入数据库,急急急!! 2009年04月05日 17:10 收藏关注本主题 到本帖网址 加入本帖到收藏夹 请用鼠标选择需要回复的文字再点按本回复键 回复该主题
困扰了我两天的问题终于解决了,我没申明提交事务的代理。框架的整合对我像我这样的新手还真是不简单啊,从中我加深了对框架的更深一层次的理解,不错不错,以前是大大滴痛苦,现在是大大滴爽啊,呵呵!谢了,前辈!
[该贴被Jxqy于2009-04-05 17:11修改过]
标签
共有 2 回复(1页) Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
正在读取,请等待...
查询本论坛内 回复超过的热门帖子
标题
 
粗体: [b]文本[/b] 斜体: [i]文本[/i] 下划线 [u]文本[/u] 插入网上的图片 [img]http://wwww.xxxx.com/img.ext[/img] 插入代码 [code]程序代码[/code]  插入url链接 [url]http://url[/url] / [url=http://url]URL加下滑线[/url] 上传图片 word文档 Txt等附件
内容
  提交时自动拷贝以上内容到剪贴板 Ctrl+V可取出;提问题前先查询标签列表

使用帮助 手机m.jdon.com RSS add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的软件架构社区 推荐FireFox或Chrome快速浏览本站
OpenSource JIVEJDON Powered by JdonFramework Code © 2002-10 jdon.com

anti spam