I actually have to agree with Jose. (Don&#39;t worry, you are a smart guy, and we are not that smart :)<br><br>The EntityManager wrapper pattern in Forge is OK, but it&#39;s not a very strongly architected solution. I used it because it was easy, and I tend to think that solutions like it are done simply because &quot;even though it smells, nobody has a better idea of what to eat.&quot; In fact, the only reason Forge uses &quot;extends&quot; via PersistenceUtil is because I need to inject a properly scoped EntityManager into *something* in order to make sure the correct one is used. That being said, perhaps one solution is to offer multiple producers for EntityManagers:<br>
<ul><li>The stateless EntityManager</li><li>The request / conversation / session scoped EntityManagers</li><li>The application-scoped entity manager<br></li></ul>I am also actually very much in favor of Jason&#39;s idea: <a href="https://issues.jboss.org/browse/SEAMFORGE-280">https://issues.jboss.org/browse/SEAMFORGE-280</a> combined, or paired with something like <a href="http://code.google.com/p/lambico/">http://code.google.com/p/lambico/</a> (More the GORM-style approach) for simpler queries. DAOs are so 2005, and nobody liked them then.<br>

<br>
These objects could be exposed via @Named in EL, and of course be made injectable.<br><br>There are also other approaches, like &quot;Active Record,&quot; but in my opinion, the EntityManager poses a bit of a problem: It requires that it must already know about the entity. And in my experience that is an inherently difficult problem to overcome when attempting to build truly stateless applications - resulting in duplicate calls to the database to fetch data that you already have (just to sync things up.) While this is good for things like transactionality, it is bad for performance, but before I get too far off topic here, I&#39;m just going to stop :) In a sense, we are fighting against JPA combined with a Strongly Typed language. I think that the lambico approach (annotating interfaces, like what Spring did - yep I said it) is actually the best approach I&#39;ve seen in a long time.<br>
<br>When you can&#39;t beat &#39;em, join &#39;em. (Then beat &#39;em)<br><br>My 2 cents,<br>~Lincoln<br><br><br><br><div class="gmail_quote">On Wed, Sep 21, 2011 at 11:04 PM, José Rodolfo Freitas <span dir="ltr">&lt;<a href="mailto:joserodolfo.freitas@gmail.com">joserodolfo.freitas@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">And if something was written in an unclear English, I&#39;d like to remind you that those were my last minutes of a long day.<div>
<div></div><div class="h5"><div><br><br><div class="gmail_quote">On Wed, Sep 21, 2011 at 11:59 PM, José Rodolfo Freitas <span dir="ltr">&lt;<a href="mailto:joserodolfo.freitas@gmail.com" target="_blank">joserodolfo.freitas@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi guys,<div><br></div><div>I see some problems on using extends for this approach:</div><div><br></div><div>1) I tend to follow the principle composition over inheritance aka &quot;<span style="font-family:sans-serif;font-size:13px;line-height:19px;background-color:rgb(255, 255, 255)">Composite Reuse Principle&quot;,</span></div>


<div>The application design is more flexible when you&#39;re not highly tied with &quot;extends&quot;.</div><div>And since we already have something that kinda do some of the boilerplate code we&#39;re talking about, the entityManager, AND it works with a simple association (injection), I think that a better way to extend CRUD functionalities would be to wrap the EM up, add what we think is needed and inject in our EntityHandler or Home, or DAO or whatever. Otherwise we&#39;re going to create a new class that mostly will delegate calls to entityManager.</div>


<div><br></div><div>2) to keep code simple, I think that organizing classes by use cases (like booking for instance) is a really good approach, instead of having a PersonController, PersonService, PersonDAO and PersonEntity, that accumulates all kind of code related to Person use cases. Very often those classes become bloated. </div>


<div>Having a package that handle its own use case, HiringPerson, for instance (dunno if it&#39;s a good example, though), seems more natural. The code is more atomic and when maintaining code, you&#39;re not swimming at a bunch of code not related to your case, and this in fact gives more value to reuse and code design. than always using the same structure over and over again.</div>


<div>IMHO, If we create a genericDAO&lt;Entity T&gt; to be extended, I&#39;m afraid that will encourage that kind of approach (PersonController, PService, PDAO and etc). If we do a more flexible way, we can easier work with both ways as one&#39;d wish.</div>


<div><br></div><div>3) when we force the use of extends to do something that could be done with composition, we&#39;re killing other design possibilities. Frequently, we have to do an extends of an extends to workaround that. I mean if we have a class A  that extends G and by design it seems logical that A should extends B. People workaround that making B extending G (even though sometimes B has nothing to do with G) so A can use both classes as parents.</div>


<div><br></div><div>I really feel intimidated disagreeing with people that know so much like you guys, but I still think it&#39;s worth more discussion around that.</div><div><br><br><div class="gmail_quote"><div><div></div>

<div>On Wed, Sep 21, 2011 at 8:34 PM, Dan Allen <span dir="ltr">&lt;<a href="mailto:dan.j.allen@gmail.com" target="_blank">dan.j.allen@gmail.com</a>&gt;</span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div><div>On Wed, Sep 21, 2011 at 19:33, Dan Allen <span dir="ltr">&lt;<a href="mailto:dan.j.allen@gmail.com" target="_blank">dan.j.allen@gmail.com</a>&gt;</span> wrote:<br>


</div><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On Wed, Sep 21, 2011 at 18:30, Stuart Douglas <span dir="ltr">&lt;<a href="mailto:stuart.w.douglas@gmail.com" target="_blank">stuart.w.douglas@gmail.com</a>&gt;</span> wrote:<br></div><div class="gmail_quote">

<div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>I don&#39;t really like that idea, as it means that forge then becomes part of your build process. </div></div></blockquote><div><br></div></div><div>Ah, I was suggesting that you add the annotation, then use Forge as a utility once to create the dao classes. Sort of forward engineering.</div>




</div></blockquote><div><br></div></div><div>And the reason that&#39;s beneficial is because it tells forge which entities should have a dao...instead of it just blindly doing it for all entities. This could also be a hint as to which UI pages to create.</div>




<div><br></div><font color="#888888"><div>-Dan</div><div> </div></font></div><div><div></div><div>-- <br><div>Dan Allen</div>Principal Software Engineer, Red Hat | Author of Seam in Action<br>Registered Linux User #231597<br>


<br><div><a href="http://www.google.com/profiles/dan.j.allen#about" target="_blank">http://www.google.com/profiles/dan.j.allen#about</a><br>

<a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br><a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br></div><br>
</div></div><br></div></div><div>_______________________________________________<br>
seam-dev mailing list<br>
<a href="mailto:seam-dev@lists.jboss.org" target="_blank">seam-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/seam-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
<br></div></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
seam-dev mailing list<br>
<a href="mailto:seam-dev@lists.jboss.org">seam-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/seam-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/seam-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.com">http://ocpsoft.com</a><br><a href="http://scrumshark.com">http://scrumshark.com</a><br>&quot;Keep it Simple&quot;<br>