dyl的gravatar头像
dyl 2014-05-21 21:34:07

Hibernate基础教程的Demo代码下载

项目截图:

Hibernate基础教程的Demo代码下载

sql:


 drop database if exists hibernate;
 create database hibernate default charset ='utf8';
 drop table if exists stock;
 create table stock(
 STOCK_ID int(10) unsigned primary key auto_increment,
 STOCK_CODE varchar(10) not null unique,
 STOCK_NAME varchar(20) not null unique)engine=innodb default charset='utf8';

Demo运行入口:

package com.zuidaima.model.context;

import org.hibernate.Session;

import com.zuidaima.model.Stock;
import com.zuidaima.util.HibernateUtil;

/**
 * Demo入口
 * @author dyl
 *
 */
public class Context {

	public static void main(String[] args) {
        Session session = HibernateUtil.getSessionFactory().openSession();
 
        session.beginTransaction();
        
        Stock stock = new Stock();
        stock.setStockCode("2014");
        stock.setStockName("zuidaima");
        session.save(stock);
        
        //提交事务
        session.getTransaction().commit();

	}

}

运行截图:

Hibernate基础教程的Demo代码下载


最代码官方编辑于2016-8-20 11:09:24


打赏

文件名:HibernateDemo.zip,文件大小:5.419K 下载
  • /
      • /HibernateDemo
        • /HibernateDemo/.classpath
        • /HibernateDemo/.project
          • /HibernateDemo/.settings
            • /HibernateDemo/.settings/org.eclipse.jdt.core.prefs
            • /HibernateDemo/.settings/org.maven.ide.eclipse.prefs
        • /HibernateDemo/pom.xml
          • /HibernateDemo/sql
            • /HibernateDemo/sql/init.sql
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友