[WIP] Ticket 1099

create a new doctrine-based method to use from template based on old dbobject method.
also contains other fixes.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #1099
| Refs tickets  | -
| License       | MIT
| Doc PR        | -

todo
 - [ ] confirm the new method works where needed.