我在休眠中的 saveOrUpdate() 函数有问题。我正在使用 Oracle 数据库。我需要使用自动生成的主键插入一行。我在hibernate注释中配置了这个id,如下所示,
模型.java
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column (name = "blush_id")
private Integer blsId;
但是在执行插入查询时,仅生成了 id。不执行 saveOrUpdate 方法。
DAO.java
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory){
this.sessionFactory = sessionFactory;
}
public void executeSaveOrUpdate(Object obj){
sessionFactory.getCurrentSession().saveOrUpdate(obj);//id generation occurs but the saveOrUpdate(obj) method is not executed
}
没有抛出错误或异常,但插入查询没有执行(而是在控制台的第二行生成序列),控制进入下一个进程。
安慰:
16:41:55,928 INFO [STDOUT] Hibernate: select category0_.cat_nbr as cat1_2_, category0_.added_by_name as added2_2_, category0_.added_ts as added3_2_, category0_.cat_dsc as cat4_2_, category0_.last_updt_by_name as last5_2_, category0_.last_updt_ts as last6_2_, category0_.mdse_grp_dsc as mdse7_2_, category0_.mdse_grp_nbr as mdse8_2_ from cvs_category_admin category0_ order by category0_.cat_nbr
16:41:56,037 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
16:41:56,084 INFO [STDOUT] Hibernate: select blushrules0_.blush_id as blush1_1_, blushrules0_.added_by_name as added2_1_, blushrules0_.added_ts as added3_1_, blushrules0_.blush_item_type as blush4_1_, blushrules0_.cat_nbr as cat5_1_, blushrules0_.subcat_nbr as subcat12_1_, blushrules0_.is_active as is6_1_, blushrules0_.is_added as is7_1_, blushrules0_.last_updt_by_name as last8_1_, blushrules0_.last_updt_ts as last9_1_, blushrules0_.sku_nbr as sku10_1_, blushrules0_.status as status1_ from blush_admin_rules blushrules0_ where blushrules0_.status='A'
请帮我解决这个问题..