Hi,
Thanks for your inputs.
I changed all the primitive data types (not just PK and FK values) used to
objects and it worked.
Thanks
Anna
Armin Waibel <[EMAIL PROTECTED]> wrote:
Hi Anna,
Annapoorani Rathi wrote:
> Hi,
>
> I just started on OJB..
>
> In PB Tutorial, the code snippet does not fetch me the record and result is
> null (though the record is present in DB)
>
> broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> QueryByCriteria query = new QueryByCriteria(template);
> result = (Product)broker.getObjectByQuery(query);
>
> But if i replace the above with the code below, i do get a populated result
> object
>
> broker = PersistenceBrokerFactory.defaultPersistenceBroker();
> Criteria criteria = new Criteria();
> criteria.addEqualTo("name","Sprocket");
> QueryByCriteria query = new QueryByCriteria(Product.class, criteria);
> result = (Product)broker.getObjectByQuery(query);
>
> I understand that the first Impl decodes to Second internally.
> But then the first Impl does not work.
>
> Can anyone help me to reason out??
>
I assume that you define a primitive number field (e.g. int) of your
persistent class Product as PK field in class-descriptor. If so, OJB
will always find PK '0' in your template object and will create a query
based on that value.
Try to use a non-primitive field (e.g. change field to Integer) and run
your test again. It's recommended to use non-primitive fields for PK and
FK fields.
regards,
Armin
> Thanks
> Anna
>
>
>
>
>
>
>
> ---------------------------------
> Yahoo! Messenger - Communicate instantly..."Ping" your friends today!
> Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Yahoo! Messenger - Communicate instantly..."Ping" your friends today!
Download Messenger Now