I'd like to second this suggestion. There have been several instances that I've 
made required fields nullable solely because validation occurs prior to the 
@PrePersist lifecycle callback.

________________________________
From: Hugi Thordarson <h...@godurkodi.is>
Sent: Wednesday, March 1, 2017 8:51:48 AM
To: user@cayenne.apache.org
Subject: Re: Validation and @PrePersist

Hi Jurgen,
fine suggestion but unfortunately not the part of the lifecycle I need to 
catch—the action needs to be performed before committing, not after adding (so 
basically I need @PrePersist—but I need it before validation happens).

Cheers,
- hugi


> On 1. mar. 2017, at 13:14, <do...@xsinet.co.za> <do...@xsinet.co.za> wrote:
>
> Hi Hugi
>
> For this kind of thing use @PostAdd instead.
>
> Regards
> Jurgen
>
>
> -----Original Message----- From: Hugi Thordarson
> Sent: Wednesday, March 1, 2017 1:18 PM
> To: user@cayenne.apache.org
> Subject: Validation and @PrePersist
>
> Hi all,
> I have some logic in a Listener that uses @PrePersist to populate the value 
> of a required attribute before committing changes. Turns out this doesn’t 
> work, since Cayenne invokes validateForInsert() before running @PrePersist.
>
> Any suggestions for where I can invoke logic populates required values before 
> validation?
>
> Cheers,
> - hugi

Reply via email to