Package org.cyclos.impl.sql.postgresql
Class PostgresqlQueryHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.sql.BaseNativeQueryHandlerImpl
-
- org.cyclos.impl.sql.postgresql.PostgresqlQueryHandlerImpl
-
- All Implemented Interfaces:
CustomBean,NativeQueryHandler
public class PostgresqlQueryHandlerImpl extends BaseNativeQueryHandlerImpl
Postgresql implementation for native queries
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPostgresqlQueryHandlerImpl.CustomTemplatesCustom templates for Querydsl queries
-
Field Summary
-
Fields inherited from class org.cyclos.impl.sql.BaseNativeQueryHandlerImpl
applicationContext, jdbcTemplate, rawEntityManagerHandler
-
-
Constructor Summary
Constructors Constructor Description PostgresqlQueryHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcloseAccountBalances()Closes the account balances, returning the number of balances closedlongcopyLargeObject(long sourceOid)Makes a copy of the large object with the specified oid and returns the oid of the copy.voiddeleteLargeObject(long oid)Deletes the large object with the specified oid.List<InconsistentBalance>fixInconsistentAccountBalances(List<Long> accountIds)Fixes any wrong account balances, returning the account ids that were wrongcom.querydsl.sql.SQLQuery<?>from(com.querydsl.sql.RelationalPathBase<?>... from)com.querydsl.sql.SQLQuery<?>from(Connection connection, com.querydsl.sql.RelationalPathBase<?>... from)NativeAccountStatusgetAccountStatus(Account account, Date date)Returns the native account status at a given datecom.querydsl.jpa.JPQLTemplatesgetJpaQueryTemplates()Returns the templates used for jpa queriesLonggetNextTransactionNumber()Returns the number used to generate the next transaction numberLonggetObjectId(long soredFileId)Returns the oid associated to the specified stored file id.SearchHandlergetSearchHandler()Returns a handler to search on the databasecom.querydsl.sql.dml.SQLInsertClauseinsert(Connection connection, com.querydsl.sql.RelationalPath<?> alias)longinsertAccountsPendingToCharge(AccountFeeLog log)Inserts the references for the accounts pending to charge the given account fee loglonginsertArchiveAccountFees()Inserts theBackgroundTaskExecutions for each account fee log older thanCyclosProperties.getArchiveAccountFeesDays()voidinsertBackgroundTaskExecution(String className, String context)Tries to insert a new execution of the task with the given context, in case of conflicts (the same execution already exists) then do nothing.longinsertMailings(MailingList mailingList)Inserts mailings for all users for a given mailing list messagevoidinsertReindexBackgroundTasks(Class<? extends SimpleEntity> entityClass, String indexName, int batchSize)Inserts n executions ofIndexEntitiesBackgroundTaskfor a given entityvoidinsertTransferInitialStatus(TransferType transferType, TransferStatus status)Inserts the relation for current status and a log for each transfer of the given typevoidinsertUserIncomingMessages(SendMessageDTO sendMessage, MessageOwner messageOwner, User sendingUser, OutgoingMessage outgoing)Inserts incoming messages for users for a given outgoing messagelonginsertUsersForBulkAction(Long bulkActionId, UserQuery params)Inserts a record ofBulkActionUserfor each returned user of the given querycom.mysema.commons.lang.CloseableIterator<Record>iterateRecords(RecordQuery params)Iterates record entities according to the given query parameterscom.mysema.commons.lang.CloseableIterator<Long>iterateUserIds(UserQuery params)Iterates user ids according to the given query parameterscom.mysema.commons.lang.CloseableIterator<UserWithFieldsVO>iterateUsers(UserQuery params)Iterates user entities according to the given query parametersList<Long>nextAccountIdsToClose(int maxCount, Date limit)Returns up to the maximum count of account ids to close balance.InputStreamopenLargeObject(long oid)Opens the large object associated to the specified oid.
NOTE: After read, the input stream must be closed (the large object will be closed in turn).Pair<Set<String>,Set<Long>>purgeRemovedBuiltinLanguages()Removes all languages that were pointing toBuiltinLanguages that no longer exist, returning both the language templates that no longer exist and the ids of languages that were removedlongrebuildClosedAccountBalances()Rebuilds all closed account balances from the beginningvoidsetObjectId(long storedFileId, long oid)Sets the oid to the specified stored file id.booleansupportsBlobsInReadOnlyTransactions()Returns whether the underlying database supports accessing BLOBs from pure read-only transactionsbooleantryLock(LockKey key)Attempt to acquire an exclusive lock with a given key.booleantryLock(JdbcTemplate jdbc, LockKey key)Attempt to acquire an exclusive lock with a given key using the givenJdbcTemplate.com.querydsl.sql.dml.SQLUpdateClauseupdate(Connection connection, com.querydsl.sql.RelationalPath<?> alias)List<AccountStatusUpdateResult>updateAccountStatuses(Collection<AccountStatusUpdateParams> updates)Updates a set of account statuses.longwriteLargeObject(InputStream in)Creates a new large object reading the content from the stream and returns its oid.
NOTE: The input stream parameter won't be closed it is responsibility of the client code.-
Methods inherited from class org.cyclos.impl.sql.BaseNativeQueryHandlerImpl
getSessionData
-
-
-
-
Method Detail
-
closeAccountBalances
public long closeAccountBalances()
Description copied from interface:NativeQueryHandlerCloses the account balances, returning the number of balances closed
-
copyLargeObject
public long copyLargeObject(long sourceOid) throws IOExceptionDescription copied from interface:NativeQueryHandlerMakes a copy of the large object with the specified oid and returns the oid of the copy.- Throws:
IOException
-
deleteLargeObject
public void deleteLargeObject(long oid)
Description copied from interface:NativeQueryHandlerDeletes the large object with the specified oid.
-
fixInconsistentAccountBalances
public List<InconsistentBalance> fixInconsistentAccountBalances(List<Long> accountIds)
Description copied from interface:NativeQueryHandlerFixes any wrong account balances, returning the account ids that were wrong
-
from
public com.querydsl.sql.SQLQuery<?> from(Connection connection, com.querydsl.sql.RelationalPathBase<?>... from)
-
from
public com.querydsl.sql.SQLQuery<?> from(com.querydsl.sql.RelationalPathBase<?>... from)
-
getAccountStatus
public NativeAccountStatus getAccountStatus(Account account, Date date)
Description copied from interface:NativeQueryHandlerReturns the native account status at a given date
-
getJpaQueryTemplates
public com.querydsl.jpa.JPQLTemplates getJpaQueryTemplates()
Description copied from interface:NativeQueryHandlerReturns the templates used for jpa queries
-
getNextTransactionNumber
public Long getNextTransactionNumber()
Description copied from interface:NativeQueryHandlerReturns the number used to generate the next transaction number
-
getObjectId
public Long getObjectId(long soredFileId)
Description copied from interface:NativeQueryHandlerReturns the oid associated to the specified stored file id. Returns null if the stored file doesn't have any associated content.
-
getSearchHandler
public SearchHandler getSearchHandler()
Description copied from interface:NativeQueryHandlerReturns a handler to search on the database
-
insert
public com.querydsl.sql.dml.SQLInsertClause insert(Connection connection, com.querydsl.sql.RelationalPath<?> alias)
-
insertAccountsPendingToCharge
public long insertAccountsPendingToCharge(AccountFeeLog log)
Description copied from interface:NativeQueryHandlerInserts the references for the accounts pending to charge the given account fee log
-
insertArchiveAccountFees
public long insertArchiveAccountFees()
Description copied from interface:NativeQueryHandlerInserts theBackgroundTaskExecutions for each account fee log older thanCyclosProperties.getArchiveAccountFeesDays()
-
insertBackgroundTaskExecution
public void insertBackgroundTaskExecution(String className, String context)
Description copied from interface:NativeQueryHandlerTries to insert a new execution of the task with the given context, in case of conflicts (the same execution already exists) then do nothing.
-
insertMailings
public long insertMailings(MailingList mailingList)
Description copied from interface:NativeQueryHandlerInserts mailings for all users for a given mailing list message- Returns:
- the quantity of users that the mailing list is sending
-
insertReindexBackgroundTasks
public void insertReindexBackgroundTasks(Class<? extends SimpleEntity> entityClass, String indexName, int batchSize)
Description copied from interface:NativeQueryHandlerInserts n executions ofIndexEntitiesBackgroundTaskfor a given entity
-
insertTransferInitialStatus
public void insertTransferInitialStatus(TransferType transferType, TransferStatus status)
Description copied from interface:NativeQueryHandlerInserts the relation for current status and a log for each transfer of the given type
-
insertUserIncomingMessages
public void insertUserIncomingMessages(SendMessageDTO sendMessage, MessageOwner messageOwner, User sendingUser, OutgoingMessage outgoing)
Description copied from interface:NativeQueryHandlerInserts incoming messages for users for a given outgoing message
-
insertUsersForBulkAction
public long insertUsersForBulkAction(Long bulkActionId, UserQuery params)
Description copied from interface:NativeQueryHandlerInserts a record ofBulkActionUserfor each returned user of the given query
-
iterateRecords
public com.mysema.commons.lang.CloseableIterator<Record> iterateRecords(RecordQuery params)
Description copied from interface:NativeQueryHandlerIterates record entities according to the given query parameters
-
iterateUserIds
public com.mysema.commons.lang.CloseableIterator<Long> iterateUserIds(UserQuery params)
Description copied from interface:NativeQueryHandlerIterates user ids according to the given query parameters
-
iterateUsers
public com.mysema.commons.lang.CloseableIterator<UserWithFieldsVO> iterateUsers(UserQuery params)
Description copied from interface:NativeQueryHandlerIterates user entities according to the given query parameters
-
nextAccountIdsToClose
public List<Long> nextAccountIdsToClose(int maxCount, Date limit)
Description copied from interface:NativeQueryHandlerReturns up to the maximum count of account ids to close balance. Accounts that are returned:- Accounts that have never been closed yet
- Accounts whose last closing was before the given limit and the current account balance's date is newer than the last closing
-
openLargeObject
public InputStream openLargeObject(long oid)
Description copied from interface:NativeQueryHandlerOpens the large object associated to the specified oid.
NOTE: After read, the input stream must be closed (the large object will be closed in turn).
-
purgeRemovedBuiltinLanguages
public Pair<Set<String>,Set<Long>> purgeRemovedBuiltinLanguages()
Description copied from interface:NativeQueryHandlerRemoves all languages that were pointing toBuiltinLanguages that no longer exist, returning both the language templates that no longer exist and the ids of languages that were removed
-
rebuildClosedAccountBalances
public long rebuildClosedAccountBalances()
Description copied from interface:NativeQueryHandlerRebuilds all closed account balances from the beginning
-
setObjectId
public void setObjectId(long storedFileId, long oid)Description copied from interface:NativeQueryHandlerSets the oid to the specified stored file id.
-
supportsBlobsInReadOnlyTransactions
public boolean supportsBlobsInReadOnlyTransactions()
Description copied from interface:NativeQueryHandlerReturns whether the underlying database supports accessing BLOBs from pure read-only transactions
-
tryLock
public boolean tryLock(JdbcTemplate jdbc, LockKey key)
Description copied from interface:NativeQueryHandlerAttempt to acquire an exclusive lock with a given key using the givenJdbcTemplate.
-
tryLock
public boolean tryLock(LockKey key)
Description copied from interface:NativeQueryHandlerAttempt to acquire an exclusive lock with a given key. The lock will be bound to the current transaction, and will be automatically unlocked when the transaction ends.
-
update
public com.querydsl.sql.dml.SQLUpdateClause update(Connection connection, com.querydsl.sql.RelationalPath<?> alias)
-
updateAccountStatuses
public List<AccountStatusUpdateResult> updateAccountStatuses(Collection<AccountStatusUpdateParams> updates)
Description copied from interface:NativeQueryHandlerUpdates a set of account statuses. Must be called only after acquiring the lock on the affected accounts.
-
writeLargeObject
public long writeLargeObject(InputStream in) throws IOException
Description copied from interface:NativeQueryHandlerCreates a new large object reading the content from the stream and returns its oid.
NOTE: The input stream parameter won't be closed it is responsibility of the client code.- Throws:
IOException
-
-