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.
|
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)
JournalDao
enqueue
in interface JournalDao
entry
- entry to persist@Internal public void queueWithCustomCreationDate(JournalEntry entry, Date creationDate)
public List<JournalEntry> findEntries(@NonNull 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(@NonNull 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–2019 Atlassian. All rights reserved.