Why repository does not found entity_id ?
See original GitHub issueHello,
I’m trying to work with eventsourcing library and for the simple example :
class Ingredient(AggregateRoot):
class Event(AggregateRoot.Event):
pass
@classmethod
def create(cls, name: str):
return cls.__create__(name=name)
class Created(Event, AggregateRoot.Created):
pass
def __init__(self, name: str, **kwargs):
super().__init__(**kwargs)
self.name = name
def __repr__(self):
return f"<Ingredient (id={self.id} name={self.name}) object at {hex(id(self))}>"
class Ingredients(ProcessApplication):
@applicationpolicy
def policy(self, repository, event):
pass
@staticmethod
def create_ingredient(name: str):
return Ingredient.create(name)
When i try to execute the following code from a runner:
with SingleThreadedRunner(system, infrastructure_class=PopoApplication) as runner:
ingredient = runner.system.ingredients.create_ingredient(name="Test")
print(ingredient.id in runner.system.ingredients.repository)
the print returns “False” (the ingredient is not persisted ?) where i’m doing something wrong ?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
I can't get an entity ID in spring boot - Stack Overflow
You look to be trying to get your id from the user passed to you in the post request: actual_user_id = user.getId();.
Read more >Entity not creating id properly · Issue #313 · JetBrains/Exposed
I have the following table and entity: object Destinations : IdTable () { override val id ... entityId() val created = long("created").
Read more >CrudRepository (Spring Data Core 3.0.0 API)
Parameters: id - must not be null. Returns: the entity with the given id or Optional#empty() if none found. Throws: IllegalArgumentException - if...
Read more >StorageTxImpl (org.sonatype.nexus:nexus-repository 3.19.1 ...
Gets a component by id, regardless of which bucket it resides in, or null if not found. Component · findComponentInBucket(org.sonatype.nexus.common.entity.
Read more >Spring Data - CrudRepository save() Method - Baeldung
CrudRepository is a Spring Data interface for generic CRUD operations on a ... Here we specify the entity's class and the entity id's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It works now, thank you. You did a great work !
I will open other issues if I have others questions.
Note: https://eventsourcing.readthedocs.io/en/stable/topics/process.html#processes is not up to date 😃
@JeanDeuns I think it’s up to date? There’s a small difference between the code that you linked to and the code you wrote. The “general rule” is that the
__save__()
method should be called on new or changed aggregates, except when they are created or updated within a process application policy (so that the domain events can be persisted atomically with the tracking and notification information). In particular, in that bit of the documentation, there is a command method on the Commands process application which does call__save__()
. The other applications create and update aggregates with their process application policy, and so correctly do not call__save__()
. It’s a subtle aspect perhaps, but it reflects the atomicity of the recording.__save__()
is atomic only for the new domain events of a single aggregate. Hope that helps 😃