thanks a lot for your hint,

now the statements are generated as expected :-)

Marc


On Mon, 16 Aug 2004 17:11:22 -0600
Ashish Rangole <[EMAIL PROTECTED]> wrote:

> My guess is your attributes have primitive types. That
> is, oUser.id has type int rather than Integer. If you
> use the later then just do not set the attribute that
> you do not want to use in criteria and since it will then be null,
> it won't be looked at.
> 
> Ashish
> 
> 
> 
> Marc Tinnemeyer wrote:
>  > Dear Listmembers,
>  >
>  > I got the following problem:
>  >
>  > I try to retrieve an object via ojb using the PB API. The syntax
>  > looks like this:
>  >
>  > broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>  > QueryByCriteria query = new QueryByCriteria(oUser);
>  > result = (User) broker.getObjectByQuery(query);
>  >
>  > the oUser object has several attributes, like id, name, username,
>  > password ...
>  >
>  > Now somebody tries to login and the attributes "username" and
>  > password" are set. That object ist then passed as criteria to
>  > QueryByCriteria.
>  >
>  > The weird thing is that the generated sql-statement looks like
>  > this:
>  >
>  > SELECT
>  > A0.username,A0.password,A0.id
>  > WHERE (((A0.id = 0) AND A0.username = 'userabc')
>  > AND A0.password = 'myPassword')
>  >
>  > My problem is A0.id = 0 !
>  > And my question is, is there a way to tell ojb only to query the
>  > attributes that are set ?
>  > s.th. like:
>  >
>  > select
>  > A0.username,A0.password,A0.id
>  > where (( A0.username = 'abcUser') and A0.password = 'myPassword')
>  >
>  > Currently my version of ojb is 1.0rc6.
>  >
>  >
>  > Thanks in advance,
>  >
>  > Kind regards,
>  > Marc Tinnemeyer
>  >
>  > ------------------------------------------------------------------
>  > --- To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>  >
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to