You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by John Armstrong <si...@gmail.com> on 2008/08/17 11:38:01 UTC

PK ID retrieval code generation seems to fail

Using M4 I map my PK field (id) to an object field as per the wiki
here : http://cwiki.apache.org/CAY/mapping-primary-keys.html

In my generated class these two functions are added:

    public void setId(int id) {
        writeProperty("id", id);
    }
    public $classGen.formatJavaType(${attr.Type}) getId() {
        Object value = readProperty("id");
        return (value != null) ? (Integer) value : 0;
    }

The getId() doesn't compile as it looks like something is not
interpolating cleanly during class generation?

Also,  the PK value is not generated into the object (According to my
debugger at least).

I'll go redesign my database better (The Right Answer)  but if this is
an issue it might be a good fix for a future release, assuming its a
bug and I am understanding correctly.

John

Re: PK ID retrieval code generation seems to fail

Posted by Andrus Adamchik <an...@objectstyle.org>.
I can confirm - this is a bug in M4. I'd appreciate a bug report...  
Also I am surprised that we overlooked it. I have a bunch of int's in  
my mappings. Wonder if there is a difference in behavior between Ant  
and Modeler generation.

Andrus

On Aug 19, 2008, at 5:39 PM, John Armstrong wrote:

> Type is int
>
> Modeler gives no warnings at all.
>
> I can send a screen cast or any other config info you might need?
>
> John-
>
> On Mon, Aug 18, 2008 at 10:47 PM, Andrus Adamchik
> <an...@objectstyle.org> wrote:
>> Are there Modeler warnings saying the type not being set? What is  
>> the Java
>> type of the id attribute?
>>
>> Andrus
>>
>>
>>
>> On Aug 18, 2008, at 7:20 PM, John Armstrong wrote:
>>
>>> 3.0M4 on MacOS X (using the native tool).
>>>
>>> J
>>>
>>> On Mon, Aug 18, 2008 at 9:19 AM, Andrus Adamchik <andrus@objectstyle.org 
>>> >
>>> wrote:
>>>>
>>>> Which version of Cayenne is this? I vaguely recall a bug that we  
>>>> fixed
>>>> already...
>>>>
>>>> Andrus
>>>>
>>>>
>>>> On Aug 18, 2008, at 7:16 PM, John Armstrong wrote:
>>>>
>>>>> Hi Ari,
>>>>> I am only using the model tool as specified in the wiki
>>>>> (http://cwiki.apache.org/CAY/mapping-primary-keys.html), no custom
>>>>> templates or anything 'advanced'. Should I file a ticket for  
>>>>> tracking
>>>>> or is this user error on my side?
>>>>>
>>>>> John-
>>>>>
>>>>> On Sun, Aug 17, 2008 at 7:23 AM, Aristedes Maniatis <ari@ish.com.au 
>>>>> >
>>>>> wrote:
>>>>>>
>>>>>> On 17/08/2008, at 7:38 PM, John Armstrong wrote:
>>>>>>
>>>>>>> public $classGen.formatJavaType(${attr.Type}) getId() {
>>>>>>>  Object value = readProperty("id");
>>>>>>>  return (value != null) ? (Integer) value : 0;
>>>>>>> }
>>>>>>>
>>>>>>> The getId() doesn't compile as it looks like something is not
>>>>>>> interpolating cleanly during class generation?
>>>>>>
>>>>>> It looks like the templates are not being properly processed. I  
>>>>>> can't
>>>>>> image
>>>>>> why, but are you using cgen as described here:
>>>>>> http://cayenne.apache.org/doc/cgen.html to create these files?  
>>>>>> If you
>>>>>> have
>>>>>> customised your templates could you try with the default ones.
>>>>>>
>>>>>> Ari Maniatis
>>>>>>
>>>>>>
>>>>>>
>>>>>> -------------------------->
>>>>>> ish
>>>>>> http://www.ish.com.au
>>>>>> Level 1, 30 Wilson Street Newtown 2042 Australia
>>>>>> phone +61 2 9550 5001   fax +61 2 9550 4001
>>>>>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49  
>>>>>> 102A
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>


Re: PK ID retrieval code generation seems to fail

Posted by John Armstrong <si...@gmail.com>.
Type is int

Modeler gives no warnings at all.

I can send a screen cast or any other config info you might need?

John-

On Mon, Aug 18, 2008 at 10:47 PM, Andrus Adamchik
<an...@objectstyle.org> wrote:
> Are there Modeler warnings saying the type not being set? What is the Java
> type of the id attribute?
>
> Andrus
>
>
>
> On Aug 18, 2008, at 7:20 PM, John Armstrong wrote:
>
>> 3.0M4 on MacOS X (using the native tool).
>>
>> J
>>
>> On Mon, Aug 18, 2008 at 9:19 AM, Andrus Adamchik <an...@objectstyle.org>
>> wrote:
>>>
>>> Which version of Cayenne is this? I vaguely recall a bug that we fixed
>>> already...
>>>
>>> Andrus
>>>
>>>
>>> On Aug 18, 2008, at 7:16 PM, John Armstrong wrote:
>>>
>>>> Hi Ari,
>>>> I am only using the model tool as specified in the wiki
>>>> (http://cwiki.apache.org/CAY/mapping-primary-keys.html), no custom
>>>> templates or anything 'advanced'. Should I file a ticket for tracking
>>>> or is this user error on my side?
>>>>
>>>> John-
>>>>
>>>> On Sun, Aug 17, 2008 at 7:23 AM, Aristedes Maniatis <ar...@ish.com.au>
>>>> wrote:
>>>>>
>>>>> On 17/08/2008, at 7:38 PM, John Armstrong wrote:
>>>>>
>>>>>> public $classGen.formatJavaType(${attr.Type}) getId() {
>>>>>>   Object value = readProperty("id");
>>>>>>   return (value != null) ? (Integer) value : 0;
>>>>>> }
>>>>>>
>>>>>> The getId() doesn't compile as it looks like something is not
>>>>>> interpolating cleanly during class generation?
>>>>>
>>>>> It looks like the templates are not being properly processed. I can't
>>>>> image
>>>>> why, but are you using cgen as described here:
>>>>> http://cayenne.apache.org/doc/cgen.html to create these files? If you
>>>>> have
>>>>> customised your templates could you try with the default ones.
>>>>>
>>>>> Ari Maniatis
>>>>>
>>>>>
>>>>>
>>>>> -------------------------->
>>>>> ish
>>>>> http://www.ish.com.au
>>>>> Level 1, 30 Wilson Street Newtown 2042 Australia
>>>>> phone +61 2 9550 5001   fax +61 2 9550 4001
>>>>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>

Re: PK ID retrieval code generation seems to fail

Posted by Andrus Adamchik <an...@objectstyle.org>.
Are there Modeler warnings saying the type not being set? What is the  
Java type of the id attribute?

Andrus



On Aug 18, 2008, at 7:20 PM, John Armstrong wrote:

> 3.0M4 on MacOS X (using the native tool).
>
> J
>
> On Mon, Aug 18, 2008 at 9:19 AM, Andrus Adamchik <andrus@objectstyle.org 
> > wrote:
>> Which version of Cayenne is this? I vaguely recall a bug that we  
>> fixed
>> already...
>>
>> Andrus
>>
>>
>> On Aug 18, 2008, at 7:16 PM, John Armstrong wrote:
>>
>>> Hi Ari,
>>> I am only using the model tool as specified in the wiki
>>> (http://cwiki.apache.org/CAY/mapping-primary-keys.html), no custom
>>> templates or anything 'advanced'. Should I file a ticket for  
>>> tracking
>>> or is this user error on my side?
>>>
>>> John-
>>>
>>> On Sun, Aug 17, 2008 at 7:23 AM, Aristedes Maniatis <ar...@ish.com.au>
>>> wrote:
>>>>
>>>> On 17/08/2008, at 7:38 PM, John Armstrong wrote:
>>>>
>>>>> public $classGen.formatJavaType(${attr.Type}) getId() {
>>>>>    Object value = readProperty("id");
>>>>>    return (value != null) ? (Integer) value : 0;
>>>>> }
>>>>>
>>>>> The getId() doesn't compile as it looks like something is not
>>>>> interpolating cleanly during class generation?
>>>>
>>>> It looks like the templates are not being properly processed. I  
>>>> can't
>>>> image
>>>> why, but are you using cgen as described here:
>>>> http://cayenne.apache.org/doc/cgen.html to create these files? If  
>>>> you
>>>> have
>>>> customised your templates could you try with the default ones.
>>>>
>>>> Ari Maniatis
>>>>
>>>>
>>>>
>>>> -------------------------->
>>>> ish
>>>> http://www.ish.com.au
>>>> Level 1, 30 Wilson Street Newtown 2042 Australia
>>>> phone +61 2 9550 5001   fax +61 2 9550 4001
>>>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>>>
>>>>
>>>>
>>>
>>
>>
>


Re: PK ID retrieval code generation seems to fail

Posted by John Armstrong <si...@gmail.com>.
3.0M4 on MacOS X (using the native tool).

J

On Mon, Aug 18, 2008 at 9:19 AM, Andrus Adamchik <an...@objectstyle.org> wrote:
> Which version of Cayenne is this? I vaguely recall a bug that we fixed
> already...
>
> Andrus
>
>
> On Aug 18, 2008, at 7:16 PM, John Armstrong wrote:
>
>> Hi Ari,
>>  I am only using the model tool as specified in the wiki
>> (http://cwiki.apache.org/CAY/mapping-primary-keys.html), no custom
>> templates or anything 'advanced'. Should I file a ticket for tracking
>> or is this user error on my side?
>>
>> John-
>>
>> On Sun, Aug 17, 2008 at 7:23 AM, Aristedes Maniatis <ar...@ish.com.au>
>> wrote:
>>>
>>> On 17/08/2008, at 7:38 PM, John Armstrong wrote:
>>>
>>>>  public $classGen.formatJavaType(${attr.Type}) getId() {
>>>>     Object value = readProperty("id");
>>>>     return (value != null) ? (Integer) value : 0;
>>>>  }
>>>>
>>>> The getId() doesn't compile as it looks like something is not
>>>> interpolating cleanly during class generation?
>>>
>>> It looks like the templates are not being properly processed. I can't
>>> image
>>> why, but are you using cgen as described here:
>>> http://cayenne.apache.org/doc/cgen.html to create these files? If you
>>> have
>>> customised your templates could you try with the default ones.
>>>
>>> Ari Maniatis
>>>
>>>
>>>
>>> -------------------------->
>>> ish
>>> http://www.ish.com.au
>>> Level 1, 30 Wilson Street Newtown 2042 Australia
>>> phone +61 2 9550 5001   fax +61 2 9550 4001
>>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>>
>>>
>>>
>>
>
>

Re: PK ID retrieval code generation seems to fail

Posted by Andrus Adamchik <an...@objectstyle.org>.
Which version of Cayenne is this? I vaguely recall a bug that we fixed  
already...

Andrus


On Aug 18, 2008, at 7:16 PM, John Armstrong wrote:

> Hi Ari,
>  I am only using the model tool as specified in the wiki
> (http://cwiki.apache.org/CAY/mapping-primary-keys.html), no custom
> templates or anything 'advanced'. Should I file a ticket for tracking
> or is this user error on my side?
>
> John-
>
> On Sun, Aug 17, 2008 at 7:23 AM, Aristedes Maniatis <ar...@ish.com.au>  
> wrote:
>>
>> On 17/08/2008, at 7:38 PM, John Armstrong wrote:
>>
>>>  public $classGen.formatJavaType(${attr.Type}) getId() {
>>>      Object value = readProperty("id");
>>>      return (value != null) ? (Integer) value : 0;
>>>  }
>>>
>>> The getId() doesn't compile as it looks like something is not
>>> interpolating cleanly during class generation?
>>
>> It looks like the templates are not being properly processed. I  
>> can't image
>> why, but are you using cgen as described here:
>> http://cayenne.apache.org/doc/cgen.html to create these files? If  
>> you have
>> customised your templates could you try with the default ones.
>>
>> Ari Maniatis
>>
>>
>>
>> -------------------------->
>> ish
>> http://www.ish.com.au
>> Level 1, 30 Wilson Street Newtown 2042 Australia
>> phone +61 2 9550 5001   fax +61 2 9550 4001
>> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>>
>>
>>
>


Re: PK ID retrieval code generation seems to fail

Posted by John Armstrong <si...@gmail.com>.
Hi Ari,
  I am only using the model tool as specified in the wiki
(http://cwiki.apache.org/CAY/mapping-primary-keys.html), no custom
templates or anything 'advanced'. Should I file a ticket for tracking
or is this user error on my side?

John-

On Sun, Aug 17, 2008 at 7:23 AM, Aristedes Maniatis <ar...@ish.com.au> wrote:
>
> On 17/08/2008, at 7:38 PM, John Armstrong wrote:
>
>>   public $classGen.formatJavaType(${attr.Type}) getId() {
>>       Object value = readProperty("id");
>>       return (value != null) ? (Integer) value : 0;
>>   }
>>
>> The getId() doesn't compile as it looks like something is not
>> interpolating cleanly during class generation?
>
> It looks like the templates are not being properly processed. I can't image
> why, but are you using cgen as described here:
> http://cayenne.apache.org/doc/cgen.html to create these files? If you have
> customised your templates could you try with the default ones.
>
> Ari Maniatis
>
>
>
> -------------------------->
> ish
> http://www.ish.com.au
> Level 1, 30 Wilson Street Newtown 2042 Australia
> phone +61 2 9550 5001   fax +61 2 9550 4001
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>
>
>

Re: PK ID retrieval code generation seems to fail

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 17/08/2008, at 7:38 PM, John Armstrong wrote:

>    public $classGen.formatJavaType(${attr.Type}) getId() {
>        Object value = readProperty("id");
>        return (value != null) ? (Integer) value : 0;
>    }
>
> The getId() doesn't compile as it looks like something is not
> interpolating cleanly during class generation?

It looks like the templates are not being properly processed. I can't  
image why, but are you using cgen as described here: http://cayenne.apache.org/doc/cgen.html 
  to create these files? If you have customised your templates could  
you try with the default ones.

Ari Maniatis



-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A