9 Steps for dynamic filtering and paging of a JPA Entity

Folks, this isn’t by any means a show of brilliant software engineering, but I didn’t find anything exactly like it in the blogosphere. I have a really basic scenario to solve.  I have a JQuery grid in a jsp with filterable columns which are mapped via Stripes MVC and Spring to a JPA Entity.

The ajax call from JQuery gives me name/value pairs to filter.  It also gives me the row number to begin the page with and how many rows to retrieve.  From this, I can filter the entity list without hard-coding the Predicates or without building a JPQL string.  The following method goes in Spring Repository or where ever you are keeping business logic for entities.

Step 1:  #44 – Get a CriteriaBuilder from the entity manager

Step 2: #47 – Get a Root of type <YourEntity>

Step 3: #49 – declare a collection of Predicates

Step 4: #60 – For each name/value pair, instantiate a new Like Predicate and add it to the list.  Use The % sign around the data for wildcard searching

Step 5: #62 – Add all predicates to the query’s where clause

Step 6: #63 – create TypedQuery from the CriteriaQuery

Step 7: #70 – set the first row for your page

Step 8: #71 – set your max your for your page

Step 9: #72 – retrieve the data

FilterPaging

Advertisements

Java 7 (2011) and Java 8 (2012)- “Let’s get the platform moving again.”

Lest there be any doubt of Oracle’s commitment to the Java SE core, Mark Reinholt shared the previously TOP-SECRET projections for future Java SE releases. He shared his wishlist of core language enhancements which I’m quite sure some other blogger (most likely a JE…Java Expert) will cover ad nauseum (thank you, by the way, whomever you are, that will be awesome).  I look forward to be as confused about Lambda’s as I was about Generics.

The reason I am excited, is that I don’t want to believe that Java is becoming a legacy platform…like my first two platforms did (COBOL and Powerbuilder).   I’m sensing a willingness from Oracle to take some bold moves to bring Java into the 21st century of coding innovation.

Bravo!

End of the road

I’ve completed this excellent tutorial. JDeveloper 11g and ADF Faces are ASTOUNDING! I thoroughly enjoyed working with this product. It’s quite easy to imagine using this tool for the work we do here. Unfortunately, we are at an empass. Oracle claims that ADF Faces’ manipulation of dom/javascript is too complex for IE6 and therefore has not even attempted to support it. My employer (large Federal Goverment agency), has not yet approved IE7 for use by its employees.

All I can say is PHOOEY!!!!!!!!!

Using Layout Components to Design the Page: Step #11 Issue

Ok, things are going pretty well so far. I’m really impressed with the style template stuff. Not being a style expert myself, I’m hoping to find that there is a budding library of style templates to choose from. If not, I’ll just use this nice little template (simple.jspx), and replace the Oracle logo with our application logo.

Minor issue: In step 11 of the “Using Layout Components to Design the Page” section 11.

Right click the ‘second‘ panel of the page and select Insert inside Panel Tabbed –> Show Detail Item.

This tab is automatically inserted when I drag Panel Tabbed from the Component Palette. So this step is confusing. I don’t know if it’s because I’m using Preview 3 and the tutorial was written for preview 1 or what. The workaround is simple: skip it!

Oracle JDeveloper 11g Technical Preview 3

Why would I, a hard-core Netbeans junky, download Oracle’s 750 MB JDeveloper 11g Technical Preview? (3% on the download) I who have devoted myself to Netbeans since before 3.6!!!?

The answer is simple:

ADF Faces

I attended the 2007 Oracle OpenWorld conference in San Francisco and attended a hands-on tutorial session for ADF Faces in JDeveloper 11g. When the session was over, I felt like I had accomplished as much as I could have accomplished in Netbeans Matisse/GUI Builder! And I live and breathe Swing on a daily basis! AND THE WIDGETS! I have never seen such an array of reusable drag n drop components! AND ALL FOR FREE!!!

So, I have a decision to make for my team. We are embarking on a large project to convert a large-scale Powerbuilder/Oracle system to a web application. My first inclination was to go with Java Swing on the front with some kind of web framework or web services on the middle. We’d use Java Web Start to deploy it and everyone would be happy…that is, except for the dinosaurs who are still concerned about java clients and JRE versions. Ok, fine! You want a browser?! You got it! Enter JSF. Netbeans and JSF has not impressed me, yet. Will we go with ADF? Maybe JBoss’s RichFaces? Dunno…

(33% on the download)

So, I’m waiting for this massive download full of juicy Oracle goodness, wondering if I can recreate the magic that I experienced in San Francisco last November. Was it really THAT good? Or was I still buzzing from the night before?

David on the far right having fun at Oracle OpenWorld 2007

Me (on the far right) having fun with the Estonians at Oracle OpenWorld 2007!

(36%)

I’ll let you know!

(38%)