-
15. Re: What if I want programmatic control of conversations?
keithnaas Feb 28, 2008 5:09 AM (in response to franciscoperedo)Is it because the flush mode is defaulting to auto?
-
16. Re: What if I want programmatic control of conversations?
jazir1979 Feb 28, 2008 5:39 AM (in response to franciscoperedo)Hi Keith,
Nah, Francisco pointed out the other day that even with MANUAL, the flush will occur when he calls persist() -- it's necessary in order to get the generated identifier.
The problem is that each method call is a transaction under CMT, so commit is occuring after the persist is flushed. If he uses BMT and injects a UserTransaction, he can get around this by manually doing ut.begin() and ut.commit() calls.
Daniel.
-
17. Re: What if I want programmatic control of conversations?
christian.bauer Feb 28, 2008 8:48 AM (in response to franciscoperedo)
Nah, Francisco pointed out the other day that even with MANUAL, the flush will occur when he calls persist() -- it's necessary in order to get the generated identifier.So? Pick a different non-stupid identity generator, like a sequence. Then persist() will not execute an INSERT but a SELECT to just get the new identifier. Btw, this is not related to flushing of the persistence context at all, it's called pre- vs. post-insert identifier generators.
-
18. Re: What if I want programmatic control of conversations?
franciscoperedo Feb 28, 2008 10:03 PM (in response to franciscoperedo)Click HELP for text formatting instructions. Then edit this text and check the preview.
-
19. Re: What if I want programmatic control of conversations?
franciscoperedo Feb 28, 2008 10:04 PM (in response to franciscoperedo)Yes! It works! @TransactionManagement(TransactionManagementType.BEAN) is the solution!!!!
Thanks!!!! -
20. Re: What if I want programmatic control of conversations?
franciscoperedo Feb 28, 2008 10:07 PM (in response to franciscoperedo)Yes, that is true... but only for databases that support non-stupid identity generation (like Oracle or PostgreSQL) but not for those with autonumerics (like SQLServer) and I wanted to find a way that worked for any database.
Regards, -
21. Re: What if I want programmatic control of conversations?
christian.bauer Feb 28, 2008 10:21 PM (in response to franciscoperedo)Hibernates SequenceStyleGenerator works on any database and emulates sequences on trash DBMS that don't support them directly (HSQL, MySQL, etc.). This wiki software is using it.