-
1. Re: CMR Fields not being persisted
dsundstrom Feb 27, 2002 11:16 AM (in response to pazu)Check the log (you will need to turn on debug for org.jboss.ejb.plugins.cmp). For your create you should see a find for the new pk followed by an insert with all columns set except of the cmr fields. Almost imedately after that you should see an update of the inserted row with cmr fields set. Are you getting the update command?
-
2. Re: CMR Fields not being persisted
pazu Feb 27, 2002 11:49 AM (in response to pazu)No, I'm not getting the update command. Here is the portion of the logfile that correspond to the bean insertion:
2002-02-27 13:33:37,566 [AutorizacaoFornecimento] Create: pk=8780808080808080
2002-02-27 13:33:37,566 [AutorizacaoFornecimento] Executing SQL: SELECT COUNT(*) FROM af WHERE af_id=?
2002-02-27 13:33:37,573 [AutorizacaoFornecimento] Executing SQL: INSERT INTO af (af_id, af_numero, af_finalizada, af_pedido, af_tipo, af_data_preenchimento, af_data_pedido, af_data_prevista, af_data_entrega, af_transporte, af_total_material, af_total_servico, af_valor_cat, af_pagamento_desc, af_pagamento_tipo, af_setor, af_sistema, af_nu_ramais_analogico, af_nu_ramais_digitais, af_nu_canais, af_nu_pa, af_nu_supervisao, af_nu_stack, af_clie_id, af_agen_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2002-02-27 13:33:37,658 [AutorizacaoFornecimento] Create: Rows affected = 1
Just after this, I got more logging from ejbPostCreate. Please note that there are some log statements from my class here.
2002-02-27 13:33:37,826 [AutorizacaoFornecimentoEJB] Em ejbPostCreate(...)
2002-02-27 13:33:37,828 [AutorizacaoFornecimentoEJB] agenteId: 2
2002-02-27 13:33:37,828 [AutorizacaoFornecimentoEJB] clienteId: 28982
2002-02-27 13:33:37,832 [Agente] Executing SQL: SELECT af_agen_id, af_id FROM af WHERE (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?) OR (af_agen_id=?)
2002-02-27 13:33:37,841 [Cliente] Executing SQL: SELECT af_clie_id, af_id FROM af WHERE (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?) OR (af_clie_id=?)
2002-02-27 13:33:37,847 [AutorizacaoFornecimentoEJB] agenteId (após set): 2
2002-02-27 13:33:37,848 [AutorizacaoFornecimentoEJB] clienteId (após set): 28982
If you look at the attached source you'll see that in ejbPostCreate() I log the id's from the AgenteLocal and ClienteLocal parameters received, set them both with setAgente() and setCliente() and then log the output from getAgente().getId() and getCliente().getId(). According to the log, the CMR fields were set. However, they are never updated to the database. The update never comes.
Note: this log excerpt is from jboss-3.0.0beta2, checked out from CVS just a minute ago. The log output from jboss-3.0.0beta was a lot more verbose. -
3. Re: CMR Fields not being persisted
pazu Feb 28, 2002 10:49 AM (in response to pazu)I've tried the 3.0.0 beta and the latest CVS tip and the problem is still the same. There is no update after ejbPostCreate().
Someone please help me :( -
4. Re: CMR Fields not being persisted
davidjencks Feb 28, 2002 12:14 PM (in response to pazu)Dain, is your code doing the expected update or are you expecting an ejbStore triggered by the end of a transaction to do it? If the latter, possibly the quadratic algorithm fix I did is preventing ejbStore from being called. Let me know. I was assuming that after ejbCreate the bean was synchronized with the db and "clean".
-
5. Re: CMR Fields not being persisted
dsundstrom Feb 28, 2002 2:01 PM (in response to pazu)> Dain, is your code doing the expected update or are
> you expecting an ejbStore triggered by the end of a
> transaction to do it?
This is supposed to be triggered by the tx complete.
> If the latter, possibly the
> quadratic algorithm fix I did is preventing ejbStore
> from being called. Let me know. I was assuming that
> after ejbCreate the bean was synchronized with the db
> and "clean".
I was thinking the same thing. When a bean comes back from the ejbCreate/ejbPostCreate call it can be dirty. Can you add this to the dirty list after create? -
6. Re: CMR Fields not being persisted
pazu Feb 28, 2002 8:14 PM (in response to pazu)David, please write here when the fix is landed. Meanwhile, there is a way to work around this?
-
7. Re: CMR Fields not being persisted
pazu Feb 28, 2002 9:59 PM (in response to pazu)Good news. I tried to venture alone into JBoss source code and apparently solved the bug. Just added a call to storeEntity() in CMPPersistenceManager.java after it calls ejbPostCreate().
I submited the small patch to sourceforge. Here is the link to the tracker item: https://sourceforge.net/tracker/index.php?func=detail&aid=524170&group_id=22866&atid=376687
This is the first time I ever dared to look at JBoss source code. Perhaps (probably) what I did is dangerous, stupid or harmful in one way or another. Anyway, I got my problem solved and my heart is still beating fast from the thrill of venturing into this great unknown land of source code :) -
8. Re: CMR Fields not being persisted
davidjencks Feb 28, 2002 10:45 PM (in response to pazu)It's still a thrill;-)
Ensuring that some "store" is called after ejbPostCreate is certainly necessary to fix this problem.
I solved it a different way, by adding all new entities to the list of entities that need ejbStore called on them before the end of the transaction (this list is in GlobalTxEntityMap). This code is in EntitySynchronizationInterceptor, which is not persistence-manager specific. My change solves the problem for all possible persistence managers: I believe yours solves it only for the particular cmp2 persistence manager.
Anyway, thanks for the patch and please continue to contribute! -
9. Re: CMR Fields not being persisted
ppetit Mar 4, 2002 3:18 AM (in response to pazu)David, where can I get your patch ?
regards
Philippe -
10. Re: CMR Fields not being persisted
dsundstrom Mar 4, 2002 11:29 AM (in response to pazu)It is not a patch; it's in cvs HEAD. Download the source from cvs and rebuild.
-
11. Re: CMR Fields not being persisted
pazu Mar 4, 2002 12:13 PM (in response to pazu)Thanks for the explanation, David. I know my solution was naive -- I don't know anything about JBoss internal to do something real good. But I hope to know more and more each day :)
-
12. Re: CMR Fields not being persisted
rollc Aug 6, 2002 5:25 PM (in response to pazu)I am having this problem with the latest 3.0 release. That is, I am not seeing the UPDATE statement in my server log.
In my post create I have a setter
setCompany(companyLocal);
However, this appears to be ignored. One way I am currently getting around this is to simply add the object to collection on the many side of the relationship.
Can anyone suggest anything? I'd be glad to provide additional information, although my thought is it may be something simple...
Thanks,
RC -
13. Re: CMR Fields not being persisted
dsundstrom Aug 6, 2002 6:23 PM (in response to pazu)This should be fixed in the 3.0.1 final release (today or tomorrow). If the final 3.0.1 release does not fix this, please post a bug report with a test case at sourceforge.
-
14. Re: CMR Fields not being persisted
rollc Aug 6, 2002 11:57 PM (in response to pazu)Thanks, Dain. I see that 3.0.1 was released yesterday. Can I assume that this is the release you are referring to? Also, do you know when a 3.0.1/Catalina final will be available?
Thanks again,
RC