On Sat, May 12, 2012 at 10:23 AM, hfriederichs <h.friederi...@ohra.nl> wrote:
> Igor,
>
> Josh suggested CDI as an alternative, in that respect it's the same as other
> approaches I've tried: to cumbersome, to complex for my goals, so in respect
> to what I want I don't think it's great.
>
> I'll look into the wicket-jee module in wicketstuff, but it is yet another
> extra 'thingy' you need for something that's so simple and basic... I wonder
> if anyone has ever coined the phrase 'boiler plate xml' or 'boiler plate
> components'. Maybe a quiz is a good idea. The Question is: fetch one row
> from a straightforward table in let's say an onclick of a wicket button,
> using jpa. The respondent that has the simplest solution gets eternal fame.

class JpaApplication extends WebApplication {
  EntityManagerFactory jpa;

  init() {  super.init(); jpa=Persistence.createEntityManagerFactory("demo"); }
  static JpaApplication get() { return (JpaApplication)application.get(); }
  EntityManager createEm() { return jpa.craeteEntityManager(); }
}

class MyPage extends WebPage {
  MyPage() {
     add(new Button("fetch") {
        onsubmit() {
           EntityManager em=JpaApplication.get().createEm();
           em.createQuery("FROM foo").setMaxResults(1).getResultList();
           em.close();
        }
    });}}

there you go. of course by the time you are done adapting this super
simple yet working example to something usable in an actual
application you will end up with something i described in my blog.

-igor

>
>> Of course, the CDI-blog goes with the usual great-gratitude-comments of
>> developers who couldn't figure it out either.
>
>>> whats wrong with that?
>
> Who says there's something wrong with that? It's just irony.
>
> Thanks anyways
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-go-tp4628562p4629186.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to