Pages

Monday, July 02, 2012

Typed Query RESTful Service Example

This example demonstrates how to use a TypedQuery<T> in a JAX-RS (Jersey) application. The service implementation utilizes a @Stateless session bean to handle the transactions, and scale the application. The application was developed using NetBeans, and GlassFish 3.1.2.

The primary reason for using a TypedQuery<T> is to maintain type safety, and give the compiler a chance to determine if there are any problems with the code. This combined with a CriteriaQuery<T> provide additional safety and functionality that was not available in Java EE5 and JPA 1.0.

There is additional functionality in the application. There is an index page which leads to the examples.

The project can be downloaded here: TypedQueryExample.zip

Interesting Bits...


5 comments:

  1. great! i was searching how to make pretty links. do you have more resources for this. thanks

    ReplyDelete
  2. great! i was wonder how to do exactly this. will it play with jsf?

    ReplyDelete
  3. I am not sure I understand your question. The code is formatted using SyntaxHighligher from Alex Gorbatchev http://alexgorbatchev.com/SyntaxHighlighter/

    ReplyDelete
  4. It will work with JSF using <f:metadata/> combined with <f:viewParam/> elements to manage the GET functionality.

    ReplyDelete
  5. Combining rest and jsf is very powerful. I use jsf purely as a templating engine and delegate ajax to jquery/jaxrs. Very fast, very clean code.

    ReplyDelete