Archive for the ‘Uncategorized’ Category, our 2.0 travel notebook to easy planning, enjoying and sharing trips, has been accepted for the second edition of the BBVA Open Talent contest, were companies in different maturity stages submit their idea and business plan for public review.

Photos displayed on one of the user's trips on

The results of the first round will be published on January 1st, 2010, and then companies passing this first (internal) filter will be displayed on the open talent website where they will be voted by the public.

We are excited about this opportunity and expect to get through this first filter.

We hope to get your votes next year!


I’ve been getting in and out of rails development for some time now… and my biggest problem is finding documentation for simple things (I guess that people already know all the stuff, but I’m still getting up to speed).

So I decided to blog about one of those simple things… in case there is still someone who has not mastered Ruby on Rails.

When several models are saved in a single transaction in Rails, the usual case is that you want to rollback the transaction if any of them fails. This is done automatically if an exception is thrown.

The example in ActiveRecord::Transactions::ClassMethods accomplishes this by using save! on the models.

However, you usually also want to display validation errors and not show the full rails trace to the user.

What the example does not show is how to accomplish this. Two options here:

  1. use save (no exclamation mark) and check the return value. If any of the saves return false, raise an ActiveRecord::RollbackException after your render or redirect.
  2. rescue from ActiveRecord::RecordInvalid and render or redirect there.

I think #2 is more elegant… but since I knew about it too late, my code uses #1.

  transaction do!!!!
rescue ActiveRecord::RecordInvalid => invalid
# do whatever you wish to warn the user, or log something

Example is from this other blog post. I wish I’ve read it sooner!

Some weeks ago I wrote down some notes for making Oracle work harder and faster with hibernate.

Those notes were collected from several places on the Internet and are supposed to help.

But they didn’t. Not for us.

Good news is that we found the problem of the bad performance and fixed it… it was all caused by foreign key integrity checks.

We got our first clue when the sysadmin detected a lot (say, 12 or so) open cursors for a simple update sentence.

We were using defaults for most of the hibernate settings and even when the update was intended to only change one column, the sql sentence set all the fields in the table for the affected row.

And Oracle fired all the checks.

I’m not sure why Oracle does not optimize this by first checking if the value has changed (if it hasn’t, then the constraints are forcedly valid), but the solution was simple… don’t update more than you need.

I have  a new friend and it is called @org.hibernate.annotations.Entity(dynamicUpdate=true). There is some (extremely brief) documentation on the hibernate annotations reference and javadocs. Of course you can also use it in the hbm files if XML is your thing.

Just in case you did not guess it, this only updates dirty properties of your objects (i.e. those that you updated after retrieving it from the database).

This has potential caveats if another transaction somehow updates your object, since the database state will be different that what you expect. To the best of my understanding this can only happen with detached objects in any reasonable isolation level… and you should reload the state from database in that case.

Well, so that was it… too many constraints on a table and updating more columns than needed. Updating only the affected columns increased performance to where we expected: better than the mysql-based prototype.

I’ve collected the following bits of information regarding the tunning of Oracle when used with Hibernate performance… it might help someone (and I need to write it down somewhere I won’t loose when moving from a desk to another!).

The following properties should be set:

# See
# NOTE: See
hibernate.jdbc.wrap_result_sets = true

# See = 0
hibernate.c3p0.max_statements = 0

# Everything else comes from
# The Oracle JDBC driver doesn't like prepared statement caching very much.
# or batching with BLOBs very much.

I have not tested the performance difference… just collected the information.

Let me know if you know more tricks!

Update: Added a warning about a memory leak in current hibernate, thanks to dfernandez.

Update 2: Statement caching for Oracle can be enabled directly on the datasource implementation. See this article.

Q4E, the maven integration plug-in that has brought WTP support and Dependency Analysis to the Eclipse&Maven users is now listed at the Eclipse Plugin Central.

You can visit EPIC, rate Q for Eclipse and leave your comments.

It should also be much easier for new users to get to know Q for Eclipse.

  • My profile

    View Abel Muño's profile on LinkedIn

    amuino on Twitter

  • My projects

    The cloud market:
    Find the virtual image you need on the cloud.
  • Top Posts

  • Archives

  • Categories