ORA-00904:映射问题导致标识符无效



我有一个为此错误消息命名的问题,如下所示。

java.sql.SQLSyntaxErrorException: ORA-00904: "DETAILORDE1_"."BOOK": invalid identifier

它的意思是不要使用书籍详细订单类进行映射。

我搜索了许多资源来解决它。我尝试了很多选择,但没有任何变化。pk.book的价值不能从书类中感知到。

我该如何解决它?

以下是下面显示的代码。

@Entity
@Table(name="BOOK",catalog = "JSPPROJECTDATABASE")
public class Book implements Serializable{
...
@OneToMany(mappedBy = "pk.book", cascade=CascadeType.ALL)
private Set<DetailOrder> detailOrders = new HashSet<DetailOrder>();

详细订单

@Entity
@Table(name = "DETAIL_ORDER", catalog = "JSPPROJECTDATABASE")
@AssociationOverrides({
        @AssociationOverride(name = "pk.orders", 
            joinColumns = @JoinColumn(name = "ORDER_ID")),
        @AssociationOverride(name = "pk.book", 
            joinColumns = @JoinColumn(name = "BOOK_ID")) })
public class DetailOrder implements Serializable{
...
@EmbeddedId
    public DetailOrderId getPk() {
        return pk;
    }
    public void setPk(DetailOrderId pk) {
        this.pk = pk;
    }
    @Transient
    public Book getBook() {
        return getPk().getBook();
    }
    public void setBook(Book book) {
        getPk().setBook(book);
    }
    @Transient
    public Orders getOrders() {
        return getPk().getOrders();
    }
    public void setOrders(Orders orders) {
        getPk().setOrders(orders);
    }

DetailOrderId

@Embeddable
public class DetailOrderId implements Serializable{
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(name = "BOOK_ID")
    private Book book;
    @ManyToOne(cascade=CascadeType.ALL)
    @JoinColumn(name = "ORDER_ID")
    private Orders orders;
    public Book getBook() {
        return book;
    }
    public void setBook(Book book) {
        this.book = book;
    }
    public Orders getOrders() {
        return orders;
    }
    public void setOrders(Orders orders) {
        this.orders = orders;
    }

我在不使用复合 id 的情况下解决了这个问题。

相关内容

  • 没有找到相关文章

最新更新