This is an interesting problem!
The OjbStore solution plugs into the JDO reference implementation.
Transaction-management and query processing is handled on the JDO RI level but not within the plugin.
That is if you are performing a filter query on the Product class the JDO RI works as follows:
1. it ask the StoreManager (in our case the OjbStoreManager) to load the *extent* of class Product. The Storemanager then executes a "select * from product" to load all Product instances.
2. Then filtering is done in the higher levels of the JDO RI.
(Just have a look at the five classes forming the OjbSTore plugin. The code is quite easy to understand)
Of course this is inefficient for large tables! But as the JDO RI StoreMananger contract does not provide any methods to specify filtering we can't solve this problem within the OjbStore solution!
This is a conceptual problem of the JDO RI! I don't see how this could be solved without changing the JDO RI codebase.
That's why we still plan to build our own JDO implementation that does not just act as a plugin to the JDO RI.
But it will take some time to get there!
cheers,
Thomas
AMELIN Franck wrote:
Hi all,
Here is a sample code using org.apache.ojb.tutorial5.Product class.
javax.jdo.PersistenceManagerFactory factory = new org.apache.ojb.jdori.sql.OjbStorePMF();
javax.jdo.PersistenceManager manager = factory.getPersistenceManager();
manager.currentTransaction().begin();
javax.jdo.Query query = manager.newQuery(Product.class);
query.setFilter("stock < 30000");
java.util.Collection allProducts = (java.util.Collection)query.execute();
java.util.Iterator iter = allProducts.iterator();
if (! iter.hasNext())
{
System.out.println("No Product entries found!");
}
while (iter.hasNext())
{
System.out.println(iter.next());
}
manager.currentTransaction().commit();
It works but if my table is very big (30 000 enr.) it's very long because the executed query is "SELECT A0.STOCK,A0.PRICE,A0.NAME,A0.ID FROM PRODUCT A0"
This code construct all object Product instances and then apply my filter on the object collection.
Is there a way to have the same result but with the sql query : "SELECT A0.STOCK,A0.PRICE,A0.NAME,A0.ID FROM PRODUCT A0 WHERE STOCK < 30000"
Regards,
Franck
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
