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

时间:2019-04-05 15:24:42

标签: hibernate mapping many-to-many one-to-many embeddable

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

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

这意味着不使用 Book DetailOrder 类进行映射。

我搜索了很多资源来解决它。我尝试了许多选择,但没有任何改变。 pk.book 的值无法从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>();

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;
    }

1 个答案:

答案 0 :(得分:0)

I solved the problem without using composite id .