- Ya
- 4 Agosti 2026, 20:57 UTC
- Mwandishi
- Kamo
- Ahadi ya
- 975b5e3
An agent stakes an exclusive claim on closing a lead for a bounded window; an approver grants, edits or denies it, and colleagues can be offered a share of the commission. Three tables: the reservation, its commission splits, and an append-only audit trail. Design points that are load-bearing: - Lead, organization and member references are plain id columns with no foreign keys, matching LEAD_HISTORY and LEAD_TASK. The trail has to outlive lead deletion and member churn without either being able to block or cascade it. - dbNow() uses CAST(now() AS timestamp). CockroachDB's bare now() is TIMESTAMPTZ, which Hibernate 6 materializes as an Instant that cannot be cast to the declared LocalDateTime — and the ::timestamp shorthand is mangled by the native-query parser reading ':' as a parameter prefix. Neither shows up at compile time. - The paged list uses JpaSpecificationExecutor rather than JPQL with (:param IS NULL OR ...) guards, because CockroachDB rejects an untyped bind parameter in a bare IS NULL test. - LeadIdentity is a projection, not the Lead entity: Lead maps four @ManyToOne associations that default to EAGER, so listing 100 reservations by entity would fire hundreds of selects for data the grid never shows. - The history timeline orders by (dateCreated DESC, id DESC). CockroachDB's now() is the transaction timestamp, so rows written by one edit share it exactly; without the tiebreak an audit trail reshuffles itself between page loads. No stereotypes here — the owning service declares the beans, so no other service pays for the repository scan.