0
考慮以下三類mappedBy在休眠中不能與繼承一起使用。任何解決方法?
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@SequenceGenerator(name = "GenericIdGenerator",
sequenceName = "GENERIC_SEQ", initialValue = 1)
@Table(name = "tbl_datastores")
public abstract class DataStore implements Serializable {
private int storeId;
public getStoreId()
{
return this.storeId;
}
//..other code removed for brevity.
}
@Entity
@Table(name = "tbl_filedatastores")
public class FileDataStore extends DataStore {
private Set<FieldDetails> fields;
@OneToMany(mappedBy="datastore")
public getFields()
{
return this.fields;
}
//..other code removed for brevity.
}
@Entity
@Table(name="tbl_fields")
@SequenceGenerator(name = "GenericIdGenerator",
sequenceName = "GENERIC_SEQ", initialValue = 1)
public class FieldDetails
{
private int fieldId;
private DataStore datastore;
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="GenericIdGenerator")
@Column(name="id", nullable=false, updatable=false)
public int getFieldId() {
return fieldId;
}
@ManyToOne
@JoinColumn (name="datastore_id", referencedColumnName="id")
public FileDataStore getDataStore(){
return datastore;
}
//..other code removed for brevity.
}
當我運行這段代碼,我得到以下錯誤...
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: entities.FieldDetails.datastore in entities.FileDataStore.fields
我已經看到了一些posts,似乎表明它是一個Hibernate的問題,但我無法在任何地方獲得妥善的解決方案
你可以請建議一種方法來映射這種休眠或解決方法嗎?
預先感謝您!
謝謝axtavt!這很有效!對我來說這真是太不可思議了。 – ajay 2011-05-04 09:01:31