ORA-00904: 2 tables mapping : invalid identifier

#1

I have a test method to update book information in Junit. But I have an error thrown on the console.

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

I can connect with Book and DetailOrder classes with Composite ID in many to many relationship.

In Book Class,

@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 class

@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{

	private DetailOrderId pk = new DetailOrderId();
	
	@Column(name="QUANTITY")
	private int quantity;
	
	@Column(name="SUBTOTAL")
	private float subTotal;
	
	public DetailOrder() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	@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);
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public float getSubTotal() {
		return subTotal;
	}

	public void setSubTotal(float subTotal) {
		this.subTotal = subTotal;
	}

}

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;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((book == null) ? 0 : book.hashCode());
		result = prime * result + ((orders == null) ? 0 : orders.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DetailOrderId other = (DetailOrderId) obj;
		if (book == null) {
			if (other.book != null)
				return false;
		} else if (!book.equals(other.book))
			return false;
		if (orders == null) {
			if (other.orders != null)
				return false;
		} else if (!orders.equals(other.orders))
			return false;
		return true;
	}
	

}

How can I fix it?

0 Likes