title: Attempt to cast instance to PersistenceCapable failed. Ensure that it's been enhanced
body: <p>I'm trying out OpenJPA 2.0.1 for the first time, and am getting:</p>
  <pre><code>79  WARN   [main] openjpa.Runtime - The configuration property named &quot;openjpa.Id&quot; was not recognized and will be ignored, although the name closely matches a valid property called &quot;openjpa.Id&quot;.
  179  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.0.1
  371  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class &quot;org.apache.openjpa.jdbc.sql.PostgresDictionary&quot; (PostgreSQL 8.4.4 ,PostgreSQL Native Driver PostgreSQL 9.0 JDBC4 (build 801)).
  &lt;openjpa-2.0.1-r422266:989424 nonfatal user error&gt; org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance &quot;x.quality.QualityQuery@4c4b11e9&quot; to PersistenceCapable failed.  Ensure that it has been enhanced.
  FailedObject: x.quality.QualityQuery@4c4b11e9
      at org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4559)
      at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2561)
      at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2423)
      at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1069)
      at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:706)
      at ...
  </code></pre>
  <p>According to <a href="http://openjpa.apache.org/builds/2.0.1/apache-openjpa-2.0.1/docs/manual/ref_guide_pc_enhance.html#ref_guide_pc_enhance_runtime" rel="nofollow noreferrer">the OpenJPA docs</a>, I shouldn't have to do anything to get the basic enhancement at runtime:</p>
  <blockquote>
  <p>2.5.  Omitting the OpenJPA enhancer</p>
  <p>OpenJPA does not require that the
  enhancer be run. If you do not run the
  enhancer, OpenJPA will fall back to
  one of several possible alternatives
  for state tracking, depending on the
  execution environment.</p>
  <p>Java 6 class
  retransformation:</p>
  <p>if you are running
  your application in a Java 6
  environment, OpenJPA will attempt to
  dynamically register a
  ClassTransformer that will redefine
  your persistent classes on the fly to
  track access to persistent data.
  Additionally, OpenJPA will create a
  subclass for each of your persistent
  classes. When you execute a query or
  traverse a relation, OpenJPA will
  return an instance of the subclass.
  This means that the instanceof
  operator will work as expected, but
  o.getClass() will return the subclass
  instead of the class that you wrote.
  You do not need to do anything at all
  to get this behavior. OpenJPA will
  automatically detect whether or not
  the execution environment is capable
  of Java 6 class retransformation.</p>
  </blockquote>
  <p>Any clues why this isn't working?  Thanks much...</p>
  <p>(Bonus points for why the openjpa.Id warning happens - I haven't set any such property...)</p>