jadeite100
Programmer
Hi:
I have following EJB QL:
SELECT OBJECT(p) FROM Product p
WHERE p.homeCategory = ?1
which for some weird reason is returning only the first record in the table Product.
In the table product there is a foreign key called categoryId that points to the primary key of the field CategoryId of the table Category.
There is three records in the table Product that contains a foregn key of CategoryId=1, THEREFORE THE ABOVE SQL should return three records from the Product table but the result only returns the first record of the Product table no matter what the value is for the first record of the CategoryId field for the Product Table.
Here are the table structure and data:
Product Table:
ProductId BrandName CategoryId
1 Hush Puppies 2
2 Minnetonka 3
3 Anne klein 1
4 DKNY Mollie 1
5 Bass Kiltie 2
I passed a categoryId of 1 for the above EJB-QL but for some reason, it only returns the first record
of the Product Table. It doesn't seem to matter what the value of the CategoryId. That seems strange.
Is my EJB/QL correct?
Here is the client jsp code that calls the ejb:
<%
Context jndiContext = getInitialContext();
Object objCategory = jndiContext.lookup("CategoryHomeLocal");
CategoryHomeLocal categoryHome = (CategoryHomeLocal)objCategory;
Integer categoryId = new Integer(categoryIdString);
CategoryLocal category = categoryHome.findByPrimaryKey(categoryId);
Collection products = categoryHome.selectProduct(category);
Iterator iterator = products.iterator();
%>
Any hint would be greatly appreciated.
Yours,
Frustrated.
I have following EJB QL:
SELECT OBJECT(p) FROM Product p
WHERE p.homeCategory = ?1
which for some weird reason is returning only the first record in the table Product.
In the table product there is a foreign key called categoryId that points to the primary key of the field CategoryId of the table Category.
There is three records in the table Product that contains a foregn key of CategoryId=1, THEREFORE THE ABOVE SQL should return three records from the Product table but the result only returns the first record of the Product table no matter what the value is for the first record of the CategoryId field for the Product Table.
Here are the table structure and data:
Product Table:
ProductId BrandName CategoryId
1 Hush Puppies 2
2 Minnetonka 3
3 Anne klein 1
4 DKNY Mollie 1
5 Bass Kiltie 2
I passed a categoryId of 1 for the above EJB-QL but for some reason, it only returns the first record
of the Product Table. It doesn't seem to matter what the value of the CategoryId. That seems strange.
Is my EJB/QL correct?
Here is the client jsp code that calls the ejb:
<%
Context jndiContext = getInitialContext();
Object objCategory = jndiContext.lookup("CategoryHomeLocal");
CategoryHomeLocal categoryHome = (CategoryHomeLocal)objCategory;
Integer categoryId = new Integer(categoryIdString);
CategoryLocal category = categoryHome.findByPrimaryKey(categoryId);
Collection products = categoryHome.selectProduct(category);
Iterator iterator = products.iterator();
%>
Any hint would be greatly appreciated.
Yours,
Frustrated.