Java: Hibernate and JUnit

I’ve just been refreshing my [lack of] knowledge of Hibernate and JUnit. BTO had some poor experiences with Hibernate (through some tendered out code) and never really seemed to need JUnit.

Hibernate

I can see the attraction and time saving of Hibernate for new projects with bespoke databases. But, for legacy projects, which are hooking into existing, extensive databases with their own dependancies, I think this would cause just as many issues, slowing down initial project development – also BTO projects were costed as cheaply as possible, with little thought to funding database requirements (although the DBA was changing that in the right direction).

JUnit

Again, BTO never really felt it needed this. As a small team (of discrete/disparate developers), it seemed overkill. I can see the advantage if the developers aren’t familiar with the data being returned, so that they can get direction to populate the assertEquals and verify results.

assertEquals("10 x 2 must be 20", 20, myTesterMethod(10, 2));

Both things for me to research further…

LG and Netflix fix

Trying to watch Netflix on an LG Smart TV.

Something that’s been bugging us for ages, and there seems no 100% fix for everyone, but I found some ‘sparse’ info online and thought I should record it for myself if not for others…

Netflix works fine on a Android or Apple tablet, no buffering. As soon as we relax in the evening to watch House of Cards or anything else that is currently ‘popular’ using the TV, Netflix plays for about 10 mins and then hangs – buffer spinner reaches 25% and then craps out to exit. Broadband speed is always fine, using speedof.me in the TV web browser.

Lots of posts about factory reset, deactivate/reactivate Netflix with bizarre arrow-key permutations, broadband speed check etc. etc. All to no avail.

But, this seems to be working currently (from Tripp2Go on CNET)…

Instead of automatically selecting your network from a drop down list or a wired connection, connect manually by typing in your IP, Subnet and Gateway numbers, and a specific DNS number.
Step by Step: on your TV go to

  • Settings
  • Network
  • Network Status – Record the IP address, Subnet mask and Gateway numbers, you’ll be entering these again manually

Then go back out to

  • Network
  • Network Connections
  • Start Connection
  • Other Network List
  • Manual setup
  • Add your IP, Subnet and Gateway numbers. Then enter 4.2.2.2 as the DNS number
  • Finish

Try using Netflix – seems to have improved things for me – if this post hasn’t been deleted then it’s continuing to work.

Isn’t the net great, when it works 😉

Outlaw Triathlon 2

OK, the Outlaw is done, and yes, it did start pissing down for the last 90mins of the bike (Met Office got it spot on). Splits below. Nutrition worked fine. Took too long in transitions (might have gone sub-11 if I’d done my 2011 transitions!), but wanted to be comfortable on bike and run.

  Swim T1 Bike T2 Run Total
2011 0:59:01 0:04:28 6:08:05 0:04:53 4:32:19 11:47:05
2015 0:58:24 0:07:50 5:49:52 0:08:43 4:07:03 11:11:53

Outlaw Splits

Happy with results – was aiming for A) sub-11 hours, B) beat 11:18 (Challenge Roth 2010 time) or C) beat previous Outlaw time (11:47, 2011) – smashed C and managed B. Next time… A.

Really felt for the slower competitors (hark at me!) as they were in the rain for lots of their bike splits and all of the run, with the rain increasing as the afternoon turned into evening and beyond. This meant the tow-path along the Trent became one big puddle in places – not fun for tired body and legs! Kudos to those guys…

Outlaw Triathlon

Outlaw Triathlon this coming Sunday, heading to Nottingham tomorrow. Think I’m ready, too late if not. Biggest concern is the weather, as I’m not keen on cycling in the rain (although had plenty of practice recently). Met Office forecast for Nottingham Race Course below:

Forecast for Notts Race Course for Sun 26th July 2015

Forecast for Notts Race Course for Sun 26th July 2015


Last time I did 11hrs 47min 05secs (splits below), so hoping to beat that whatever the weather throws at me. I’m hoping that coach Jason B (http://www.performancecoaching.me/) continues to have a positive impact!
Swim:0:59:01
Bike:6:08:05
Run: 4:32:19
Using same bike as last time, but deciding to do a complete change in T1 and T2 into most comfortable bike and run kit, as hopefully being comfortable will help me flow better? Will post report next week…

Android: Remembering users previous tab selection

This is something I built into v2.0 of Pace Calculator, since often users would be only runners, cyclists or swimmers, and once they select a particular tab, they want the app to start-up in that tab every time. It uses the basic SharedPreferences object, all within the main activity that controls the ActionBarActivity tabs.

First, in MainActivity, set up the following variables

Integer tabPref;
SharedPreferences prefs;

In the onCreate method instantiate the variables, defaulting to 0 if the app has never been used before

prefs = getPreferences(Context.MODE_PRIVATE);
tabPref = prefs.getInt("tabPref", 0);

You need to make sure that when each tab is selected, the preference is also set, and editor.apply() called

mViewPager
		.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
			@Override
			public void onPageSelected(int position) {
				actionBar.setSelectedNavigationItem(position);
				SharedPreferences.Editor editor = prefs.edit().putInt(
						"tabPref", position);
		 	    editor.apply();
		}
	});

Finally, at the end of OnCreate, you need to make sure that the tab determined in the preferences is selected with

mViewPager.setCurrentItem(tabPref, false);

That’s it!

Plantar fasciitis…

…is a right pain in the arse. Probably caused by running hard (Edinburgh 1/2 Marathon with Sandy Cleland) on shoes that were past it, then not resting up. Last week was a big running week for me, about 60km, and I’m now hobbling about. Remedies include massaging with Tiger Balm (homeopathy I guess, but it smells great) and rolling a frozen Sigg bottle on the floor with knackered foot. Hope it’s OK by tomorrow, hill reps on the bike. Wikipedia Plantar fasciitis >>>

Pace Calculator updated

Today I updated the first Android App I ever built (released December 2010!) Pace Calculator has been updated to include speed calculations for cyclists and pace per 100m for swimmers. Both run and bike tabs include metric (km) or imperial (mile) options. It’s been a useful exercise using action-bars, styles and swipe tabs, all new standards since I built the original app. APPS >>>