1

Even though I use a specific ORM framework, Bold for Delphi, I'm more interested in framework agnostic theoretical view on the problem.

So the question is about having a persistent object and a transient attribute with initial value tag.

The initial tag specifies the value attribute will get when instance of owning object is created.

However when subsequently loading this object from persistence, what should be the value of transient attribute?

Should initial value tag be applied again? Logically, it should, otherwise it will be left unassigned (null).

I couldn't find any specs on this particular case in any of the docs.

Laurel
  • 5,965
  • 14
  • 31
  • 57

1 Answers1

2

We can't create object up to the DB record only - because we would lose all transient attributes. So, when you are loading a persistent object, it can be done only into the already created instance. And there is no other way of instantiating without using the base object constructor, which sets the initial values. Of course, some language could make a workaround about it, but why?

Gangnus
  • 24,044
  • 16
  • 90
  • 149
  • The framework I use sets initial value of attributes only when object is first created. On subsequent recreate prior to fetching it does not set initial value so transient attributes remain uninitialized. I want a comfirmation of my intention to treat this as a bug and fix in the framework. Perhaps I wasn't so clear in the question. –  Feb 28 '14 at 16:59
  • @DanielMaurić If we are talking about a concrete framework, I would look for how it has to be done and how it is done in the source code documentation. have you access to that? – Gangnus Feb 28 '14 at 19:04
  • @Gangus: It's a legacy product, docs don't specify this particular situation, but I do have the source and we maintain it ourselves. Currently it only sets initial value on first create of a persistent object, should I change it so that initial value is set on restore from db as well as on initial create ? –  Feb 28 '14 at 19:26
  • @DanielMaurić Are there some interfaces that this framework has to support? – Gangnus Feb 28 '14 at 20:15