public class HibernateJournalDao extends org.springframework.orm.hibernate5.support.HibernateDaoSupport implements JournalDao
JournalDao
that uses Hibernate for
persistence.Constructor and Description |
---|
HibernateJournalDao() |
HibernateJournalDao(com.atlassian.core.util.Clock clock) |
Modifier and Type | Method and Description |
---|---|
int |
countEntries(JournalIdentifier journalId,
long afterId,
long ignoreWithinMillis)
Counts the number of entries in a journal.
|
long |
enqueue(JournalEntry entry)
Adds the given entry to a journal.
|
List<JournalEntry> |
findEntries(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(JournalIdentifier journalId,
long ignoreWithinMillis)
Finds the latest journal entry if any.
|
com.atlassian.fugue.Option<JournalEntry> |
findMostRecentEntryByMessage(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(Date date)
Removes entries from all journals that were created before the given
date.
|
public HibernateJournalDao()
public HibernateJournalDao(com.atlassian.core.util.Clock clock)
public long enqueue(JournalEntry entry)
JournalDao
enqueue
in interface JournalDao
entry
- entry to persist@Internal public void queueWithCustomCreationDate(JournalEntry entry, Date creationDate)
public List<JournalEntry> findEntries(JournalIdentifier journalId, long afterId, long ignoreWithinMillis, int maxEntries)
JournalDao
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:
findEntries
in interface JournalDao
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 processpublic com.atlassian.fugue.Option<JournalEntry> findMostRecentEntryByMessage(@Nonnull JournalIdentifier journalId, String message)
JournalDao
Note 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 JournalDao
journalId
- only entries with this journal id will be returnedmessage
- the exact text of the journal entry messagepublic int removeEntriesOlderThan(Date date)
JournalDao
removeEntriesOlderThan
in interface JournalDao
date
- only entried with a date later than this will be returnedpublic com.atlassian.fugue.Option<JournalEntry> findLatestEntry(@Nonnull JournalIdentifier journalId, long ignoreWithinMillis)
JournalDao
findLatestEntry
in interface JournalDao
journalId
- identifier of the journalignoreWithinMillis
- only entry created this many milliseconds ago
or earlier will be returnedpublic JournalEntry findEntry(long entryId)
JournalDao
findEntry
in interface JournalDao
entryId
- identifier of the journal entrypublic int countEntries(@Nonnull JournalIdentifier journalId, long afterId, long ignoreWithinMillis)
JournalDao
countEntries
in interface JournalDao
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 returnedCopyright © 2003–2017 Atlassian. All rights reserved.