skip to navigation
skip to content

Planet Jython

Last update: November 24, 2014 09:37 PM

November 23, 2014


Josh Juneau

NetBeans Tip: Working with JPQL

Have you heard of the NetBeans JPQL tool?  This is an often overlooked feature of NetBeans IDE that can save developers a lot of time.

If you are a Java EE developer, then you've likely encountered moments when you would like to see the results of a Java Persistence Query Language (JPQL) query before you've written your session bean method.  Being that I come from a database administrator background, I am oftentimes finding myself at the SQL command-line (or NetBeans SQL Editor) writing queries, and then translating the SQL into JPQL.  NetBeans IDE contains a JPQL tool (since NetBeans 7.3), which makes it easy to write JPQL queries and retrieve results immediately.  Let's see how:

The JPQL tool can be invoked within the context of a NetBeans project.  The project must have a valid Persistence Context, meaning that it is wired up for database access.  Once this is in-place, simply right click on the persistence.xml file, and click on the "Run JPQL Query" to open the tool.





















The tool provides a nice editor that provides a top pane for entering a query, and a bottom pane for showing the SQL or the results of the query execution.  If you have more than one Persistence Context within your persistence.xml, then you will have the option to select which context you would like to utilize for the query.












To execute the JPQL, simply click on the button next to the Persistence Context pull-down, or right click in the query editor and choose "Run JPQL".

The tool comes in super handy when you are executing queries that involve more than one entity.













Another handy reference for the tool, Geertjan's blog post:
https://blogs.oracle.com/geertjan/entry/test_jpql_with_netbeans_ide

Note:  Be sure to "Build" your project successfully before trying to use the JPQL tool.  If you do not have a successful build, you will likely encounter an error stating that the abstract schema type cannot be found:

November 23, 2014 09:02 AM

November 21, 2014


James Abley

VelocityConf EU 2014 – Day 1

TLDR; Velocity is a great conference for web and operations people, and why didn't you go already?

Is TLS Fast Yet?

This was a talk by Ilya Grigorik full of practical, actionable things that you can do to serve your site over TLS, and make it fast.

My notes on Ilya's talk.

Monitoring: The Math Behind Bad Behavior

Theo Schlossnagle gave an excellent talk (which didn't involve much maths) about the problems that Circonus see with handling massive amounts of data, and reliably detecting anomalies. I found this quite hard to take notes, and it wasn't as practical in my context as the first talk, but still really interesting.

My notes on Theo's talk.

Design Reviews for Operations

Mandi Walls of Chef showed us how operations should be involved early on. She did a great job of emphasising the importance of having the right people having the right conversations at the right time.

I felt a little over-qualified for this talk, given that I've worked with Gareth Rushgrove for most of the last 3 years, and helped write some of the user stories for operations that GDS published on GOV.UK. Not everyone has had that privilege though!

My notes on Mandi's talk.

What Ops Can Learn From Design

Rob Treat of Omniti brought together The Design of Everyday Things and The Art of UNIX Programming to show how designing with empathy to create intuitive interfaces can be easy to overlook, but can have a massive impact on people using your stuff.

My notes on Rob's talk.

Statistical Learning-based Automatic Anomaly Detection @Twitter

Anomaly Detection seemed to be quite popular this year (see Theo's talk and Baron's proposed talk). Here, Arun Kejariwal talked about the state of the art, how it didn't quite fit for Twitter's usage, and what they did about it. The tools and code should be open-sourced in a few weeks, so people can plug it into their own problems.

My notes on Arun's talk.

Your Place or Mine: A Discussion of Where to Host Your Site

This was an emergency panel convened since the originally planned speaker had something come up. Nice end to the day, talking about cloud and similar issues. Michael did a nice job of not answering someone that seemed to be either aggrieved, or trolling quite hard. He's a proper civil servant.

November 21, 2014 08:58 PM

November 05, 2014


Josh Juneau

Building and Testing JSF.next

The JSF 2.3 Expert Group is hard at work determining which features will be part of the upcoming release.  The JSF Team been working hard improving CDI alignment, among other things.  There are already a number of new features in the JSF 2.3 codebase that you can begin to test.  I will attempt to keep this post updated with the latest features that have been added.  For the most up-to-date reference, please see Manfred's blog.  To reference the information from Manfred's blog, take a look here.

JSF 2.3 Features

The features that have been added as of 11/4/2014 are as follows:

- Inject @ViewMap

@ViewMap
@Inject
Map viewMap;

- #1333 - Support @Inject for UIViewRoot
@Inject
UIViewRoot viewRoot;

- #1332 - Let CDI handle #{view}
- #1331 - Let CDI handle #{application}
- #1254 - contracts attribute too restrictive.
- #1328 - Let CDI handle #{session} EL resolving
- #1325 - Let CDI handle #{applicationScope}
- #1311 - Let CDI handle #{facesContext} EL resolving
- #1323 - Support @Inject for the applicationMap
@ApplicationMap
@Inject
Map applicationMap;

- #1322 - Simplify #{externalContext} to use ExternalContextProducer
- #1309 - Support @Inject for ExternalContext
@Inject ExternalContext externalContext;

- #527 - Support @Inject for FacesContext
 @Inject FacesContext facesContext;

Please reference the JavaServer Faces JIRA for more information.

Taking JSF 2.3 for a Test Spin

If you would like to start testing out these new features today, the easiest way to get started is to simply download the 2.3 SNAPSHOT and then replace the javax.faces.jar file within your GlassFish/glassfish/modules directory with the snapshot.

You will need to be sure to reference version 2.3 in your faces-config.xml. as follows:

<faces-config  version="2.3"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd">

</faces-config>

If you are adventurous and you would like to build JSF from source, that is also fairly simple.  To do so, follow these steps:

1)  Check out the trunk using SVN:
svn checkout --username yourname --password x https://svn.java.net/svn/mojarra~svn/trunk
2)  Copy the build.properties.glassfish file to build.properties
3)  Edit the build.properties file and set jsf.build.home to your source home.
4)  From the source home, run ant clean main

The jsf-api.jar will be in SOURCE_HOME/jsf-api/build/lib and jsf-impl.jar will be in SOURCE_HOME/jsf-ri/build/lib

For more information on building the sources (and even contributing), please see the following reference:
https://wikis.oracle.com/display/GlassFish/JavaServerFacesRI#JavaServerFacesRI-HowcanIcontribute%3F

November 05, 2014 08:21 PM