While answering this question, I realised I had made the same mistake in my own code for a game I am writing using an Entity-Component System. The problem arose when I decided to use a Finite State Machine to identify entity states and their behaviours.
State is an interface which enumerations implement. State also declares some methods, including an update method which all implementing states’ enum constants implement, so each state (IDLE, MOVING, etc.) has its own implementation of update.
The problem is that I have an abstract StateComponent<T extends State> class which contains a StateMachine<T>. Any Component that extends this (such as PlayerStateComponent extends StateComponent<PlayerState>) is added to the Entity. The StateMachine contains methods to change the state, and also a reference to the Entity which is needed so that other components owned by the entity can be retrieved.
The StateComponent itself has no reference to its owning Entity, but the StateMachine does. Does this still count as circular referencing? Is this acceptable? If not, is there any other way I can use an FSM in an ECS without breaking the component-based architecture?