On Aug 2, 2007, at 13:58 , Andrus Adamchik wrote:
> let me take this to the list, as it would be much easier to follow
> the discussion compared to Jira comments. First, this is indeed a
> separate issue from CAY-811 main problem, as it has nothing to do
> with database generated PK.
Okay, I reopened CAY-835.
> Now that you posted a patch below I remember why it was done this
> way - to support PK generation for primitive int attributes,
> required by JPA (and our POJO feature). Now I guess we'll need to
> figure out a way in DataDomainInsertBucket to tell apart meaningful
> primitives vs. java.lang.Number subclasses.
Handling null as 0 can probably lead to other problems as well.
Perhaps 'NullNumber extends Number' could be used? Or creating a
(empty) Null-interface and then subclass Integer, Long and so on?
Btw: Øyvind Harboe has lots of good thoughts on null handling.
> Otherwise the patch below would break JPA.
Or unbreak cayenne classic :)
Regards,
- Tore.
>
> Andrus
>
>
> On Aug 2, 2007, at 2:36 PM, Tore Halset (JIRA) wrote:
>
>>
>> [ https://issues.apache.org/cayenne/browse/CAY-811?
>> page=com.atlassian.jira.plugin.system.issuetabpanels:comment-
>> tabpanel#action_12430 ]
>>
>> Tore Halset commented on CAY-811:
>> ---------------------------------
>>
>> This small patch fixes my issue (int meaningful primary key *not*
>> marked as generated). Is it the same as your 1) in the description
>> above? I would love to commit it, but I do not know why the
>> special handling of a Number with the intValue 0 was added?
>>
>> Index: framework/cayenne-jdk1.4-unpublished/src/main/java/org/
>> apache/cayenne/access/DataDomainInsertBucket.java
>> ===================================================================
>> --- framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/
>> cayenne/access/DataDomainInsertBucket.java (revision 562071)
>> +++ framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/
>> cayenne/access/DataDomainInsertBucket.java (working copy)
>>.. -144,11 +144,8 @@
>> .readPropertyDirectly(object);
>>
>> if (value != null) {
>> - // treat numeric zero values as nulls
>> requiring generation
>> - if (!(value instanceof Number &&
>> ((Number) value).intValue() == 0)) {
>> - idMap.put(dbAttrName, value);
>> - continue;
>> - }
>> + idMap.put(dbAttrName, value);
>> + continue;
>> }
>> }
>>
>>
>>
>>> Meaningful identity columns: user provided PK values are ignored
>>> ----------------------------------------------------------------
>>>
>>> Key: CAY-811
>>> URL: https://issues.apache.org/cayenne/browse/
>>> CAY-811
>>> Project: Cayenne
>>> Issue Type: Bug
>>> Components: Cayenne Core Library
>>> Affects Versions: 1.2 [STABLE], 2.0 [STABLE], 3.0
>>> Reporter: Andrus Adamchik
>>> Assignee: Andrus Adamchik
>>> Priority: Minor
>>> Fix For: 3.0
>>>
>>>
>>> I found it when testing on 3.0, although I suspect this is a
>>> problem on 2.0 and 1.2 as well. When a meaningful PK is set by
>>> the user and is also mapped as a DB-generated PK, Cayenne
>>> incorrectly overrides user value. There are two places where this
>>> must be fixed:
>>> 1. DataDomainInsertBucket (I will commit the fix shortly)
>>> 2. InsertBatchQueryBuilder (this is a bit more hairy - as the
>>> batch syntax will be affected depending on whether user provided
>>> a value or not)
>>
>> --
>> This message is automatically generated by JIRA.
>> -
>> You can reply to this email to add a comment to the issue online.
>>
>>
>
>
This archive was generated by hypermail 2.0.0 : Thu Aug 02 2007 - 08:44:32 EDT