Posts

Type Safe Criteria API for Hibernate

I've started a library for a type-safe criteria API for Hibernate called SafeCriteria. I've always been bothered by the fact that the Criteria API always requires one to use text strings for the property names. Strings aren't checked by the compiler, so they can hide errors in your code until runtime, which is way too late. In short, SafeCriteria allows you to query via "showing" the API what properties you want via the getter methods for that property. The great thing is that the getter methods are checked by the compiler so you at least get some help there, and if you need to refactor a property getter the refactoring tools of your IDE will help you catch these references as well. I also have some ideas for handling class aliases better than with remembering strings in your property names, but that is coming after the basics are working properly. Maybe I'm just scratching my own itch here, but someone else might have the same itch. If anything, I'll a...

Thinning the Vegetables

Image
Today, I had to thin out the cabbage as all the sprouts would never have enough room in the bed to grow. This process was quite difficult for me because I had to kill some perfectly healthy sprouts. It was for the benefit of the remaining cabbages, but it was still hard for me to choose. The bed looks a lot more sparse now. I hope the remaining plants get bigger soon. On the plus side, the small thinnings from the cabbage are tasty enough for even my youngest to eat with some ranch dressing. I think I'll take a salad with them for lunch at work tommorow. Today's conditions: Partly Cloudy, High of 84°, with late night thunderstorms.

Dell Streak Wouldn't Connect to Cell Network

I had a bit of a scare this morning with my phone. I have a Dell Streak running Android 2.2 and for some reason this morning when I powered it up, it wouldn't connect to the cellular network. I had grey bars with an X next to them in the status bar, and I couldn't make calls, or get on the internet except for wifi. Going into Settings -> Wireless & networks , I noticed that "Airplane mode" was checked. I figured maybe I set that at some point and forgot, so I tried to uncheck it. The button would stay greyed out for a while, and if I left the settings page and came back, it was still checked. I tried pulling the battery, SIM card, SD card, and then putting the battery back into to restart. Still no cell connection. I pulled the battery out again, put everything back in, but still there was no cell connection. Finally, I searched some forums and found that people have this problem for various reasons. Suggestions ranged from the procedure I tried to a ful...

Garden at 9 days

Image
In an attempt to keep myself focused on my garden this year, I'm going to try and keep a log of what I'm doing and the results I'm seeing. Hopefully this will also help guilt me into making sure that I keep checking up on the garden and taking care of it. Well, we decided to move our raised beds up to a location that gets better sunlight as our vegetables last year just didn't get enough. All in all, it took me about 3 weekends to get the old bed moved up to the hill, leveled, and then build a second bed for planting. We ran out of dirt from cutting into the hill as the hill is a pretty steep one. I ended up putting in some old rubber mulch as a fill under the front bed. Therese and the kids helped me at various points, and I think the results are pretty good. We're using the same method as last year from the Square Foot Gardening book, although I couldn't get the same vermiculite we used last year. I had to get the bigger, pearl-ized kind. I did find som...

SQL Server "no count", and Hibernate StaleStateException

Recently an application my company wrote had suddenly stopped working. We were getting an exception from Hibernate in some maintenance tasks we were doing on server startup. The exception string was: org.hibernate.StaleStateException: Unexpected row count: 0; expected: 1 I wondered how this could even be possible since no one was in the DB at the time the server was starting up. The person who reported this error said it was only happening on this one instance of MS SQL server, and no where else. So I proceeded to debug remotely from my workstation to the server instance that failing. I noticed that the message on the StaleStateException was that the number of updated rows "0" did not match the expected row count of "1". This was even more confounding to me as I could even see that the row existed in the database. Plus, Hibernate would re-inserted the row if I deleted it, and yet I would _still_ get the StaleStateException. I should have listened to the perso...

Using Snapshot Isolation with SQL Server and Hibernate

In the course of working on some deadlock issues, I found that MS SQL Server exhibits some unexpected (to me, at least) locking behaviors that can affect performance and cause deadlocks. In the end, I found that SQL Server provides an isolation level called Snapshot isolation which removes the need for locks on rows and removes lock contention. To use this isolation level, you need to execute the following SQL on the database that you want to use the isolation level with (replacing MyDatabase with your database name, of course): ALTER DATABASE MyDatabase SET ALLOW_SNAPSHOT_ISOLATION ON ALTER DATABASE MyDatabase SET READ_COMMITTED_SNAPSHOT ON Next, you need to modify your hibernate.cfg.xml file to add a property to tell Hibernate to use the Snapshot Isolation level: <!-- The 4096 isolation level is the setting to use with the jTDS or Microsoft JDBC drivers --> < property name =”hibernate.connection.isolation”>4096</property> Snapshot isolation is not a panacea...

Virus Authors, I hate you

I was browsing the internet to a see if there was an option to run Civilization V without a DVD, since I hate having to put one in to my laptop if I want to play. I search Google, see a likely site, and go to it. I get to the site and I see some things that look like text links, but nothing is active. So, I start to go back to Google, and I get an error message from Adobe Reader saying it couldn't read the PDF I was trying to open. "Huh, " I say to myself, "I didn't click on any PDFs. I'll just close that window. Hmm, now I'm getting a bunch of Virus infection notifications from some virus software I didn't install. Oh, CRAP!" At this point I'm getting pretty worried, so I power down the system to stop the spread of what ever evil has traveled down the Inter-tubes to my poor, innocent laptop. I figure I'll just build the AVG Rescue environment on my USB key to scan and clean my infested laptop and go about my merry way. I boot up th...