JPA alternatives?

731 views
Skip to first unread message

Jens

unread,
Sep 12, 2011, 9:40:56 AM9/12/11
to google-we...@googlegroups.com
In a current project I use JPA for persistence. JPA works and you can have a fast start with it but it has its pitfalls. 
For example having lazy attributes sounds nice but as soon as you have more complex logic and queries you want to fetch these properties eagerly to avoid hundreds of querys (N+1 for collections). But you can not make everything eagerly because then simple queries would fetch lots of data that is not needed at all. So you have to use JOIN FETCH but thats not defined for multiple tiers/properties in the JPA spec. So you end up using vendor specific features and its not that nice anymore to use JPA. 
Also if anything gets wrong with your queries its hard to debug the internals of JPA.

So I wonder if there are any nice alternatives to JPA? 

What do you guys use for persistence assuming you can not use AppEngine and thus Objectify? 

-- J.

Juan Pablo Gardella

unread,
Sep 12, 2011, 9:55:51 AM9/12/11
to google-we...@googlegroups.com
jdbc

2011/9/12 Jens <jens.ne...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/qvOQ0Ln1sQIJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Y2i

unread,
Sep 12, 2011, 10:03:12 AM9/12/11
to google-we...@googlegroups.com
When you use JDBC, what do you use to map between the database records and Java objects?  Also, what do you do to deal with optimistic concurrency control?  JPA automatically uses versioning.  Do you have to implement the same mechanism by hand or are there tools that help with this?


J.Ganesan

unread,
Sep 12, 2011, 10:14:20 AM9/12/11
to Google Web Toolkit
If I may suggest, please try out DataStoreGwt. It does lazy loading,
enables optimistic concurrency control from client side and does
automatic versioning of objects.

J.Ganesan
www.DataStoreGwt.com

Paul Stockley

unread,
Sep 12, 2011, 10:17:07 AM9/12/11
to google-we...@googlegroups.com
Take a look at mybatis

Thomas Broyer

unread,
Sep 12, 2011, 10:21:59 AM9/12/11
to google-we...@googlegroups.com
Never used them, but Spring's JdbcTemplate with RowMapper, and MyBatis seem appealing (for the ORM part; AFAIK, versionning has to be done by hand, but I suspect this is by design)

Y2i

unread,
Sep 12, 2011, 10:30:30 AM9/12/11
to google-we...@googlegroups.com
Does DataStoreGwt support WITH RECURSIVE sql features?  I need to efficiently traverse large graphs within the database before returning small result sets as opposed to returning large result sets and traversing them on either client or server.

Y2i

unread,
Sep 12, 2011, 10:39:38 AM9/12/11
to google-we...@googlegroups.com
Thanks Thomas, these look interesting.

Jens

unread,
Sep 12, 2011, 10:41:30 AM9/12/11
to google-we...@googlegroups.com
Haven't looked into it in detail but I think it doesn't match my needs. I can not use an embedded database on server side (clustered application server / database environment).

Juan Pablo Gardella

unread,
Sep 12, 2011, 10:29:22 AM9/12/11
to google-we...@googlegroups.com
If you wan't have problem with lazy loading, N+1; you must write a custom jpaql query to fetch the properties do you need. You have N queries, so q1 fetch X properties, q2 Y properties. This is the way I found to resolve the problems that you mark with JPA.

Always you will final must tunning your queries when have a lot of data.

Juan



2011/9/12 Juan Pablo Gardella <gardella...@gmail.com>

Jens

unread,
Sep 12, 2011, 10:55:22 AM9/12/11
to google-we...@googlegroups.com
Thanks I'll take a look at it. Hopefully I can dynamically set a DataSource to mybatis and don't have to configure them statically in xml.

-- J.

Ashton Thomas

unread,
Sep 12, 2011, 12:00:56 PM9/12/11
to Google Web Toolkit
I use Spring/JDBC/MyBatis

Like it so far

Y2i

unread,
Sep 12, 2011, 1:00:56 PM9/12/11
to google-we...@googlegroups.com
How do you debug your application?  For production I use the same version of Jetty that comes with GPE, so I can debug my application (both server and client) without changing any configuration and without going through GWT re-compilation.  Is it possible to do the same when using Spring container?

Paul Stockley

unread,
Sep 12, 2011, 10:43:14 PM9/12/11
to google-we...@googlegroups.com
That should be possible. I also use mybatis generator to generate all the maps/dto's. I created a plugin because I needed to customize the code generated to support GWT RPC plus some application specific stuff. It would be pretty easy to add optimistic locking automatically.


yur...@gmail.com

unread,
Sep 12, 2011, 11:11:36 PM9/12/11
to google-we...@googlegroups.com
Thanks Paul.  I'm currently sticking with Jetty+JPA but Spring and MyBatis is something I'd like to look into if it is possible to setup debugging without GWT re-compilation.

On Mon, Sep 12, 2011 at 7:43 PM, Paul Stockley <pstoc...@gmail.com> wrote:
That should be possible. I also use mybatis generator to generate all the maps/dto's. I created a plugin because I needed to customize the code generated to support GWT RPC plus some application specific stuff. It would be pretty easy to add optimistic locking automatically.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

maticpetek

unread,
Sep 13, 2011, 2:16:48 AM9/13/11
to google-we...@googlegroups.com
Last three year we are using iBatis and MyBatis with GWT project and we are very happy with it. Just must be a programmer that loves writing SQL.. 

Regards,
   Matic
------------------
GWT stuff twitter  - http://twitter.com/#!/gwtstuff
Reply all
Reply to author
Forward
0 new messages