Hello all,
Can anyone please help me with this query. The scenario is i need to get data from two different tables and show them in jtable. For this i have used secondary table annotation to create a single class for the purpose. Now i need to create a query for this but i am having trouble with it. The query is :
select pi.productcode , pi.productname , pi.barcodeno , in.saleunitprice , in.quantity from inventory as in inner join in.ProductInformation as pi WHERE pi.productid = in.productid
Quote:
Where productinformation and inventory are two tables from which i want to get data from and product Id is the primary key in both of them
But it keeps giving me this error:
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: in near line 1, column 58 [ select pi.productcode , pi.productname , pi.barcodeno , in.saleunitprice , in.quantity from inventory as in inner join in.ProductInformation as pi WHERE pi.productid = in.productid ]
the class is :
@Entity
@Table(name="productinformation")
@SecondaryTable(name="inventory")
public class InventoryCombined {
String allocatedlocation;
Integer allocationid;
Integer productid;
String sellable_notsellable;
Date sellablefromdate;
Date sellabletill;
Integer shelflocation;
Integer quantity;
Integer receivedquantity;
Integer soldquantity;
Integer inhandquantity;
Integer costtotalprice;
Integer saleunitprice;
Integer notsellablereasoncode;
Integer inventorybarcode;
Integer productcode;
String productname;
Integer barcodeno;
String productcomptype;
@Column(table="inventory")
public Integer getAllocationid() {
return allocationid;
}
public void setAllocationid(Integer allocationid) {
this.allocationid = allocationid;
}
@Column(table="inventory")
public String getAllocatedlocation() {
return allocatedlocation;
}
public void setAllocatedlocation(String allocatedlocation) {
this.allocatedlocation = allocatedlocation;
}
@Id
@GeneratedValue
public Integer getProductid() {
return productid;
}
public void setProductid(Integer productid) {
this.productid = productid;
}
@Column(table="inventory")
public String getSellable_notsellable() {
return sellable_notsellable;
}
public void setSellable_notsellable(String sellable_notsellable) {
this.sellable_notsellable = sellable_notsellable;
}
@Column(table="inventory")
public Date getSellablefromdate() {
return sellablefromdate;
}
public void setSellablefromdate(Date sellablefromdate) {
this.sellablefromdate = sellablefromdate;
}
@Column(table="inventory")
public Date getSellabletill() {
return sellabletill;
}
public void setSellabletill(Date sellabletill) {
this.sellabletill = sellabletill;
}
@Column(table="inventory")
public Integer getShelflocation() {
return shelflocation;
}
public void setShelflocation(Integer shelflocation) {
this.shelflocation = shelflocation;
}
@Column(table="inventory")
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
@Column(table="inventory")
public Integer getReceivedquantity() {
return receivedquantity;
}
public void setReceivedquantity(Integer receivedquantity) {
this.receivedquantity = receivedquantity;
}
@Column(table="inventory")
public Integer getSoldquantity() {
return soldquantity;
}
public void setSoldquantity(Integer soldquantity) {
this.soldquantity = soldquantity;
}
@Column(table="inventory")
public Integer getInhandquantity() {
return inhandquantity;
}
public void setInhandquantity(Integer inhandquantity) {
this.inhandquantity = inhandquantity;
}
@Column(table="inventory")
public Integer getCosttotalprice() {
return costtotalprice;
}
public void setCosttotalprice(Integer costtotalprice) {
this.costtotalprice = costtotalprice;
}
@Column(table="inventory")
public Integer getSaleunitprice() {
return saleunitprice;
}
public void setSaleunitprice(Integer saleunitprice) {
this.saleunitprice = saleunitprice;
}
@Column(table="inventory")
public Integer getNotsellablereasoncode() {
return notsellablereasoncode;
}
public void setNotsellablereasoncode(Integer notsellablereasoncode) {
this.notsellablereasoncode = notsellablereasoncode;
}
@Column(table="inventory")
public Integer getInventorybarcode() {
return inventorybarcode;
}
public void setInventorybarcode(Integer inventorybarcode) {
this.inventorybarcode = inventorybarcode;
}
I am sorry for the long post but it was necessary to put the class here.
SO please can anyone help me this. I would be very thankful to him.
Haris Tasawar.