Determine if unsaved (not flushed) changes exist in a repository

2 views
Skip to first unread message

Rico Leuthold

unread,
Mar 28, 2011, 12:52:25 PM3/28/11
to flextrine
Hi,

I'm looking for a (flextrine) way to determine if there are unsaved
(not flushed) changes made to entities of a repository.
e.g.

if( repository.hasChanges )
{
entityManager.flush();
}

Certainly, I can implement something like this in- or outside of
flextrine. Just wondering if this already exists.

Thank you
- rico

Dave Keen

unread,
Mar 28, 2011, 2:11:22 PM3/28/11
to flex...@googlegroups.com, Rico Leuthold
Try:

if (entityManager.getUnitOfWork().size() > 0) {
    entityManager.flush();
}

although if all you are doing is flushing there is no need as entityManager.flush() shouldn't do anything unless there is something to do!

Dave
No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.894 / Virus Database: 271.1.1/3535 - Release Date: 03/28/11 08:34:00

Reply all
Reply to author
Forward
0 new messages