Wednesday, September 11, 2013

Hibernate scalar types deprecated

In earlier versions of Hibernate, you might have had code that looks like this

session.createSQLQuery("select * from person").addScalar("id", Hibernate.INTEGER)


The fully qualified name of that type is org.hibernate.Hibernate.INTEGER.
That entire type class (org.hibernate.Hibernate) was replaced by org.hibernate.type.StandardBasicTypes.


Thus, your new code should look like this:

session.createSQLQuery("select * from person").addScalar("id", StandardBasicTypes.INTEGER)


Note that the documentation on the JBoss website is outdated depending on which version you are looking at.

For example, documentation for Hibernate 3.3 still says this:
sess.createSQLQuery("SELECT * FROM CATS")
 .addScalar("ID", Hibernate.LONG)

Thursday, January 31, 2013

[CODE] Setting the transaction timeout in EJB 3 using annotations

It's annoyingly hard to find this info online, so here it is:

The timeout annotation is provider specific (weblogic, jboss, etc.).  For example, for Weblogic it is @TransactionTimeoutSeconds(value=40)


http://docs.oracle.com/cd/E16764_01/web.1111/e13720/annotations.htm#i1438354

It's a class annotation, and should be put on the same class you have your javax.ejb.Stateless (or Stateful) EJB.

e.g.

@Stateless(mappedName="myClass")
@TransactionTimeoutSeconds(value=50)
public class MyClass implements ...

Wednesday, August 31, 2011

[CODE] Finding database constraints in Oracle

Quick and easy way to find a constraint by name in Oracle.

By the way, if the constraint name comes out as MYSCHEMA.ConstraintName, leave off the schema part when you search for the constraint.

Friday, July 29, 2011

[RANDOM] Giving NBA referees their due

One of my biggest peeves with sports fans are their complete disregard for the difficulty of being a ref or an umpire in professional sports. They have an extremely hard task that demands perfection and they very nearly get it all the time. Playoff refs are actually chosen based on their number of mistakes during the regular season (for NBA and the NFL, at least. I assume it's the same for other sports). There is a relentless review of their work after every game and each referee is criticized and trained throughout their careers to become better.

They could get 99% of their calls right, and yet they still get lambasted when they make one wrong call.

A great passage I read from Peter Post summed up my feeling towards the matter well. Paraphrased, it was something along the lines of, "Never blame the ref for one bad call that costs you the game. Chances are your team made at least one mistake along the way, so you should instead lament all your missed opportunities that would have won it for you."

At any rate, here's a fantastic article from ESPN where the writer spends a day hanging out with NBA referees at work and has some very interesting and insightful comments.

[RANDOM] Monty Hall Problem

The "Monty Hall" problem is a famous probability question that stumped me when I heard it. Even though I guessed it was a trick question, I couldn't mathematically prove why either solution was correct, which I would consider as getting the question false (I don't think blind guesses should count for anything).

If you've never heard it, it's a fun one to puzzle through. I'll put the problem description below and a link to the Wikipedia page with the solution afterwards.

"Suppose you're on a game show and you're given the choice of three doors [and will win what is behind the chosen door]. Behind one door is a car; behind the others, goats [unwanted booby prizes]. The car and the goats were placed randomly behind the doors before the show. The rules of the game show are as follows: After you have chosen a door, the door remains closed for the time being. The game show host, Monty Hall, who knows what is behind the doors, now has to open one of the two remaining doors, and the door he opens must have a goat behind it. If both remaining doors have goats behind them, he chooses one [uniformly] at random. After Monty Hall opens a door with a goat, he will ask you to decide whether you want to stay with your first choice or to switch to the last remaining door. Imagine that you chose Door 1 and the host opens Door 3, which has a goat. He then asks you "Do you want to switch to Door Number 2?" Is it to your advantage to change your choice?"
-Krauss and Wang 2003:10

http://en.wikipedia.org/wiki/Monty_Hall_problem#Extended_problem_description

[RANDOM] Google data online

Sorry about the six month absence of new posts onto this blog. It's been more a lack of energy than a lack of motivation or ideas that's been preventing anything from going up. I actually have a ton of content that I've been wanting to post about for a while now, and hopefully I'll make some progress on that in the next few weeks.

For starters, I never cease to be amazed at the great work Google does at putting up information online. I stumbled on this a while ago and was impressed at how easily they put data into the public arena and how accessible it is. I'm the type of person who likes to debate and talk about varied subjects, and I think that backing up your arguments with proof is important. That previous link is to GDP of countries in the world, but you can access all sorts of nifty statistics here. It's worth exploring if you're into demographic data like this and I'm sure it'll be useful in the future in more serious research as well when awareness grows.

Just to scare you, check out this chart on the rise of chlamydia in the US.

Tuesday, January 4, 2011

[FOOTBALL] Ed Hochuli and other referee-related awesomeness

Besides my obvious interest in software development (and XKCD, which is where I got my blog title from), I also love football.

While I could write a novel on all the reasons I love football, I'm sure people would love to just see some interesting random football tidbits instead.

For starters, Ed Hochuli is basically my hero. He is one of the only two refs that I know the name of. When they release the ref schedules for the games I actually get excited when I see him listed for a Pats game.

Why is he my hero? Oh, so many reasons...

  • He's really jacked.
  • The guy is in better shape than I am and he's over sixty.
  • He's one of the best active refs out there, having been selected to ref for two Super Bowl and many playoff games.
  • His day job is a lawyer.
  • He represents the refs in their union.
  • He has the best explanations of any ref I have ever heard, gaining points for clarity, completeness, and unintentional humor.
  • The players think he's hilarious.
  • Did I mention he's really, really jacked?
  • and the list goes on...
But that's enough hero worship. Just check out some of his awesomeness.

"There was no foul on the play... the defender was just overpowered." Check out Belichick's facial expression.

God, this guy is thorough with explanations.

NFL special "I want to be Ed Hochuli":
"He once needed 91 words to explain an illegal motion infraction."
Jared Allen: "Ed's arms are looking better than all of ours!"

Butt slap at 0:47-

Tony Romo wishes he was Hochuli:

Ed Hochuli gives a penalty call in Spanish while refereeing a game in Mexico:

And just so I'm not too focused on Hochuli, here's a great ref call that I won't spoil by typing it out first.