Class HibernateJournalDao
java.lang.Object
com.atlassian.confluence.impl.journal.HibernateJournalDao
- All Implemented Interfaces:
JournalDao
JournalDao that uses Hibernate for
persistence.- Since:
- 5.6
-
Constructor Summary
ConstructorsConstructorDescriptionHibernateJournalDao(org.hibernate.SessionFactory sessionFactory, com.atlassian.core.util.Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionintcountEntries(@NonNull JournalIdentifier journalId, long afterId, long ignoreWithinMillis) Counts the number of entries in a journal.longenqueue(@NonNull JournalEntry entry) Adds the given entry to a journal.voidenqueue(@NonNull Collection<JournalEntry> entries) Adds a collection of given entries to a journal.com.atlassian.fugue.Option<JournalEntry>Finds the earliest journal entry if any.findEntries(@NonNull JournalIdentifier journalId, long afterId, long ignoreWithinMillis, int maxEntries) Finds journal entries that were added after an entry with the given id but earlier than given milliseconds ago.findEntry(long entryId) Finds the specified journal entry, if it exists.com.atlassian.fugue.Option<JournalEntry>findLatestEntry(@NonNull JournalIdentifier journalId, long ignoreWithinMillis) Finds the latest journal entry if any.com.atlassian.fugue.Option<JournalEntry>findMostRecentEntryByMessage(@NonNull JournalIdentifier journalId, String message) Finds the most recent journal entry (if any) for the given journal that exactly matches the given journal entry message.intremoveEntriesOlderThan(@NonNull Date date) Removes entries from all journals that were created before the given date.intremoveEntriesOlderThanExclusive(@NonNull Date date, Collection<String> excludingJournalNames) Removes entries from journals that were created before the given date.intremoveEntriesOlderThanInclusive(@NonNull Date date, Collection<String> journalNames) Removes entries from journals that were created before the given date.voidupdateEntry(JournalEntry journalEntry) Update a persistent journal entry
-
Constructor Details
-
HibernateJournalDao
public HibernateJournalDao(org.hibernate.SessionFactory sessionFactory, com.atlassian.core.util.Clock clock)
-
-
Method Details
-
enqueue
Description copied from interface:JournalDaoAdds the given entry to a journal.- Specified by:
enqueuein interfaceJournalDao- Parameters:
entry- entry to persist- Returns:
- id generated for the entry
-
enqueue
Description copied from interface:JournalDaoAdds a collection of given entries to a journal. Adding multiple records in one transaction is more efficient than inserting them one by one.- Specified by:
enqueuein interfaceJournalDao- Parameters:
entries- entries to persist
-
findEntries
public List<JournalEntry> findEntries(@NonNull JournalIdentifier journalId, long afterId, long ignoreWithinMillis, int maxEntries) Description copied from interface:JournalDaoFinds journal entries that were added after an entry with the given id but earlier than given milliseconds ago. Entries are returned in ascending order of their identifier.This method can miss some entries due to identifier assignment and entry insertion not being an atomic operation. The risk of missed entries can be reduced in two ways:
- Create new entries as close to transaction commit as possible.
- Increase ignoreSinceMillis value.
- Specified by:
findEntriesin interfaceJournalDao- Parameters:
journalId- only entries with this journal id will be returnedafterId- only entries with id higher than this will be returnedignoreWithinMillis- only entries created this many milliseconds ago or earlier will be returnedmaxEntries- maximum number of entries to process- Returns:
- journal entries that were added after an entry with the given id
-
findMostRecentEntryByMessage
public com.atlassian.fugue.Option<JournalEntry> findMostRecentEntryByMessage(@NonNull JournalIdentifier journalId, String message) Description copied from interface:JournalDaoFinds the most recent journal entry (if any) for the given journal that exactly matches the given journal entry message.Note that this operation is likely to EXTREMELY SLOW when the journal gets above a certain size. Do not use in production code.
- Specified by:
findMostRecentEntryByMessagein interfaceJournalDao- Parameters:
journalId- only entries with this journal id will be returnedmessage- the exact text of the journal entry message- Returns:
- the Optional journal entry matching the search
-
removeEntriesOlderThan
Description copied from interface:JournalDaoRemoves entries from all journals that were created before the given date.- Specified by:
removeEntriesOlderThanin interfaceJournalDao- Parameters:
date- only entried with a date later than this will be returned- Returns:
- number of removed entries
-
removeEntriesOlderThanExclusive
public int removeEntriesOlderThanExclusive(@NonNull Date date, Collection<String> excludingJournalNames) Description copied from interface:JournalDaoRemoves entries from journals that were created before the given date. Excluding journal if name match with excludingJournalName- Specified by:
removeEntriesOlderThanExclusivein interfaceJournalDao- Returns:
-
removeEntriesOlderThanInclusive
Description copied from interface:JournalDaoRemoves entries from journals that were created before the given date. Excluding journal if name match with journalNames- Specified by:
removeEntriesOlderThanInclusivein interfaceJournalDao- Returns:
-
findLatestEntry
public com.atlassian.fugue.Option<JournalEntry> findLatestEntry(@NonNull JournalIdentifier journalId, long ignoreWithinMillis) Description copied from interface:JournalDaoFinds the latest journal entry if any.- Specified by:
findLatestEntryin interfaceJournalDao- Parameters:
journalId- identifier of the journalignoreWithinMillis- only entry created this many milliseconds ago or earlier will be returned- Returns:
- the latest journal entry
-
findEarliestEntry
Description copied from interface:JournalDaoFinds the earliest journal entry if any.- Specified by:
findEarliestEntryin interfaceJournalDao- Returns:
- the earliest journal entry across all journals
-
findEntry
Description copied from interface:JournalDaoFinds the specified journal entry, if it exists.- Specified by:
findEntryin interfaceJournalDao- Parameters:
entryId- identifier of the journal entry- Returns:
- the journal entry matching the given id
-
countEntries
public int countEntries(@NonNull JournalIdentifier journalId, long afterId, long ignoreWithinMillis) Description copied from interface:JournalDaoCounts the number of entries in a journal.- Specified by:
countEntriesin interfaceJournalDao- Parameters:
journalId- identifier of the journalafterId- only entries with id higher than this will be returnedignoreWithinMillis- only entries created this many milliseconds ago or earlier will be returned
-
updateEntry
Description copied from interface:JournalDaoUpdate a persistent journal entry- Specified by:
updateEntryin interfaceJournalDao- Parameters:
journalEntry- the journal entry must be persistent
-