MyEclipse 下启动得到
插入代码
Configuration cfg = new Configuration().configure();
SessionFactory sf = cfg.buildSessionFactory();
session = sf.openSession();
tr = session.beginTransaction();
Card card=new Card("熊熊", "2014-2-12");
Card_type cardTp=(Card_type) session.get(Card_type.class, 1);
card.setCard_tp(cardTp);
session.save(card);
tr.commit();
session.close();
数据库:
因为card_id 自增中底数为1,每次插入数据增加1 但是我用hibernate 插入就会出现问题。