标题: 我今天终于用MVC完成了一个项目,再次分享 [打印本页] 作者: 樊占江 时间: 2012-8-3 16:37 标题: 我今天终于用MVC完成了一个项目,再次分享 先是数据库(我用的orcal)
create table ACCOUNTINFO
(
id number(11) primary key not null,
account_number varchar2(16) not null,
account_password varchar2(6) not null,
account_money number(11) not null,
account_stutus number(11) not null--0可用,1不可用
);
create sequence seq_accountinfo;
insert into ACCOUNTINFO values(seq_accountinfo.nextval,'6221000000000001','123456',6000,0);
insert into ACCOUNTINFO values(seq_accountinfo.nextval,'6221000000000002','222222',8000,0);
insert into ACCOUNTINFO values(seq_accountinfo.nextval,'6221000000000003','333333',1000,1);
insert into ACCOUNTINFO values(seq_accountinfo.nextval,'6221000000000004','444444',2000,0);
/**
* Configures and provides access to Hibernate sessions, tied to the
* current thread of execution. Follows the Thread Local Session
* pattern, see {@link http://hibernate.org/42.html }.
*/
public class HibernateUtil {
/**
* Location of hibernate.cfg.xml file.
* Location should be on the classpath as Hibernate uses
* #resourceAsStream style lookup for its configuration file.
* The default classpath location of the hibernate config file is
* in the default package. Use #setConfigFile() to update
* the location of the configuration file for the current session.
*/
private static String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";
private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();
private static Configuration configuration = new Configuration();
private static org.hibernate.SessionFactory sessionFactory;
private static String configFile = CONFIG_FILE_LOCATION;
/**
* return session factory
*
* session factory will be rebuilded in the next call
*/
public static void setConfigFile(String configFile) {
HibernateUtil.configFile = configFile;
sessionFactory = null;
}