|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
诸如RMI,EJB等一些技术并不是你说的那么复杂,而是它们把一些复杂的工具封装成不复杂的工具了,理解这些工具是需要些时间。我问你,.net网页编程里有这些工具吗?要简单多少?。
测试代码:
packagecom.hb3.pack_01;
importorg.hibernate.Session;
importorg.hibernate.SessionFactory;
importorg.hibernate.Transaction;
importorg.hibernate.cfg.Configuration;
importcom.hb3.pack_01.model.User;
publicclassBusinessService{
publicstaticvoidmain(String[]args){
Configurationconfig=newConfiguration().configure();
SessionFactorysessionFactory=config.buildSessionFactory();
Sessionsession=sessionFactory.openSession();
//insert
Useruser=newUser();
user.setName("chenyan");
//user.setAge(newInteger(23));
Transactiontx=session.beginTransaction();
session.save(user);
tx.commit();
//get
user=(User)session.get(User.class,user.getId());
System.out.println(user.getAge());
//update
user.setAge(newInteger(24));
tx=session.beginTransaction();
session.update(user);
tx.commit();
//load
user=(User)session.load(User.class,user.getId());
System.out.println(user.getAge());
//delete
tx=session.beginTransaction();
session.delete(user);
tx.commit();
session.close();
sessionFactory.close();
}
}
实行了局:
11:50:50,750WARNConfigurationFactory:127-Noconfigurationfound.Configuringehcachefromehcache-failsafe.xmlfoundintheclasspath:jar:file:/D:/Java/MyEclipse%206.0/workspace/hb3demo/ehcache-1.2.3.jar!/ehcache-failsafe.xml
11:50:51,156WARNEhCacheProvider:93-Couldnotfindconfiguration[org.hibernate.cache.UpdateTimestampsCache];usingdefaults.
11:50:51,171WARNEhCacheProvider:93-Couldnotfindconfiguration[org.hibernate.cache.StandardQueryCache];usingdefaults.
Hibernate:insertintouser(name,age)values(?,?)
null
Hibernate:updateusersetname=?,age=?whereid=?
24
<p>
如果你学习的是市场营销,是销售,也许参加大课堂的学习会更合适,因为你的工作能力中有个基础就是搭建自己的人脉, |
|