cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: Stumps me.....Error "java.lang.String cannot be cast to java.util.UUID"
Date Fri, 20 Jul 2012 13:11:50 GMT

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.


View raw message