Package com.onec.posting
Class PostingEngine
java.lang.Object
com.onec.posting.PostingEngine
Posts documents: runs their
Postable logic, writes the resulting register movements and
totals, enforces non-negative balances, then flips _posted.
Transaction boundary — important
Posting runs inside its own JDBI transaction (Jdbi.useTransaction(org.jdbi.v3.core.HandleConsumer<X>)) on a connection
obtained directly from the DataSource. It is not enlisted in any ambient
Spring @Transactional that the caller may have opened. Two consequences follow:
- Do not wrap "save the document, then post it" in a single
@Transactionalmethod. Thesave()row is not yet committed, so JDBI — on a separate connection — cannot see it, theUPDATE ... SET _posted = TRUEmatches zero rows, and you silently get register movements with_postedstillfalse. Save (and let it commit) first, then callPostingService/post(...). - Posting is atomic in itself (movements, totals, balance checks and the
_postedflag all commit or roll back together), but it is a distinct transaction from the document write.
-
Constructor Summary
ConstructorsConstructorDescriptionPostingEngine(org.jdbi.v3.core.Jdbi jdbi, MetadataRegistry registry, Map<Class<?>, RegisterRepositoryImpl<?>> repositoryMap) PostingEngine(org.jdbi.v3.core.Jdbi jdbi, MetadataRegistry registry, Map<Class<?>, RegisterRepositoryImpl<?>> repositoryMap, OutboxWriter outboxWriter) PostingEngine(org.jdbi.v3.core.Jdbi jdbi, MetadataRegistry registry, Map<Class<?>, RegisterRepositoryImpl<?>> repositoryMap, OutboxWriter outboxWriter, PostEventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionvoidpost(DocumentObject document) preview(DocumentObject document) voidunpost(DocumentObject document)
-
Constructor Details
-
PostingEngine
public PostingEngine(org.jdbi.v3.core.Jdbi jdbi, MetadataRegistry registry, Map<Class<?>, RegisterRepositoryImpl<?>> repositoryMap) -
PostingEngine
public PostingEngine(org.jdbi.v3.core.Jdbi jdbi, MetadataRegistry registry, Map<Class<?>, RegisterRepositoryImpl<?>> repositoryMap, OutboxWriter outboxWriter) -
PostingEngine
public PostingEngine(org.jdbi.v3.core.Jdbi jdbi, MetadataRegistry registry, Map<Class<?>, RegisterRepositoryImpl<?>> repositoryMap, OutboxWriter outboxWriter, PostEventPublisher eventPublisher)
-
-
Method Details
-
post
-
preview
-
unpost
-