繼續(xù)關(guān)注我的C語言學(xué)習(xí)博客

          林臨的地盤

          java學(xué)習(xí)博客
          posts - 44, comments - 28, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          用hibernate建表 續(xù)

          Posted on 2006-07-28 17:02 lubaolin 閱讀(389) 評論(0)  編輯  收藏
          package hibernatedemo;

          import hibernatedemo.person;
          import java.util.*;

          import net.sf.hibernate.Query;
          import net.sf.hibernate.Session;
          import net.sf.hibernate.SessionFactory;
          import net.sf.hibernate.cfg.Configuration;
          import net.sf.hibernate.tool.hbm2ddl.SchemaExport;

          publicclass Test {
          publicstaticvoid main(String[] args)throwsException{
          ? ?Configuration cfg = new Configuration().addClass(person.class);
          ? ?SessionFactory sessions = cfg.buildSessionFactory();
          ? ?new SchemaExport(cfg).create(true, true);
          ? ?Session s = sessions.openSession();
          ? ?Query q = s.createQuery("from person");
          ? ?for(Iterator it = q.iterate();it.hasNext();){
          ? ? ?person b = (person)it.next();
          ? ? ?System.out.println("##name:"+b.getName());
          ? ?}
          }
          }

          引自:http://www.aygfsteel.com/TrampEagle/articles/29972.html

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          繼續(xù)關(guān)注我的C語言學(xué)習(xí)博客
          主站蜘蛛池模板: 喜德县| 淮滨县| 中西区| 澜沧| 新化县| 株洲县| 丰镇市| 拜城县| 新泰市| 西和县| 石楼县| 乐安县| 博爱县| 五家渠市| 新丰县| 林芝县| 唐海县| 赣榆县| 连南| 吴旗县| 南丹县| 康定县| 廉江市| 抚远县| 赤城县| 太白县| 江北区| 清徐县| 贺兰县| 社会| 全椒县| 河东区| 邓州市| 萨嘎县| 铁岭县| 涟源市| 华阴市| 沧源| 葫芦岛市| 枣庄市| 凯里市|