我正在爲我的應用程序使用Hibernate(3.0)+ Oracle DB(10g)。ORACLE:org.hibernate.ObjectNotFoundException:不存在具有給定標識符的行
我的域對象都像PluginConfig.java
@Entity
@Table(name = "plugin_config" , schema = "test")
@org.hibernate.annotations.Cache(usage =org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
public class Config {
private static final long serialVersionUID = -92627830L;
/** This object's id */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected long id;
@OneToOne
@JoinColumn(name = "plugin_id")
private Plugin plugin;
@Column(name = "config_name")
@NaturalId(mutable = true)
private String name;
@Column(name = "config_desc")
private String description;
另一個域對象Plugin.java
@Entity
@Table(name = "plugin", schema = "test")
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.READ_WRITE)
public class Plugin implements Serializable {
private static final long serialVersionUID = 5694761325202724778L;
/** This object's id */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected long id;
@Column(name = "plugin_name")
@NaturalId
private String pluginName;
@OneToOne
@JoinColumn(name = "plugin_config_id")
private PluginConfig pluginConfig;
@Column(name = "plugin_desc")
private String description;
每當我試着通過數據庫服務方法加載插件(使用@Transactional註解,因此它會加載它的所有子項)我得到以下錯誤
org.hibernate.ObjectNotFoundEx ception:不存在具有給定標識符的行:[PluginConfig#53]
plugin_config表中實際上沒有與id = 53
的行。 也沒有插件表條目plugin_config_id=53
。
那麼從何處挑選這些值呢? 我注意到這裏有一件事,值「53」實際上是來自plugin_config表的行號,它應該已被緩存。
見下面的圖片:
這是我的查詢應該尋找插件配置。但它試圖用標識符#53(行號:)而不是#95(主鍵「id」的值)進行搜索。
我在哪裏可能會出錯?
查看圖片! [1]:http://i.stack.imgur.com/hVpob.png – GSG
基於'plugin_config_id'的對應對象是否存在?你如何試圖在'plugin_config'表中加載實體? –
你是如何生成你的表格ID的? –