title: Spring Statemachine persistence
body: <p>I am testing Spring Statemachine and in particular I am interesting in applying the statemachine to manage the state of my objects.</p>
  
  <p>My Statemachine is of type <code>StateMachine&lt;EpisodeState, EpisodeEvent&gt;</code>.</p>
  
  <p>My business object, <code>Episode</code>, has an enum property (<code>state</code>) of type <code>EpisodeState</code>, which should hold the statemachine state of the episode.  I have a batch process that will obtain an instance of Statemachine at initialization.  I would like to follow the basic flow:</p>
  
  <ul>
  <li>Load an <code>Episode</code> from the database</li>
  <li>Set the current state of the Statemachine from the <code>EpisodeState</code> that is in that <code>Episode</code> instance.</li>
  <li>Send an event to the Statemachine.</li>
  <li>Get the resultant state from the Statemachine (post event) and set the <code>EpisodeState</code> in my <code>Episode</code> instance.</li>
  <li>Save the <code>Episode</code> instance.</li>
  </ul>
  
  <p>The documentation mentions an <code>extendedState</code> property, which in my tests is empty, but seems to support a map of arbitrary objects which I suppose I could use to hold the primary key of my <code>Episode</code>, but I am at a loss as to how to set the current state of the statemachine to the <code>EpisodeState</code> value in the <code>Episode</code>.</p>
  
  <p>I have configured the statemachine with a <code>StateMachineInterceptorAdapter&lt;EpisodeState, EpisodeEvent&gt;</code>, and I can see the information at pre/post stateChange and at pre/post Transition, as well as the <code>preEvent</code>.</p>