Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How value objects are saved and loaded?

Since there aren no respositories for value objects. How can I load all value objects?

Suppose we are modeling a blog application and we have this classes:

  • Post (Entity)
  • Comment (Value object)
  • Tag (Value object)
  • PostsRespository (Respository)

I Know that when I save a new post, its tags are saved with it in the same table. But how could I load all tags of all posts. Should PostsRespository have a method to load all tags? I usually do it, but I want to know others opinions

like image 810
yeraycaballero Avatar asked Feb 16 '10 23:02

yeraycaballero


1 Answers

I'm looking for a better solution for this question and I found this post:

http://gojko.net/2009/09/30/ddd-and-relational-databases-the-value-object-dilemma/

This post explain very well why there is a lot of confusion with value objects and databases. Here you are phrase which liked me too much:

  • "Persistence is not an excuse to turn everything to entities."

Gojko Adzic, give us three alternatives to save our value objects.

like image 61
yeraycaballero Avatar answered Sep 28 '22 07:09

yeraycaballero