I solved the problem although the solution implies a bug or incredibly
bad documentation
The CurrencyPair pojo was setup as follows
public class CurrencyPair extends AbstractEncodedKeyObject{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk",
value="true")
private String encodedKey;
@Persistent
@Unique
@Extension(vendorName="datanucleus", key="gae.pk-name",
value="true")
private String currencyPair;
.....
It seems that I cannot use currencyPair in a filter because it forms
part of the encoded key. I added the same data in a new field, name.
@Persistent
String name;
The filter worked when
name
was used as the criterion and was not used in generating the key.
I must say that I have had a terrible time getting my head around the
datanucleus jive. I find it terrible: extremely limited functionality
and gae don't give adequate documentation for the functionality that
it does have. I mean every new technology takes time to learn but
datanucleus/jdo doesn't compare with oracle objects introduced years
ago in oracle 8 or 9i, nor to jpa working with an rdb.
Would jpa be easier in gae even though it is still datanucleus??
Whose idea was it to not have the standard operators such as OR, NOT
etc? Why do we need == when .equals() method should be the way to go?
Where are the wild cards?
You can put your data in but then you have got to be able to get it
out and use it.
Dukha
On Nov 13, 11:59 am, m seleron <[email protected]> wrote:
> Though different sources think
> Could you try this in simple ?
>
> PersistenceManager pm= getPersistenceManager();
>
> String JDOQL =CurrencyPair.class.getName() + " wherecurrencyPair
> =='AUD.USD' ";
> Query query = pm.newQuery(JDOQL);
>
> List<CurrencyPair> l = (List<CurrencyPair>)query.execute();
>
> thanks.
>
> On 11月13日, 午前9:09, dukha <[email protected]> wrote:
>
> > Thanks for the reply.
> > Yes I have tried this, with a query.declareParameters() in the middle.
>
> > On Nov 12, 8:55 pm, m seleron <[email protected]> wrote:
>
> > > Hi,
>
> > > Query query = pm.newQuery(CurrencyPair.class);
>
> > > query.declareParameters("String currency_name");
> > > query.setFilter("currencyPair== currency_name");
> > > String currency_name = "AUD.USD";
>
> > > List<CurrencyPair> l = (List<CurrencyObj>)query.execute
> > > (currency_name);
>
> > > It is likely already to have tried.
> > > thanks.
>
> > > On 11月12日, 午後5:18, David Brown <[email protected]> wrote:
>
> > > > Have you tried using an outside tool like TOAD or DBVIS to run your
> > > > query
> > > > first as a test? Or can you JUnit your query?
>
> > > > On Thu, Nov 12, 2009 at 2:11 AM, dukha <[email protected]> wrote:
> > > > > I have a pojoCurrencyPairwhich I have successfully saved in the
> > > > > database using jdo.
> > > > > CurencyPair has a fieldcurrencyPair.
>
> > > > > Now trying to select in jdo the query works fine so long as there are
> > > > > no conditions/filters involved. ie I can select all currency pairs
> > > > > like this
>
> > > > > PersistenceManager pm= getPersistenceManager();
> > > > > Query query = pm.newQuery(CurrencyPair.class);
> > > > > List<CurrencyPair> l = (List<CurrencyPair>)query.execute();
>
> > > > > This gives
> > > > > USD.JPY
> > > > > GBP.JPY
> > > > > EUR.GBP
> > > > > EUR.USD
> > > > > USD.CAD
> > > > > AUD.USD
> > > > > USD.CHF
> > > > > EUR.JPY
> > > > > EUR.CHF
> > > > > GBP.USD
>
> > > > > PersistenceManager pm= getPersistenceManager();
> > > > > Query query = pm.newQuery(CurrencyPair.class,"currencyPair==
> > > > > 'AUD.USD'");
> > > > > List<CurrencyPair> l = (List<CurrencyPair>)query.execute();
>
> > > > > returns no data.
>
> > > > > I've tried all all combinatioins of setting a filter and declaring a
> > > > > parameter or putting the whole query in 1 String according to the gae
> > > > > getting started guide.
> > > > > I have no idea what I'm doing wrong. any help would be appreciated.
>
> > > > > Thanks.
> > > > > Dukha
>
> > > > > --
>
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups
> > > > > "Google App Engine for Java" group.
> > > > > To post to this group, send email to
> > > > > [email protected].
> > > > > To unsubscribe from this group, send email to
> > > > > [email protected]<google-appengine-java%[email protected]>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/google-appengine-java?hl=.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=.