Path: csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!weretis.net!feeder4.news.weretis.net!news.albasani.net!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: The easiest framework for Java Database applications development released for production use Date: Mon, 07 Feb 2011 21:33:14 -0500 Organization: albasani.net Lines: 53 Message-ID: References: <740c95bd-a21f-4ad3-8733-6b3b61e44e18@l18g2000yqm.googlegroups.com> <92e64642-b624-4598-beaa-c57540a30733@k22g2000yqh.googlegroups.com> <55029b5a-726d-4e31-96b7-3de2adbe7f5d@d19g2000yql.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net Sm6Y5ak/dWR4bsZ8l77ncFIVWekiwb857V1+pafVFMVy86Etu7B/R00h4FfeMDFcalF/uPuk36yzz0ekt9naYw== NNTP-Posting-Date: Tue, 8 Feb 2011 02:32:59 +0000 (UTC) In-Reply-To: <55029b5a-726d-4e31-96b7-3de2adbe7f5d@d19g2000yql.googlegroups.com> Cancel-Lock: sha1:7zBB/gsQ5PzEyiGg8kXcGaC67XM= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 Injection-Info: news.albasani.net; logging-data="fVJ/QVaHh9DJACxjgj6x6gRAb5rmzV/xf20AtCVzRhkGBcbgDZR4tuux2WpvqjsiSw66povTbopaai4bqSoAW5RUqf00BdNldeZd4Faj64I0dW7m87OKuEgw2ImjjHDl"; mail-complaints-to="abuse@albasani.net" Xref: csiph.com comp.lang.java.programmer:26065 yaormaAdmin wrote: > What would the code you would write to get the data from the > message_table and echo it to the console in the example at www.yaorma.org > look like? You assume I would write code like that. I wouldn't, normally. In a toy example where everything fits in one 'main()' call, there's not much you can conclude about the utility of a framework. The question isn't whether you can simplify a single call to a database for a single hard-coded query. The question is whether you can build a robust, stable, extendible application backed by a database. Knocking away a couple of 'close()' calls is of minor value in such a context. But to answer your question for the toy example, something similar to public class Foo { @PersistenceContext( unitName = "pcontext" ) private EntityManager em; public List findMessages() { final CriteriaQuery cq = em.getCriteriaBuilder().createQuery( Message.class ); cq.select( cq.from( Message.class )); return em.createQuery( cq ).getResultList(); } public static void main( String [] args ) { System.out.println( new Foo().findMessages() ); } } Or I might use a JQL query instead of the 'CriteriaQuery'. It's just that the criteria approach is amenable to generic treatment - my actual code has a type parameter for the 'Message' type. -- Lew Ceci n'est pas une fenĂȘtre. .___________. |###] | [###| |##/ | *\##| |#/ * | \#| |#----|----#| || | * || |o * | o| |_____|_____| |===========|