You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Bruno René Santos <br...@holos.pt> on 2010/10/20 03:05:09 UTC
OnPrePersist not working
Hello All,
I have created a pre-persist callback to set a property from my pojo. But when I commit changes the callback is not executed... Any ideas? For instants, the post-add callback works great.
Thank you
Re: Raw delete
Posted by Michael Gentry <mg...@masslight.net>.
I've done this in the past:
QueryChain chain = new QueryChain();
// Add raw SQL templates to the chain.
chain.addQuery(new SQLTemplate(Customer.class, "DELETE FROM Customers"));
chain.addQuery(new SQLTemplate(Item.class, "DELETE FROM Items"));
chain.addQuery(new SQLTemplate(LineItem.class, "DELETE FROM LineItems"));
chain.addQuery(new SQLTemplate(Order.class, "DELETE FROM Orders"));
// Execute all of the SQL statements.
dataContext.performNonSelectingQuery(chain);
Keep in mind that isn't a good thing to do if you are concerned about
your in-memory object graphs (DataContexts/etc) suddenly becoming
out-of-sync. Also, if you don't need to do multiple deletes, you
don't need the query chain part.
mrg
On Wed, Oct 20, 2010 at 1:56 PM, <br...@lamp1.dmz.holos.pt> wrote:
> Hello all,
>
> Whats the better way to do a regular delete from in raw sql? I tried a raw
> sql named query on the modeler but i get a Null PK error, maybe because no
> data rows are returned?
>
> Thank you
>
>
>
Raw delete
Posted by br...@lamp1.dmz.holos.pt.
Hello all,
Whats the better way to do a regular delete from in raw sql? I tried a raw
sql named query on the modeler but i get a Null PK error, maybe because no
data rows are returned?
Thank you
RE: OnPrePersist not working
Posted by Bruno René Santos <br...@holos.pt>.
Just opened an improvement issue on JIRA.
Regards
Bruno Santos
-----Mensagem original-----
De: Andrus Adamchik [mailto:andrus@objectstyle.org]
Enviada: quarta-feira, 20 de Outubro de 2010 11:27
Para: user@cayenne.apache.org
Assunto: Re: OnPrePersist not working
On Oct 20, 2010, at 1:14 PM, Bruno René Santos wrote:
> Do you think validating after
> pre-persist could lead to problems? I think it would help pre-persist to be
more
> useful, allowing us to calculate mandatory fields.
Maybe a good idea actually. Care to open a Jira? We'll think about it.
Andrus
Re: OnPrePersist not working
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Oct 20, 2010, at 1:14 PM, Bruno René Santos wrote:
> Do you think validating after
> pre-persist could lead to problems? I think it would help pre-persist to be more
> useful, allowing us to calculate mandatory fields.
Maybe a good idea actually. Care to open a Jira? We'll think about it.
Andrus
RE: OnPrePersist not working
Posted by Bruno René Santos <br...@holos.pt>.
Hi Andrus,
I have just found out the problem. I wa trying to affect a cayenne-mandatory
table field with a calculated value during pre-persist. I think the problem is
that Cayenne mandatory validation is executed before the prepersist, not letting
me affect the field, which starts as null. Do you think validating after
pre-persist could lead to problems? I think it would help pre-persist to be more
useful, allowing us to calculate mandatory fields.
I made it work by removing the Mandatory check on Cayenne Modeler.
Regards
Bruno Santos
-----Mensagem original-----
De: Andrus Adamchik [mailto:andrus@objectstyle.org]
Enviada: quarta-feira, 20 de Outubro de 2010 08:32
Para: user@cayenne.apache.org
Assunto: Re: OnPrePersist not working
Odd. Should be working. Do you actually see INSERT statement in the logs, but no
callback before that?
Andrus
On Oct 20, 2010, at 4:05 AM, Bruno René Santos wrote:
> Hello All,
>
> I have created a pre-persist callback to set a property from my pojo. But when
I commit changes the callback is not executed... Any ideas? For instants, the
post-add callback works great.
>
> Thank you
>
>
Re: OnPrePersist not working
Posted by Andrus Adamchik <an...@objectstyle.org>.
Odd. Should be working. Do you actually see INSERT statement in the logs, but no callback before that?
Andrus
On Oct 20, 2010, at 4:05 AM, Bruno René Santos wrote:
> Hello All,
>
> I have created a pre-persist callback to set a property from my pojo. But when I commit changes the callback is not executed... Any ideas? For instants, the post-add callback works great.
>
> Thank you
>
>