Getting my S.H.I.T. together

Only 4 types of stuff

Share: Should be on social media a wiki or a blog somewhere.

Hold: Store until I know where it fits with my life goals – or because it is for personal reference at some point in the future (like receipts, guarantees, statements, insurance papers and the like). Have a filing system and file it regularly in a way that can be found.

In Progress: Artifacts from an ongoing project, should be filed with the project in a way that can’t get lost. Includes any goals that need broken down.

Tasks: Has a size and an action and needs attention, should be scheduled or stacked ready to work on. There may be time or other resources needed. Find a slot for it and if it isn’t now come back to it.

Anything else should be recycled reused or passed on to someone else.


Posted in Uncategorized

Idle thoughts on approaching life (5 S’s)

At any moment in time I should be doing one or more of 5 things that starts with S. The trick is figuring out which and doing it consistently.

Split: If a problem can’t be solved, or seems hard it is because Ii isn’t understood properly. Split it up into chunks, until there is one that looks less scary or fits the time space and energy available.

Store: Have a system simple enough to keep track of what needs to be solved, lessons learnt, and most importantly lets stuff be parked reliably at any time that it can’t be solved right now. Get the focus to where it is needed at that moment.

Solve: Always have something to hand to be working on, or thinking about. Have clear dreams and goals to refer to when stuck for what need to do next. Be willing to ‘Store’ to be able to focus on that thing.

The clearer it is and the less distraction the easier it is to find an answer. When  can’t put distractions aside it is because this is the wrong time, something else needs the focus right now – so Store,  or trying to avoid something scary because it hasn’t been split enough – so Split. Figure out which and do it.

Share: There is nothing wrong with asking for help and advise, share successes and lessons learnt, triumphs and failures. It helps understand them better and it may help someone else. Work hard at listening and understanding before trying to explain anything.

Smile: People before things and positive before grumpy. Getting frustrated with what is going on seldom helps. Enjoy the moment. Help others to smile. Find the best in other people and every situation.

Posted in Uncategorized

Happier – there is a better way to write to work with Oracle

Happier because I found a better way to call oracle stored procs through Hibernate – at least one that works with the code rather than having to work round it.

From searching around I found this link by Len (Marilen Aretius Corciovei)

Len’s solution is to use  the dummy DUAL table in Oracle to create a single return value in the form of a reference cursor.

(As an aside because I hadn’t seen it used before so other people might not know about it either – DUAL is a handy table that exists in all Oracle DBs especially for when you need some type of pseudo column to use in a FROM statement. It gets its name because it was originally created to allow an easy way to join a table to itself to get two rows for every row on the original table as part of one of the views in the Oracle Data Dictionary.)

At the top you declare a reference cursor

   ( params ...)

Then further down when you are ready to set a return value – you then create the ‘cursor’  for a single value using DUAL as your table source to return the value.

OPEN st_cursor FOR SELECT 0 AS retVal FROM DUAL;
    RETURN st_cursor;

And then in the hibernate file you need to tell it to expect a scalar value and tie up the column name (in this case retVal)

<sql-query name="CheckLastNPass" callable="true">
    	<return-scalar column="retVal" type="java.lang.Integer"/>
    	    { ? = call checklastnpass(:userId, ...) }

Which means you can write much more Hibernate like Java  than sing the connection straight

Query query = hsession.getNamedQuery("CheckLastNPass");
query.setParameter("userId", user.getId());
result = (Integer)query.uniqueResult();
Posted in Uncategorized

Oracle and Hibernate = annoyances

Spent most of the day working on what should have been an easy problem. From my current Java applaication I needed to call an Oracle Stored Procedure.

After a bit of digging I found that under Hibernate things aren’t as simple as they might seem – because you can’t just call any stored procedure – it has to be one that returns a result set.

Frome the Hibernate docs:

“For Oracle the following rules apply: A function must return a result set. The first parameter of a procedure must be an OUT that returns a result set. This is done by using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle you need to define a REF CURSOR type. See Oracle literature for further information.”

Spent rather longer than I wanted to trying to shoehorn the SP into a structure that would return a result set, but in the end went back and rewrote the Java to use the underlying session via:

CallableStatement statement = session.connection().prepareCall(…);

The code to pick up the SP definition from the hibernate XML still seems clunky, in that at present I have to retrieve it as a query extract the SQL and then create a callable statement.

For the moment I’ll ignore the fact that connection is deprecated in Hibernate until they provide me something better.

Now that I know what the problem is there are some more elegant looking routes to the same point on Stack Overflow. Another item for the polishing list once I get all the core functionality working and tested.

Another further annoyance was down to my own stupiditiy – because my Stored Proc returned a value it had been written in Oracle as a Function rather than a Procedure. Much head scratching – Oracle was telling me it didn’t exist but in SQL Plus DESCRIBE was showing it as plain as day. I could call it through TOAD from my workspace but not directly or from J2EE

A salutory lesson in reading the info in front of me – Doh!

Posted in Uncategorized

Ouch – Groundhog Day again

Brings it home that it has been two years since I last posted – need to do something about that

Posted in Uncategorized

Groundhog Day

It would seem churlish to let Groundhog Day pass without writing something.

It doesn’t feel much like the first day of spring. Personally I feel sorry for any small furry creatures emerging today looking vainly for their shadow. It brings to mind the punchline of the old Flanders & Swan routine about Stonehenge:

“…then we shall know it is Summer.
Well I’d better help you brush the snow off it then”

For some reason my reflections of winter are all about the real and metaphorical snow brushing. The fundamental decency of people who’ve rallied round when things were tough. Lots of little acts of kindness given and received. A time of reestablishing contact with lots of good people.

Friends, colleagues, neighbours and relations. The sort of people willing to have chat about rubbish, lend you a car, like your random musing and help you working out the meaning of the archaic words your daughter gets given in her spelling test.

Yesterdays corker was ‘friendlihood’ which seems somehow apt.

As our friend Nick was able to inform us after consulting his full OED:

“… friendlihood dates from at least 1390 when it was spelt frendelehyde and citations go right up to 1481, when it was frendlyhode (according to the Earl of Wessex). Nothing since then.”

It seems a shame its died out of use. We could do with a word for people being friendly to others – not as exclusive as community or neghbourhood, or as intimate as frendship. Perhaps Groundhog Day is as good a day as any to clear some snow and not be scared to be friendly  – to cast a shadow that touches others.

For as another helpful and clever person once put it so well ‘gnomon is an island’.

Posted in Uncategorized

The goddess of small things

Various important reminders – mostly from groundhogmum this week that perspective matters and small does not mean unimportant.

Her day is often built of small things – and each one of those things matter.  Moving a hairbrush, forgetting to leave a door open, not putting something away, mis-matching socks,  may seem like a small thing to me, but it doesn’t take many of these for say a whole getting kids to school routine to be completely derailed.

Her day is like a tower of kids blocks. Move just one and the planned out day can come crashing ‘hey ho rumble oh’ to the ground.

This counts as a small apology – and a commitment to do better in the future at watching the small things, and helping to maintain that precarious balance.

Posted in Uncategorized