cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <...@maniatis.org>
Subject Re: Stumps me.....Error "java.lang.String cannot be cast to java.util.UUID"
Date Sat, 21 Jul 2012 12:58:33 GMT
Just as Andrus said: look at the lifecycle listeners.

Ari


On 21/07/12 2:27pm, Kanwar Manish wrote:
> Yes, this is a primary key column.
>
> If possible - please point me to an optimal way of initializing the column
> for new objects.
>
> On Fri, Jul 20, 2012 at 6:41 PM, Andrus Adamchik <andrus@objectstyle.org>wrote:
>
>>
>> On Jul 20, 2012, at 2:31 PM, Kanwar Manish wrote:
>>
>>> Column is of type varchar(36) in PostgreSQL and it is mapped as UUID in
>> the
>>> cayenne mapping.
>>
>> Is this a PK column?
>>
>>> In the constructor of the db class I am initiating the id.
>>> Values are being saved perfectly fine.
>>>
>>> "
>>> public class UserMaster extends _UserMaster {
>>>
>>>     public UserMaster() {
>>>         this.setUserMasterId(UUID.randomUUID());
>>>     }
>>> .........}
>>
>> This is wrong, or at least suboptimal. Constructor is called not only when
>> a NEW object is created, but also when an existing one is selected from DB.
>> You need to use a different initialization mechanism, such as PostAdd
>> lifecycle callback or something like it. But this is an aside.. It doesn't
>> seem related to the issue.
>>
>> Andrus
>>
>>
>

-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Mime
View raw message