【求助】[hibernate]每运行一次程序,为何用session.save()会把表中的行替换而不是增加?
发现每运行一次程序,程序中的session.save代码都会把原数据库表中的行清空,再插入;而不是生成identity,插入到最后。请问有啥解决办法?
console中的显示信息:
Hibernate: insert into Star (name, xxxx) values (?, xx)
select @@identity
程序代码:
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Star star = new Star();
star.setName("aa");
star.set...("aa");
session.save(star);
session.getTransaction().commit();
环境:hibernate3.1,sybase 12.5
maping:
<class name="Star">
<id name="id">
<generator class="native"/>
</id>
<property name="name" length="10" not-null="true"/>
<property name="age" length="4" not-null="false"/>
<property name="resume" length="1000" not-null="true"/>
<property name="sign" length="500" not-null="false"/>
<property name="phone" length="13" not-null="true"/>
<property name="imagePath" length="100" not-null="true"/>
</class>
console中的显示信息:
Hibernate: insert into Star (name, xxxx) values (?, xx)
select @@identity
程序代码:
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Star star = new Star();
star.setName("aa");
star.set...("aa");
session.save(star);
session.getTransaction().commit();
环境:hibernate3.1,sybase 12.5
maping:
<class name="Star">
<id name="id">
<generator class="native"/>
</id>
<property name="name" length="10" not-null="true"/>
<property name="age" length="4" not-null="false"/>
<property name="resume" length="1000" not-null="true"/>
<property name="sign" length="500" not-null="false"/>
<property name="phone" length="13" not-null="true"/>
<property name="imagePath" length="100" not-null="true"/>
</class>
...全文
相关推荐
医学生在线学习交流平台 SSM毕业设计 源码+数据库+论文(JAVA+SpringBoot+Vue.JS)RR.zip
医学生在线学习交流平台 SSM毕业设计 源码+数据库+论文(JAVA+SpringBoot+Vue.JS)RR
homework2-mpmc
homework2-mpmc
家庭果园种植管理-入门版-清新雅致.docx
家庭果园种植管理-入门版-清新雅致
年终工作总结-互联网-清新雅致.docx
年终工作总结-互联网-清新雅致
高校如何通过技术转移服务提升成果转化率,助力区域创新发展?.docx
科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。


