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 <and...@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

Reply via email to