<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>LocalServiceUtil.getCount return a old value after insert a new record?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110351461" />
  <subtitle>LocalServiceUtil.getCount return a old value after insert a new record?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=110351461</id>
  <updated>2026-04-06T11:32:35Z</updated>
  <dc:date>2026-04-06T11:32:35Z</dc:date>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110396511" />
    <author>
      <name>Tinh Nguyen</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110396511</id>
    <updated>2018-07-02T07:02:02Z</updated>
    <published>2018-07-02T07:02:02Z</published>
    <summary type="html">&lt;p&gt;Finally, i found reason when i using update() of localServiceUtil it
  will not change cache . I must using add() and everything work perfectly.&lt;/p&gt;
&lt;p&gt;I think different thing at model.setNew(true) in add(). &lt;/p&gt;</summary>
    <dc:creator>Tinh Nguyen</dc:creator>
    <dc:date>2018-07-02T07:02:02Z</dc:date>
  </entry>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110362700" />
    <author>
      <name>Tinh Nguyen</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110362700</id>
    <updated>2018-06-28T07:10:08Z</updated>
    <published>2018-06-28T07:10:08Z</published>
    <summary type="html">&lt;p&gt;Actually, I'm trying with a CRUD database example . I'll check my
  code again then try create a new project.&lt;br /&gt; I'll back when i done.&lt;/p&gt;
&lt;p&gt;Anyway thanks for responding.&lt;/p&gt;</summary>
    <dc:creator>Tinh Nguyen</dc:creator>
    <dc:date>2018-06-28T07:10:08Z</dc:date>
  </entry>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110361500" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110361500</id>
    <updated>2018-06-28T05:25:01Z</updated>
    <published>2018-06-28T05:25:01Z</published>
    <summary type="html">&lt;p&gt;I'm reading several conflicting statements here.&lt;/p&gt;
&lt;p&gt;The others are right, pointing to Liferay's cache: When you manually
  insert records into the database, you can't expect Liferay's caches to
  be current and will need to invalidate them yourself. Or better: Don't
  write to the database manually.&lt;/p&gt;
&lt;p&gt;In case there's something wrong with your code, please share your
  LocalServiceImpl code for the method that inserts into the database,
  and the code that calls this in order to insert.&lt;/p&gt;
&lt;p&gt;If you're on Liferay 7, you should just use a @Reference to the
  service (interface) instead of the LocalServiceUtil. (this wouldn't
  change much in your case, but while we're at it, this could be changed
  as well)&lt;/p&gt;</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2018-06-28T05:25:01Z</dc:date>
  </entry>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110360763" />
    <author>
      <name>Tinh Nguyen</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110360763</id>
    <updated>2018-06-28T01:50:37Z</updated>
    <published>2018-06-28T01:50:37Z</published>
    <summary type="html">&lt;p&gt;Absolutely,  I added successfully to database and show it on
  searchContainer. But in another jsp file,  i used
  LocalServiceUtil.getCount then it still return a old result (Here: 10 records).&lt;/p&gt;</summary>
    <dc:creator>Tinh Nguyen</dc:creator>
    <dc:date>2018-06-28T01:50:37Z</dc:date>
  </entry>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110354449" />
    <author>
      <name>Ravi Shah</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110354449</id>
    <updated>2018-06-27T10:39:34Z</updated>
    <published>2018-06-27T10:39:34Z</published>
    <summary type="html">&lt;p&gt;Is that your custom entity?&lt;/p&gt;</summary>
    <dc:creator>Ravi Shah</dc:creator>
    <dc:date>2018-06-27T10:39:34Z</dc:date>
  </entry>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110353809" />
    <author>
      <name>Tinh Nguyen</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110353809</id>
    <updated>2018-06-27T10:31:08Z</updated>
    <published>2018-06-27T10:31:08Z</published>
    <summary type="html">&lt;p&gt;Hi Samuel Kong and Ravi Shah,&lt;/p&gt;
&lt;p&gt;I did insert new by LocalServiceUtil.update...&lt;/p&gt;</summary>
    <dc:creator>Tinh Nguyen</dc:creator>
    <dc:date>2018-06-27T10:31:08Z</dc:date>
  </entry>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110353107" />
    <author>
      <name>Samuel Kong</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110353107</id>
    <updated>2018-06-27T10:21:21Z</updated>
    <published>2018-06-27T10:21:21Z</published>
    <summary type="html">&lt;p&gt;How did you add the 2 records? Did you add it manually or did you use
  LocalServiceUtil to add. If you're not using LocalServiceUtil to add,
  there's no way for the portal to know that it needs to update it's cache.&lt;/p&gt;</summary>
    <dc:creator>Samuel Kong</dc:creator>
    <dc:date>2018-06-27T10:21:21Z</dc:date>
  </entry>
  <entry>
    <title>RE: LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110352399" />
    <author>
      <name>Ravi Shah</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110352399</id>
    <updated>2018-06-27T10:05:44Z</updated>
    <published>2018-06-27T10:05:44Z</published>
    <summary type="html">&lt;p&gt;Can you please confirm if you have manually inserted record in
  database? If yes, try Clear Database Cache option under server administration. &lt;/p&gt;</summary>
    <dc:creator>Ravi Shah</dc:creator>
    <dc:date>2018-06-27T10:05:44Z</dc:date>
  </entry>
  <entry>
    <title>LocalServiceUtil.getCount return a old value after insert a new record?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110351460" />
    <author>
      <name>Tinh Nguyen</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=110351460</id>
    <updated>2018-06-27T09:38:54Z</updated>
    <published>2018-06-27T09:38:54Z</published>
    <summary type="html">&lt;p&gt;Hi all,&lt;br /&gt; I have a problem. When i change database such as insert
  a new record then LocalService still get a old version of database.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;Table A have 10 records. I add 2 new records and
  use LocalServiceUtil.getCount in portlet then i still get 10 result.&lt;/p&gt;
&lt;p&gt;What 's happening?&lt;/p&gt;
&lt;p&gt;P/S: I added by handle in msql workbench.&lt;/p&gt;
&lt;p&gt;Please help me.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Thanks for reading&lt;/p&gt;
&lt;p&gt;Tinhnx&lt;/p&gt;</summary>
    <dc:creator>Tinh Nguyen</dc:creator>
    <dc:date>2018-06-27T09:38:54Z</dc:date>
  </entry>
</feed>
