db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Jefferson <a...@datanucleus.org>
Subject Re: New Feature Idea
Date Fri, 04 Nov 2011 07:55:42 GMT
Hi,

> However, I would also propose to also include the following which would be
> a really easy mechanism query data.

I'd agree that QBE would add something to JDO queries over what is already 
there, or planned. The Typesafe query seems to be drifting into JDO 3.2 IIRC, 
so plenty of time for proposals of how this could work (and for contributions 
to DataNucleus providing an implementation).

> Suppose you wanted all the products that start with "Wal", then the code
> would be something like this:
>         Product product = new Product();
>         product.setName("Wal%");

I wouldn't necessarily use values of String fields to imply startsWith though. 
A field could have a value with "%" in it for other reasons, so its value 
should only be used for equality, or maybe <, >, <=, >= for numeric fields.


To have an object of a persistable type with fields set, and be able to say

Query q = pm.newQueryByExample(Person.class, myPerson, "lastName");
to get all Person objects with the same surname as the example Person.

Query q = pm.newQueryByExample(Person.class, myPerson, "age", OP_LT);
to get all Person objects with age less than the age of the example Person.

would be great.

Obviously all these are really doing behind the scenes is create a standard 
JDOQL Query object with a filter and certain parameter values. In particular 
for these examples

SELECT FROM mydomain.Person WHERE lastName == :param

SELECT FROM mydomain.Person WHERE age < :param

i.e nothing that isn't workaroundable right now, just for convenience its 
sometimes nice to express as you say.

> The issue I have is that even though JDO actually keeps track of what
> values have changed within a bean, there is no easy way to determine that
> from the developer's perspective.  So, I have to create a mechanism within
> the beans myself (items that are not persisted) in order to make this all
> work. If there were at least a way to easily gain that "changed field"
> information from a JDO object that would be great.  And from that
> indicator I would be able to get the field name and type using reflection.
>  Getting the changed field indicators is what would make the QBE work.

JDO keeps track of changes *when the object is connected to a StateManager*, 
and only then. If an object is not introduced to the JDO persistence mechanism 
(not persisted) then it has no StateManager, so the mechanism doesn't benefit 
you.


-- 
Andy
DataNucleus (http://www.datanucleus.org)

Mime
View raw message