In Hibernate 4, StatelessSession#connection is a deprecated method, but there's no suggested alternative. StatelessSession does not have a "doWork" method like Session.

The best way I've found to deal with the deprecation warnings is to get a connection from the connection provider directly, create StatelessSession with that connection explicitly, and then carry around references to both the session and connection.

Old (deprecated) approach:

StatelessSession session = sessionFactory.openStatelessSession();
// Example of using the underlying connection
session.connection().setAutoCommit(true);
// Now do work with session

New approach:

Connection connection = sessionFactory.getSessionFactoryOptions().
getServiceRegistry().getService(ConnectionProvider.class).getConnection();
StatelessSession session = sessionFactory.openStatelessSession(connection);
// Example of using the underlying connection
connection.setAutoCommit(true);
// Now do work with session

Here are my "top 10" jQuery questions that can be answered in 1-2 sentences over the phone--no whiteboard required. These are not "gotcha" or "puzzler" questions. They cover the basics, and any competent jQuery developer should know the answers.

1. What's the purpose of jQuery?

jQuery is a JavaScript library providing convenient abstractions and utilities to make DOM manipulation and event management consistent across browser vendors and versions.

2. How do CSS selectors related to jQuery?

CSS selectors are a common way of referencing DOM elements, i.e. via the $(selector) syntax. A very common way of constructing a jQuery object is via a selector.

3. How would you define your own custom jQuery method (to extend jQuery)?

You'd write a statement like "jQuery.fn.pluginName = function() { ... }". You could also use $.fn.extend(...);

4. How can you tell how many elements a jQuery selector has matched?

Use the "length" property of the jQuery object.

5. What's a Promise, and what's an example usage in the jQuery API?

A Promise is an interface (contract) providing for callbacks depending on success or failure of some asynchronous operation. One such usage is $.ajax.

6. How is $.each() used, and what does the "this" keyword reference when the callback is executed?

The $.each() jQuery method iterates over all DOM elements of the invoked jQuery object by calling the provided callback once per element, in order. The "this" keyword references each element in turn.

7. How can you bind to events on DOM elements that are not yet created? (example: a "delete" button on rows that may be added to a table dynamically)

You can use the longer form of the $.on() method, binding to an ancestor that does exist, and specify a selector argument that matches the elements that will be created later. (This is a performant replacement over the former $.live() method.)

8. What's the major difference between jQuery 1 and jQuery 2?

jQuery 2 does not support legacy browsers (IE6-8), making it lighter-weight. The jQuery team is otherwise attempting to main API parity between versions 1 and 2. More info here.

9. What's the difference between $.attr(), $.data(), and $.prop() methods?

The $.attr() method gets/sets HTML attributes directly on the DOM node, so the keys and values are strings. The $.data() method sets arbitrary data in a jQuery-managed dictionary associated with the DOM element(s), so the keys are strings but the values can be any type. The $.prop() attribute gets/sets properties of the DOM node, like whether it's currently checked.

10. How would you use jQuery to determine whether a checkbox is checked?

Use $('checkbox-selector').prop('checked') or $('checkbox-selector').is(':checked')

Here are my "top 10" JavaScript (ECMAScript) questions that can be answered in 1-2 sentences over the phone--no whiteboard required. These are not "gotcha" or "puzzler" questions. They cover the basics, and any competent JavaScript developer should know the answers.

1. What data types does JavaScript support?

Based on unique return values of the typeof operator, there are 7: undefined, object (which includes arrays), boolean, number, string, function, and object. (ECMAScript 6 supports an additional type, symbol.)

2. What's the difference between "==" and "==="?

The double-equals operator (==) tests for equity after coercing the operands to matching types, whereas the triple-equals operator (===) tests for both type and equailty without doing any type conversion. Therefore an expression like 1=='1' evaluates to true, whereas 1==='1' evaluates to false.

3. What's "undefined"?

Undefined is a special value used with unitialized variables, missing function arguments, and functions that do not return a value explicitly. It's distinct from null, which is assigned explicitly. (It's also a global property set to this value.)

4. What does the "use strict" statement do?

5. What does the "this" keyword refer to?

It's tricky, but the "this" keyword basically provides object context: global context (window object) outside of a function, object reference inside a function, or DOM reference in an event handler. You can use call and apply to set a function's context explicitly. More details here.

6. What's the difference between "call" and "apply"?

While both are methods of the Function prototype used to call a function, taking a context as the first argument, call also takes a comma-separated list of arguments to pass to the target function, whereas apply takes a single array of packed arguments to pass to the target function.

7. What are the possible scopes for declaring variables?

A variable can be scoped globally or at a function level. While a variable can be declared with a block ({ ... }) it's still scoped to the outer function.

8. What's a closure, and how can you create one?

A closure is a function that references variables from outside its definition, and an easy way to create one is to define an anonymous function within a function, and refers to variables from the outer function's declared variables or arguments.

9. What's "prototype" used for?

Each object has a "prototype" property, defining an object hierarchy through its "prototype chain" for inheritance. When referencing a property of an object, if the property does not exist, the JavaScript interpreter looks up the prototype hierarchy for a match.

10. How would you execute a JavaScript statement asynchronously?

While JavaScript execution is single-threaded, you can defer a particular statement using setTimeout with a timeout argument of 0 ms. (In newer web browsers, if the statement isn't accessing the DOM you could also use web workers.)

If you need a selector that uniquely identifies a DOM element and is robust to some changes to the page structure over time, your best bet is to keep the selector as concise as possible. I've seen jQuery plugins that attempt to build a selector by navigating the entire DOM hierarchy, and adding some unique bits for each ancestor encountered along the way. This can be overkill -- especially if any element has an ID along the way. Since ID is unique, there's no need to keep going.

Here's a custom jQuery function called "getSelector" to provide a concise selector for any element on the page.

Recently I was trying to convert a Highcharts SVG-based chart into a static image that I could copy and paste into a document. Highcharts provides a mechanism to do this on with a server-side roundtrip, but for modern browsers (and, no, not any flavor of IE), it's possible to do this completely on the client side -- and even inline replace the SVG element with a pixel-perfect matching <img> element.

If you'd like the destination tag to have Base64-encoded data rather than a temporary blob URL and/or want to manipulate the image (e.g. set the background color), add an intermediate step of rendering the image on a canvas first. Unfortunately this step doesn't work in IE, whose security model marks the canvas as "write only" once SVG data is written to it, regardless of where it came from.

Before I settled on an "infinite scrolling" solution to a pagination problem, I was using Twitter Bootstrap's "pagination" CSS class and a bunch of page links, including the usual next/previous. I wrote the script to meet these requirements:

First and previous page links must always be available

Next and last page links must always be available

The current page must be highlighted and non-clickable

Up to X additional links must be visible for interstitial pages before and after the current page.

Each link must consume the same amount of horizontal space so next/previous/first/last links don't change position. This prevents accidental clicks if the user were to click multiple times and the elements jumped around.

I've been looking for a way to build a large-screen kiosk capable of running multiple apps and websites, but still run in a 'locked down" mode so kiosk users can't escape the sandbox and do something malicious. The iPad now has a kiosk mode, but it limits you to a single app. Android has kiosk apps, like SureLock, that do support multiple apps and websites, however there's no Android device quite large enough for what I'm trying to do (the 24" ViewSonic is the largest I've seen). That leaves a custom solution: probably built on top of Windows so Windows apps + Android apps (in an emulator like BlueStacks).

Here's a summary of the options I've evaluated to date to get a ~40" multi-app exhibit/kiosk experience: