hibernate 总结基础

1 java 类型,             hibernate 类型       sql
  java .lang.String       string               varchar
  java.lang.String        text                 Text
  int                     int                  INT
  char                    character             char(1)
  boolean                 boolean              bit
  byte[]                  binary               blob
  java.sql.Date           date                 Date
  java.sql.Timestamp      timestamp            Timestamp (载数据库中如果插入为null,数据库系统自动插入为当前值)
2 表述层--》业务逻辑层-》hibernate-》database
3
  Configuration config=new Configuration();
  config.add(Customer.class);
  sessionFactory=conf.buildSessionFactory();
  Session session=sessionFactory.openSession();
  Transaction tx;
  try{
   tx=session.beginTransaction();
   tx.commit();
  }catch(Exception e){
    if(tx!=null){
      tx.rollback();
    }
  }finally{
    session.close();
  }
4 数据库存取blob 对象
 1
   InputStream in=this.getClass().getResourceAsStream("photo.gif");
   byte[] buffer=new byte[in.available()]'
   in.read(buffer);
   customer.setImage(buffer);
 2 byte[] buffer=customer.get.getImage();
   File OutputStream fout=new fileOutStream("photo.gif");
   fout.write(buffer);
   fout.close();

posted on 2006-08-18 16:20 康文 阅读(205) 评论(0)  编辑  收藏 所属分类: java


只有注册用户登录后才能发表评论。


网站导航:
 
<2006年8月>
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜