You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Frank <fa...@hotmail.com> on 2007/03/19 16:55:39 UTC

problems querying int,long

Hello,

I am getting hung up on passing int and long values to cayenne.
In my MySQL database, all PK fields are defined as BIGINT.
The PK in my cayenne schemas are defined as long.
ExpressionFactory.matchDbExp is looking for an object, I am passing in a long.

What is the best way to handle this?



Thanks

Frank

Re: problems querying int,long

Posted by Michael Gentry <bl...@gmail.com>.
Well, given that I'm not entirely sure what you are trying to do ... On
your:

     id = s.getSchedule_id(s.getId());

line, your getSchedule_id() method doesn't take a parameter, so that would
generate an error.  If you meant to call getSchedule(Long) there, then try
something like this:

     id = s.getSchedule_id(new Long(s.getId()));

Although I have to admit this seems a little confusing to me, too.  If all
you are trying to obtain is the ID, seems like you could get it calling your
getSchedule_id() method.

/dev/mrg


On 3/19/07, Frank <fa...@hotmail.com> wrote:
>
> Hi Michael ,
> Here is more of my code:
> I did not understand your statement
> Thanks
> Frank
>
> public class Schedules extends _Schedules {
> public int getSchedule_id() {
>   return DataObjectUtils.intPKForObject(this);
> }
>
> private String getProvider(long pid) {
> ..
> if (records.size() > -1) {
>       Schedules s = new Schedules();
>       s = (Schedules)records.get(0);
>   // This line complains because it is an int value
>       id = s.getSchedule_id(s.getId());
>      }
> }
>
> private long getSchedule(Long pid) {
>   Expression qualifier = ExpressionFactory.matchExp("scheduleDate",
> c.getTime());
>   qualifier =
> qualifier.andExp(ExpressionFactory.matchDbExp(
> Schedules.PROVIDER_ID_PROPERTY,
> pid));
> ..
> }
> ----- Original Message -----
> From: "Michael Gentry" <bl...@gmail.com>
> To: <us...@cayenne.apache.org>
> Sent: Monday, March 19, 2007 1:20 PM
> Subject: Re: problems querying int,long
>
>
> > Try using a java.lang.Long or even a java.math.BigInteger.  If you use
> the
> > BigInteger, use String.valueOf(yourLong) to pass into the constructor
> > (BigInteger() will take a String, but not a long).
> >
> > /dev/mrg
> >
> >
> > On 3/19/07, Frank <fa...@hotmail.com> wrote:
> >>
> >> Hello,
> >>
> >> I am getting hung up on passing int and long values to cayenne.
> >> In my MySQL database, all PK fields are defined as BIGINT.
> >> The PK in my cayenne schemas are defined as long.
> >> ExpressionFactory.matchDbExp is looking for an object, I am passing in
> a
> >> long.
> >>
> >> What is the best way to handle this?
> >>
> >>
> >>
> >> Thanks
> >>
> >> Frank
> >>
> >
>
>

Re: problems querying int,long

Posted by Frank <fa...@hotmail.com>.
Hi Michael ,
Here is more of my code:
I did not understand your statement
Thanks
Frank

public class Schedules extends _Schedules {
 public int getSchedule_id() {
  return DataObjectUtils.intPKForObject(this);
}

private String getProvider(long pid) {
..
if (records.size() > -1) {
      Schedules s = new Schedules();
      s = (Schedules)records.get(0);
  // This line complains because it is an int value
      id = s.getSchedule_id(s.getId());
     }
}

private long getSchedule(Long pid) {
  Expression qualifier = ExpressionFactory.matchExp("scheduleDate", 
c.getTime());
  qualifier = 
qualifier.andExp(ExpressionFactory.matchDbExp(Schedules.PROVIDER_ID_PROPERTY, 
pid));
..
}
----- Original Message ----- 
From: "Michael Gentry" <bl...@gmail.com>
To: <us...@cayenne.apache.org>
Sent: Monday, March 19, 2007 1:20 PM
Subject: Re: problems querying int,long


> Try using a java.lang.Long or even a java.math.BigInteger.  If you use the
> BigInteger, use String.valueOf(yourLong) to pass into the constructor
> (BigInteger() will take a String, but not a long).
>
> /dev/mrg
>
>
> On 3/19/07, Frank <fa...@hotmail.com> wrote:
>>
>> Hello,
>>
>> I am getting hung up on passing int and long values to cayenne.
>> In my MySQL database, all PK fields are defined as BIGINT.
>> The PK in my cayenne schemas are defined as long.
>> ExpressionFactory.matchDbExp is looking for an object, I am passing in a
>> long.
>>
>> What is the best way to handle this?
>>
>>
>>
>> Thanks
>>
>> Frank
>>
> 


Re: problems querying int,long

Posted by Michael Gentry <bl...@gmail.com>.
Try using a java.lang.Long or even a java.math.BigInteger.  If you use the
BigInteger, use String.valueOf(yourLong) to pass into the constructor
(BigInteger() will take a String, but not a long).

/dev/mrg


On 3/19/07, Frank <fa...@hotmail.com> wrote:
>
> Hello,
>
> I am getting hung up on passing int and long values to cayenne.
> In my MySQL database, all PK fields are defined as BIGINT.
> The PK in my cayenne schemas are defined as long.
> ExpressionFactory.matchDbExp is looking for an object, I am passing in a
> long.
>
> What is the best way to handle this?
>
>
>
> Thanks
>
> Frank
>