Spring save method: saves the entity object

save(Object entity)

Example

public static void main(String[] args){
  ApplicationContext context = new ClassPathXmlApplicationContext("cfg/XMLConfig.xml");//加载配置文件
  Dao dao = (Dao)context.getBean("dao");  //创建Dao
  TbUser user = new TbUser();
  user.setName("明日");
  user.setSex("男");
  user.setAge(20);
  dao.getHibernateTemplate().save(user);  //执行保存方法
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>