package com.hurricane.action;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import com.hurricane.entity.Classes;
import com.hurricane.entity.Person;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
public String Name;
public int Age;
public Person PersonShana;
static SessionFactory sessionFactory;
public String getResult() {
return Result;
}
public Person getPersonShana() {
return PersonShana;
}
public void setPersonShana(Person personShana) {
PersonShana = personShana;
}
public void setResult(String result) {
Result = result;
}
public String Result;
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public int getAge() {
return Age;
}
public void setAge(int age) {
Age = age;
}
@Override
public String execute() throws Exception {
Session ss = getSession();
ss.beginTransaction();
/*ss.save(PersonShana);
ss.getTransaction().commit();*/
Classes classes = new Classes();
classes.setName("语文");
classes.setCreateTime(new Date());
ss.save(classes);
ss.getTransaction().commit();
ss.close();
return "success";
}
static Session getSession() {
if (sessionFactory == null) {
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure().build();
sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
}
return sessionFactory.openSession();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
使用Maven Hibernate5 之反向工程
共38个文件
xml:16个
prefs:5个
class:3个
需积分: 9 9 下载量 130 浏览量
2016-07-15
12:36:38
上传
评论 1
收藏 22KB RAR 举报
温馨提示
在实际开发中,一般都是表结构先设计好,再实现代码,所以根据表结构生成数据库实体类比较常见。说不如做,行动吧 博客中有详细说明。
资源推荐
资源详情
资源评论
收起资源包目录
webtest.rar (38个子文件)
webtest
.project 2KB
.springBeans 472B
src
test
java
main
webapp
WEB-INF
lib
jdbc2_0-stdext.jar 7KB
web.xml 730B
index.jsp 407B
resources
struts.xml 590B
hibernate.cfg.xml 869B
application.xml 632B
Classes.hbm.xml 808B
Person.hbm.xml 606B
hibernate.reveng.xml 367B
java
com
hurricane
action
LoginAction.java 2KB
entity
Person.java 634B
Classes.java 852B
target
m2e-wtp
web-resources
META-INF
MANIFEST.MF 110B
maven
com.hurricane.struts
webtest
pom.properties 228B
pom.xml 2KB
classes
struts.xml 590B
hibernate.cfg.xml 869B
application.xml 632B
com
hurricane
action
LoginAction.class 3KB
entity
Classes.class 1KB
Person.class 975B
Classes.hbm.xml 808B
Person.hbm.xml 606B
hibernate.reveng.xml 367B
test-classes
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 430B
org.eclipse.wst.validation.prefs 50B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 144B
org.eclipse.wst.common.component 1020B
org.hibernate.eclipse.console.prefs 87B
.jsdtscope 639B
pom.xml 2KB
.classpath 1KB
共 38 条
- 1
资源评论
宛飓如风
- 粉丝: 13
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功