com.atlassian.confluence.impl.journal
Class HibernateJournalDao

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate.support.HibernateDaoSupport
          extended by com.atlassian.confluence.impl.journal.HibernateJournalDao
All Implemented Interfaces:
JournalDao, org.springframework.beans.factory.InitializingBean

public class HibernateJournalDao
extends org.springframework.orm.hibernate.support.HibernateDaoSupport
implements JournalDao

JournalDao that uses Hibernate for persistence.

Since:
5.6

Field Summary
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
HibernateJournalDao()
           
HibernateJournalDao(com.atlassian.core.util.Clock clock)
           
 
Method Summary
 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.
 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.
 
Methods inherited from class org.springframework.orm.hibernate.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateJournalDao

public HibernateJournalDao()

HibernateJournalDao

public HibernateJournalDao(com.atlassian.core.util.Clock clock)
Method Detail

enqueue

public long enqueue(JournalEntry entry)
Description copied from interface: JournalDao
Adds the given entry to a journal.

Specified by:
enqueue in interface JournalDao
Parameters:
entry - entry to persist
Returns:
id generated for the entry

queueWithCustomCreationDate

@Internal
public void queueWithCustomCreationDate(JournalEntry entry,
                                                 Date creationDate)

findEntries

public List<JournalEntry> findEntries(JournalIdentifier journalId,
                                      long afterId,
                                      long ignoreWithinMillis,
                                      int maxEntries)
Description copied from interface: JournalDao
Finds 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:

  1. Create new entries as close to transaction commit as possible.
  2. Increase ignoreSinceMillis value.

Specified by:
findEntries in interface JournalDao
Parameters:
journalId - only entries with this journal id will be returned
afterId - only entries with id higher than this will be returned
ignoreWithinMillis - only entries created this many milliseconds ago or earlier will be returned
maxEntries - 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: JournalDao
Finds 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:
findMostRecentEntryByMessage in interface JournalDao
Parameters:
journalId - only entries with this journal id will be returned
message - the exact text of the journal entry message
Returns:
the Optional journal entry matching the search

removeEntriesOlderThan

public int removeEntriesOlderThan(Date date)
Description copied from interface: JournalDao
Removes entries from all journals that were created before the given date.

Specified by:
removeEntriesOlderThan in interface JournalDao
Parameters:
date - only entried with a date later than this will be returned
Returns:
number of removed entries

findLatestEntry

public com.atlassian.fugue.Option<JournalEntry> findLatestEntry(@Nonnull
                                                                JournalIdentifier journalId,
                                                                long ignoreWithinMillis)
Description copied from interface: JournalDao
Finds the latest journal entry if any.

Specified by:
findLatestEntry in interface JournalDao
Parameters:
journalId - identifier of the journal
ignoreWithinMillis - only entry created this many milliseconds ago or earlier will be returned
Returns:
the latest journal entry

countEntries

public int countEntries(@Nonnull
                        JournalIdentifier journalId,
                        long afterId,
                        long ignoreWithinMillis)
Description copied from interface: JournalDao
Counts the number of entries in a journal.

Specified by:
countEntries in interface JournalDao
Parameters:
journalId - identifier of the journal
afterId - only entries with id higher than this will be returned
ignoreWithinMillis - only entries created this many milliseconds ago or earlier will be returned


Copyright © 2003–2015 Atlassian. All rights reserved.