Wicket and JPA: <i>please</i> a simple way to go

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
Hello,

I'm using wicket 1.5.4, and I tried various approaches in using Wicket and JPA (using webshere/open jpa). I looked at several posts here, but I keep ending up writing more boiler plate code and configuration than with plain old jdbc.
So.
I don't want to write factories. I don't want to write Managers. I don't want to use Guice. I'd like to inject an EntityManager, but there's no Servlet, and injecting it in a ServletContextListener obviously doesn't work.
If your response is like: look at this forum for '....' please don't respond.

Please help
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

Josh Kamau
You dont want to use cdi either?

On 12 May 2012 12:22, "hfriederichs" <[hidden email]> wrote:

Hello,

I'm using wicket 1.5.4, and I tried various approaches in using Wicket and
JPA (using webshere/open jpa). I looked at several posts here, but I keep
ending up writing /more/ boiler plate code and configuration than with plain
old jdbc.
So.
I don't want to write factories. I don't want to write Managers. I don't
want to use Guice. I'd like to inject an EntityManager, but there's no
Servlet, and injecting it in a ServletContextListener obviously doesn't
work.
If your response is like: look at this forum for '....' please don't
respond.

Please help

--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-go-tp4628562.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
I looked at it, shortly. It's a perfect example of what I mean. I looked at a blog by Igor V. And there we go again: you have to do this; and than that. And then configure this. And don't forget to add a line in ....xml.
And in the end, put it all together and it's so great.

I don't think so.

I think JPA has to make life easier, and it does for me when I'm not using Wicket: inject an EntityManager and do my db-stuff. That's how it should be, IMHO.

Of course, the CDI-blog goes with the usual great-gratitude-comments of developers who couldn't figure it out either.
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

Josh Kamau
Use ebean then. Www.avaje.org  . You just add 1 properties file and you can
start persisting your jpa  entities

On 12 May 2012 12:58, "hfriederichs" <[hidden email]> wrote:

I looked at it, shortly. It's a perfect example of what I mean. I looked at
a
blog by Igor V. And there we go again: you have to do this; and than that.
And then configure this. And don't forget to add a line in ....xml.
And in the end, put it all together and it's so great.

I don't think so.

I think JPA has to make life easier, and it does for me when I'm not using
Wicket: inject an EntityManager and do my db-stuff. That's how it should be,
IMHO.

Of course, the CDI-blog goes with the usual great-gratitude-comments of
developers who couldn't figure it out either.

--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-go-tp4628562p4628598.html

Sent from the Users forum mailing list archive at Nabble.com.

-------------------------------------...
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

Igor Vaynberg-2
In reply to this post by hfriederichs
On Sat, May 12, 2012 at 2:58 AM, hfriederichs <[hidden email]> wrote:
> I looked at it, shortly. It's a perfect example of what I mean. I looked at a
> blog by Igor V. And there we go again: you have to do this; and than that.
> And then configure this. And don't forget to add a line in ....xml.
> And in the end, put it all together and it's so great.

my blog explains how to create an application architecture based on
conversations. once its set up you dont have to touch it again and it
makes life much simpler whether you are using wicket or not. very
little of the article has to do with wicket itself.

> I don't think so.

thats nice.

> I think JPA has to make life easier, and it does for me when I'm not using
> Wicket: inject an EntityManager and do my db-stuff. That's how it should be,
> IMHO.

when you are not using it with wicket what are you using it with?
websphere and servlets? sounds like websphere is using JEE to manage
jpa for you, so use wicket-jee module in wicketstuff. it will allow
you to inject the EntityManager into wicket components.

-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?

-igor
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-go-tp4628562p4628598.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
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.

> 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
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

James Carman-3
Wicket core tries to stay "stack agnostic".  If you want technology
specific stuff, you have to use extra modules.
On May 12, 2012 1:23 PM, "hfriederichs" <[hidden email]> 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.
>
> > 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
James, what is technology specific about JPA?
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

James Carman
What if people want to use Hibernate?  What if people want to use
Cayenne?  What if people want to use iBatis/myBatis?  What if folks
want to use just plain ole JDBC?

The point is that the "core" of Wicket tries to stay as uncluttered as
possible, relying upon add-on modules to adapt it to other
environments (such as JEE like you're used to).  I would suggest you
take a look at the examples folks are showing you and play with them.
I think you'll find that the boilerplate stuff you have to do drops
off considerably after you get things working the way you want.  There
are even maven archetypes out there (legup is one I think others are
using) to help you get a fully working version set up in no time.

On Sat, May 12, 2012 at 3:05 PM, hfriederichs <[hidden email]> wrote:

> James, what is technology specific about JPA?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-go-tp4628562p4629309.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

Igor Vaynberg-2
In reply to this post by hfriederichs
On Sat, May 12, 2012 at 10:23 AM, hfriederichs <[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
In reply to this post by James Carman
I have things working, in two versions: one with a 'PersistenceManagerSingleton' I wrote, ugly, and one based on jndi-lookups of both the EntityManager and the UserTransaction, ugly too, for sticking to jndi-lookups. A third I am thinking of is create an EJB-project alongside my WebModule, so I can do my Injection stuff there. A fourth could be the wicketstuff JEE-module.

I think you're missing my point. It doesn´t matter that there are loads of examples. As I see it, they are all far too complex for such simple a task.

And I think I´m missing your point: I still don't get what's technology specific about JPA. Isn't it just a Java API like JMS or JaxWS?
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

James Carman
On Sat, May 12, 2012 at 3:42 PM, hfriederichs <[hidden email]> wrote:
> And I think I´m missing your point: I still don't get what's technology
> specific about JPA. Isn't it just a Java API like JMS or JaxWS?
>

Yes, JPA is *an* API, but it's not the only persistence API out there.
 If Wicket were to "pick a favorite", then of course there would be
folks out there that wouldn't like it.  So, it doesn't.  However,
there are plenty of add-on modules for you to choose from that make it
much easier for you to use your API of choice.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
In reply to this post by Igor Vaynberg-2
Igor,

I suspect you didn't realize when you got up this morning that at the end of the day you would acquire eternal fame, but there it is. To get it working with WebSphere is another matter; let's call it a challenge...

I'll consider all the things mentioned here, thanks to you all.

Regards etc...
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

Igor Vaynberg-2
that example will work with websphere, or without it.

-igor

On Sat, May 12, 2012 at 1:15 PM, hfriederichs <[hidden email]> wrote:

> Igor,
>
> I suspect you didn't realize when you got up this morning that at the end of
> the day you would acquire eternal fame, but there it is. To get it working
> with WebSphere is another matter; let's call it a challenge...
>
> I'll consider all the things mentioned here, thanks to you all.
>
> Regards etc...
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-go-tp4628562p4629413.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Wicket and JPA: <i>please</i> a simple way to go

chrisco484
In reply to this post by hfriederichs
>James, what is technology specific about JPA?

You assume that because JPA is a standard it must be the only standard.
A lot of people would take offense to that.

Have you heard of JDO? It was around long before JPA, is much more
mature, still actively enhanced and many who use it do so because they
believe it to be superior because it wasn't written with the design goal
of 'constrain it sufficiently so that a popular ORM is capable of
implementing it'. That's why JDO can work with all the RDBMSes and the
NoSQLs, GAE, Mongo, OODBs etc.,

>
>--
>View this message in context: http://apache-
>wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-
go-
>tp4628562p4629309.html
>Sent from the Users forum mailing list archive at Nabble.com.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
All standards are equal, but some (like JPA) are more equal than others, that's what you mean?

Well, a short look at the history of computing shows that technologies with obvious and proven qualities,
unanimously supported by experts, sometimes still don't survive. Other qualities are needed...

In my company, JPA is the way to go.
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

Arjun Dhar
Has your company heard of NOSQL?

JPA is a standard and I agree with most of it, but there are times when good ol iBatis is more straight forward.

Looking at the future there are non RDBMS related databases; JPA is the way to go depending on where you are going.

For a community building a framework, they have to consider the community and not just a single line of thought.

If you still feel that a single stack of technologies that provides a 360 degree coverage. Check out "PLAY" !

They have re invented the paridgm and are ready to even discard the servlet specification (or make it optional)

I don't like that aspect of Play, but looks like you may enjoy it more. Its nice for that I could critcize it.

Wicke ftw for the rest.
Good luck


Sent from BlackBerry® on Airtel

-----Original Message-----
From: hfriederichs <[hidden email]>
Date: Sun, 13 May 2012 00:23:32
To: <[hidden email]>
Reply-To: [hidden email]
Subject: RE: Wicket and JPA: <i>please</i> a simple way to go

All standards are equal, but some (like JPA) are more equal than others,
that's what you mean?

Well, a short look at the history of computing shows that technologies with
obvious and proven qualities,
unanimously supported by experts, sometimes still don't survive. Other
qualities are needed...

In my company, JPA is the way to go.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-and-JPA-i-please-i-a-simple-way-to-go-tp4628562p4630088.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Software documentation is like sex: when it is good, it is very, very good; and when it is bad, it is still better than nothing!
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

Tom Eugelink

Chiming in;

As it happens I'm currently working on a NoSQL (Cassandra) project and found a JPA implementation for Cassandra (http://code.google.com/p/kundera/). Currently JPA is the most used persistency API in Java, allowing for binding with RDBMS, XML, NoSQL. I decided not to use it, BTW, but that is because of other considerations.

To also have an quick opinion on the rest of the thread (as I understand it). Java projects have a tendency to over complicate and bloat. For example, wicket convention dictates that all labels should be put in property files. I decided not to do that. I fully understand the advantages, but for this project I'm simply not going to add an additional label component and a property file just to get "Name" on the screen. Yes, if it must be internationalized I have to rework my code, but as it stands the application probably won't have to be, and I would have added the abstraction for nothing.

Same goes for the 6 line JPA example a few posts back. If it works, great, just use it as is. Why make it more complex from the start? Refactor if you need to, not overarchitecture in advance.

I found that this pragmatic style (mind you; it's all a balance, you can't skip every corner), usually delivers results "PHP style" fast, but still has "Java quality" architecture in the overall setup. And even with all refactoring counted in, it stays well within budget; I'm currently aiming to complete my project in 75% of the "Java architecture" estimate. ;-)

Coming full circle; one of the corners you can't cut is clear separation of concern. So extracting the model (JPA) from the presentation (wicket) is very important.

My 2 euro cents. And thanks for a well though through framework, I'm warming up to it.

Tom


On 2012-05-13 09:51, [hidden email] wrote:
> Has your company heard of NOSQL?
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

hfriederichs
Tom,

I couldn't agree more, you hit the spot. Indeed it's all about balance, don't over- (nor under-)architecture things. My application will be used by maybe 5 people, and requires some very simple CRUD-implemetations on a database table with maybe 100 rows (eventually).

Here's what I will do: stick the EntityManagerFactory in the WicketApplication's subclass as Igor suggested (OK, without injection, but never use injection for injection's sake); same goes for UserTransactions for the CUD-part; make a DatabaseFacadeThing with all the necessary actions; that thing uses the WicketApplication's subclass and will be used by the Wicket components when needed. As a matter of fact, I already did make it, and it works fine. And there's only the JPA-obligatory persistence.xml, no other configs, components, and whatsoever.

Igor, thanks again for your 'dry swum code sample'. Btw: em.close() is not allowed in a container-managed entity manager (JPA 5.9.1).

For all the other suggestions (not JPA): thank you, I will look at them, just out of curiosity, because my
company is a big, fat, obese insurance company, and big, fat, obese creatures don't move a lot and don't like to move.
So it is JPA, and it will be so for ever and ever, in line with the company's daily definition of 'ever and ever'.

Regards, Hans
Reply | Threaded
Open this post in threaded view
|

Re: Wicket and JPA: <i>please</i> a simple way to go

James Carman
On Sun, May 13, 2012 at 7:19 AM, hfriederichs <[hidden email]> wrote:
> Tom,
>
> I couldn't agree more, you hit the spot. Indeed it's all about balance,
> don't over- (nor under-)architecture things. My application will be used by
> maybe 5 people, and requires some very simple CRUD-implemetations on a
> database table with maybe 100 rows (eventually).

If your application is that simple, check out Wicketopia.  It might be
able to do a lot of what you need out of the box.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

12