Live data from Hacker News

Build RESTful web services with Java technology

ibm.com

21–30 of 30 posts

Re: Build RESTful web services with Java technology

#21
post #19

Earlier quoted context omitted.

JPA does have some gotchas and the learning curve is a little bit steep (not too steep, but just a wee bit). You do need to know how JPA works internally a little bit (e.g.: EntityManager actually cache your objects unless you tell it specifically to "flush").

My biggest problems with JPA: 1) CriteriaBuilder API is the worst API I've ever seen. I've never seen an API that turns a simple task into more lines of code than this monstrosity. I can't imagine many people use this thing, instead they use JPQL losing type safety in the process. 2) JPQL is still wildly verbose and very difficult to intertwine with native SQL. As an example try to generate something like "SELECT * F…

Have you tried Querydsl? Works good with Spring Data JPA at least. http://www.petrikainulainen.net/programming/spring-framework...

Re: Build RESTful web services with Java technology

#22
post #19

Earlier quoted context omitted.

JPA does have some gotchas and the learning curve is a little bit steep (not too steep, but just a wee bit). You do need to know how JPA works internally a little bit (e.g.: EntityManager actually cache your objects unless you tell it specifically to "flush").

My biggest problems with JPA: 1) CriteriaBuilder API is the worst API I've ever seen. I've never seen an API that turns a simple task into more lines of code than this monstrosity. I can't imagine many people use this thing, instead they use JPQL losing type safety in the process. 2) JPQL is still wildly verbose and very difficult to intertwine with native SQL. As an example try to generate something like "SELECT * F…

>CriteriaBuilder API is the worst API I've ever seen.

It's not great, but it's type safe. Having said that, I do C# so I just use Linq but before Linq I was using CriteriaBuilder. It wasn't so bad because I was only using it in specific repository objects, not all over the code.

Re: Build RESTful web services with Java technology

#25
post #2

Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though). One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my…

Wise comment about JPA, it's full of gotchas and just when you need something fancy that you think will justify all the troubles of setting it up, you find that is impossible either because of a bug in your provider or because the spec just didn't cover that case. On the rest side the real beauty of it over SOAP is that you don't really need a framework, I use Spring MVC but I set it up to the barebones because much of it is not needed.

Re: Build RESTful web services with Java technology

#27
post #4

Earlier quoted context omitted.

Thanks a lot for the pointers. I have been looking for a good java framework to learn. I will be more than happy to settle with this 90% you quoted. They look simple enough to understand in a couple of days without wrestling with tons of XML config files.

If you're looking to write a backend service using Java, I would take a serious look at dropwizard http://dropwizard.codahale.com/ The get started page is not that long, and you should be able to kill it in a few hours. At the minimum you get http requests routed to methods and restful json parsed for you automatically. If you want, you can add optional configuration, metrics, healthcheck, logging, db access, views e…

I've been using dropwizard for a new project and I'm pretty happy with it so far. It's a great head start and a simple architecture.

Re: Build RESTful web services with Java technology

#28
post #2

Building REST services with JAX-RS is truly pretty smooth and quick (I've been using Jersey not Wink though). One thing I don't ever recommend is using JPA based libraries (Hibernate, EclipseLink, whatever). Run screaming away from that spec as fast as you possibly can. There are much better options for ORMs in Java that don't have the session management headache and endless string of gotchas that is JPA. Ebean is my…

Usually reserved for legacy databases with lots of custom queries and jdbc code, mybatis (previously ibatis) is a pretty flexible solution. Hooks into Spring pretty well too.

http://www.mybatis.org/core/

Re: Build RESTful web services with Java technology

#29
post #16

Earlier quoted context omitted.

I prefer plain files instead of annotations. Just wish the non-readability of XML would go away with less bloated format (which other frameworks did with JSON).

Fair enough argument :) Though, now that I've gotten into the annotation way I like it the most.

I mix them usually. Layer-oriented stuff like @Transactional and @RequestMapping incl. Path/HTTP Method etc. in the code, central declaration stuff like e.g. Marshallers, HandlerAdapters, global ExceptionHandlers in XML...

:)

Re: Build RESTful web services with Java technology

#30
post #7

Earlier quoted context omitted.

Ah, I'm not the only one who thinks ORMs suck! That's why I love the latest development in the Scala community towards a non-ORM solution for persistence: Slick ( http://slick.typesafe.com ) and Play! Anorm ( http://www.playframework.org/documentation/2.0/ScalaAnorm )

I don't hate ORMs, but I hate when they are too intrusive. What I like about Ebean is that it was designed to only handle the simple stuff "ORMish" and provide a very smooth and easy breakdown to raw SQL so you get the best of both worlds. I also love "autotune", it tracks your call stack for queries and after it has enough statistics it'll start only fetching the fields that you actually ended up using. So if you ha…

I see. Ebean looks interesting! I'm kinda stigmatized because of Hibernate and therefore avoid any persistence library that calls itself an ORM :)
Post reply on HN