首页 > csdn导入, Space导入, 技术, 未分类 > Hibernate里的重复记录

Hibernate里的重复记录

前几天APIS爆出了个奇怪的BUG:某个小组关闭任务后,任务自动被duplicate,然后子任务也丢失了。手工查看数据库,发现数据库里居然只有一条Task记录,Hibernate却返回两条。findById(id为主键)居然会返回两条记录,这就奇了怪了。

用Firebug看记录,发现抛出了异常。”More than one row with the given identifier was found”。可是数据库里明明只有一条记录啊。二话不说google发现了这个post,顿时想起来由于关联(association)而产生万恶的outer join。排查了几个关联(出问题的那个类偏偏是最heavily-associated),终于在一个与Part类<one-to-one>上发现了问题。虽然是<one-to-one>关联,却发现另外一方(Part)存在重复的记录,直接影响到Task类。找到原因,assign给Part类的责任人,问题解决。

  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


Warning: fsockopen() has been disabled for security reasons in /home/onlymars/public_html/wp/wp-includes/class-snoopy.php on line 1148