Basic code is here, but we don't have tests in ORM, and I discovered problems when I added a test.
I will add a link to the test as soon as I have a JIRA key to create a branch with that key.