I have an entity that has field called 'group'. This field serves as a way to tie multiple entities together(it is like a reference field but not exactly in the way core uses it). Basically the entities in the same group are all variants of each other so they are tightly related. The value is either the ID of the entity or id of entity that the entity is a variant of(so there is always some "root" entity that is a source for the variants).

Anyway, what I am trying to do is to have the value to equal to entity id as default behavior. New entity will get ID only after it is saved into the storage and so in order to get the ID I have to wait for save() method and do the logic AFTER the fact. Currently I am using postSave() method in the entity to manually update the field data table and save the entity id as a value for this field.

It is working just fine but since RC1 the Drupal core has some advanced caching in it I am affraid this can become a problem in the future. So I am wondering how should I approach this but prevent saving the entity twice in a row?

closed as unclear what you're asking by Shawn Conn, Scott Joudry, Krishna Mohan, Yusef Mohamadi, kenorb Nov 23 '15 at 12:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.