<p>I have a SEAM app with some JPA/Hibernate entities. And I now wonder where to put my query, persistence methods.</p>

<p>The default choice seems to put them in a session bean layer with injected </p>

<pre><code>@PersistenceContext(...) @Inject EntityManager entityManager;
</code></pre>

<p>But I think I would rather have the methods on the entities themselves. What are the pro's/con's? </p>

<ol>
<li>Testablity?</li>
<li>Niceness?</li>
<li>Performance?</li>
</ol>

<p>And does anyone have links to best practices for interacting with the EntityManager etc. from methods on the Entities rather than session beans?</p>

<p>Best,
Anders</p>

I have no experience with SEAM, but from my experience with Java projects, I found it easiest to keep beans clear of persist methods. What we usually do:
Have beans for business objects (like "User" and "Setting" for example)
Have a DAO layer which can persist and retrieve these beans (simple CRUD)
Have a Service Layer which nows how to handle the beans, and maybe even how to build an aggregate of beans
This way, everything is pretty separated, and is easy to unittest. Performance is usually not an issue with this setup.