English 中文(简体)
Hibernate org.hibernate.hql.ast. QuerySyntaxException mis
原标题:Hibernate org.hibernate.hql.ast.QuerySyntaxException error

I have seen a few questions about this but I am unable to derive a solution to my problem.

我有以下<代码>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()
}

载于<代码>。 履历: 我试图删除一些行文......

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 

如你所知,该表已在<条码>中绘制。 实体和<代码>PositionHistoryDaoImp延伸至该实体。

我失踪或作错了吗?

你的帮助非常受赞赏。

谢谢。


www.un.org/Depts/DGACM/index_russian.htm

@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;
    }
}
最佳回答

你在问询中使用表格名称,而不是实体名称。 修改:

getSession().createQuery("delete from position_history a where a.position_id=:id")

:

getSession().createQuery("delete from PositionHistory a where a.id =:id")
问题回答

更改hibernate.query. Factory_class property in hibernate.cfg.xml 页: 1 我希望这将有助于你。

<property name="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</property>




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签