public class HibernateJournalDao extends Object implements JournalDao
JournalDao that uses Hibernate for
persistence.| Constructor and Description |
|---|
HibernateJournalDao(org.hibernate.SessionFactory sessionFactory) |
HibernateJournalDao(org.hibernate.SessionFactory sessionFactory,
com.atlassian.core.util.Clock clock) |
| Modifier and Type | Method and Description |
|---|---|
int |
countEntries(@NonNull JournalIdentifier journalId,
long afterId,
long ignoreWithinMillis)
Counts the number of entries in a journal.
|
long |
enqueue(@NonNull JournalEntry entry)
Adds the given entry to a journal.
|
com.atlassian.fugue.Option<JournalEntry> |
findEarliestEntry()
Finds the earliest journal entry if any.
|
List<JournalEntry> |
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.
|
JournalEntry |
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.
|
void |
queueWithCustomCreationDate(JournalEntry entry,
Date creationDate) |
int |
removeEntriesOlderThan(@NonNull Date date)
Removes entries from all journals that were created before the given
date.
|
public HibernateJournalDao(org.hibernate.SessionFactory sessionFactory)
public HibernateJournalDao(org.hibernate.SessionFactory sessionFactory,
com.atlassian.core.util.Clock clock)
public long enqueue(@NonNull JournalEntry entry)
JournalDaoenqueue in interface JournalDaoentry - entry to persist@Internal public void queueWithCustomCreationDate(JournalEntry entry, Date creationDate)
public List<JournalEntry> findEntries(@NonNull JournalIdentifier journalId, long afterId, long ignoreWithinMillis, int maxEntries)
JournalDaoThis 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:
findEntries in interface JournalDaojournalId - 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 processpublic com.atlassian.fugue.Option<JournalEntry> findMostRecentEntryByMessage(@NonNull JournalIdentifier journalId, String message)
JournalDaoNote that this operation is likely to EXTREMELY SLOW when the journal gets above a certain size. Do not use in production code.
findMostRecentEntryByMessage in interface JournalDaojournalId - only entries with this journal id will be returnedmessage - the exact text of the journal entry messagepublic int removeEntriesOlderThan(@NonNull Date date)
JournalDaoremoveEntriesOlderThan in interface JournalDaodate - only entried with a date later than this will be returnedpublic com.atlassian.fugue.Option<JournalEntry> findLatestEntry(@NonNull JournalIdentifier journalId, long ignoreWithinMillis)
JournalDaofindLatestEntry in interface JournalDaojournalId - identifier of the journalignoreWithinMillis - only entry created this many milliseconds ago
or earlier will be returnedpublic com.atlassian.fugue.Option<JournalEntry> findEarliestEntry()
JournalDaofindEarliestEntry in interface JournalDaopublic JournalEntry findEntry(long entryId)
JournalDaofindEntry in interface JournalDaoentryId - identifier of the journal entrypublic int countEntries(@NonNull JournalIdentifier journalId, long afterId, long ignoreWithinMillis)
JournalDaocountEntries in interface JournalDaojournalId - 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 returnedCopyright © 2003–2021 Atlassian. All rights reserved.