我已经看到了一些关于此的问题,但我无法为我的问题找到解决方案。
我PositionHistory
声明了以下实体...
@Entity
@Table(name = "position_history")
@Cache (usage=CacheConcurrencyStrategy.READ_WRITE)
@AttributeOverride (name="id", column = @Column(name=PositionHistory.PRIMARY_KEY))
public class PositionHistory extends AbstractPersistable {
public static final String PRIMARY_KEY = "s_posn_history_id";
public static final String KEY = "positionHistory";
public static final String KEY_DATE = "date";
public static final String KEY_COMMENT = "comment";
// String field length definitions
public static final int LENGTH_COMMENTS = 1000;
// Instance Variables
private Date date;
private String comment;
@Column(name = "d_date", nullable = false)
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
@Column(name = "t_comment", length = LENGTH_COMMENTS)
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
// hashCode()
// equals()
// toString()
}
在PositionHistoryDaoImp
我试图删除一些行......
public void deletePositionHistory(Long positionId) {
getSession().createQuery("delete from position_history a where a.position_id=:id")
.setParameter("id", positionId).executeUpdate();
}
当我打电话时,deletePositionHistory
我收到以下错误...
ERROR a.g.q.d.v.s.c.CommandProcessorImpl:75 - org.hibernate.hql.ast.QuerySyntaxException: position_history is not mapped
如您所见,该表已映射到PositionHisotry
实体中并PositionHistoryDaoImp
扩展了实体。
我错过了什么或做错了什么?
非常感激你的帮助。
谢谢你。
Position
实体...
@Entity
@Table(name = "position")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@AttributeOverride(name = "id", column = @Column(name = Position.PRIMARY_KEY))
public class Position extends AbstractPersistableEffective {
...
public static final String PRIMARY_KEY = "s_posn_id";
public static final String KEY_ID = "positionId";
private List<PositionHistory> history = new ArrayList<PositionHistory>();
...
@OneToMany(fetch = FetchType.LAZY)
@Cascade({CascadeType.ALL, CascadeType.DELETE_ORPHAN})
@JoinColumn(name = Position.PRIMARY_KEY)
@IndexColumn(name = AbstractPersistable.INDEX_COLUMN)
public List<PositionHistory> getHistory() {
return history;
}
public void setHistory(List<PositionHistory> history) {
this.history = history;
}
}