Posts

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...

Search from Start Menu Stops Returning Items

Image
I've always hated how the start menu in Windows gets so bloated with icons. Since migrating to Windows 7, I've really gotten into using the start menu search box to quickly find the app I want to run by simply typing a few of the characters of the name of the app. It is much easier than trying to set up paths and do everything from the command line. I recently found that the start menu search functionality seemed to have stopped working properly for me. Every time I would try to search for something like "cmd" for the Windows Command Prompt, I was greeting with only a couple of entries in the list with generic icons like the screen shot below: After some searching, I was able to find a Microsoft answers entry that referred to my problem exactly. It seems that the root of the problem is the GroupBy value in the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FolderTypes\{EF87B4CB-F2CE-4785-8658-4CA6C63E38C6}\TopViews\{00000000-0000-0000-0000-0...

Write More Declaritive JUnit Assertions with Hamcrest

The Hamcrest framework is a generic "matching" framework that JUnit added direct support for with version 4.4. Hamcrest allows developers to write more declarative assertions by using both built in matchers, as well as a clean way to define your own matchers. The online documentation on Hamcrest is mostly limited to some API docs, test cases, and a brief online tutorial . However the API is fairly intuitive for basic checks. One area that was intersting to me was the collection portion of the API. Hamcrest allows you to perform some assertions on collections to check for the existence of an item in the collection, but all the examples I saw were based on simple collections of items that implemented "equals" (Strings, primitives, etc). However, I wanted to find a way to validate more complex objects that may not have implemented equals. After some experimentation, I found I nice way to do what I was trying do. Basically, the collection matchers allow for embed...

Don't Package on Every Single Compile, Flex Compiler!!

One of the problems I have with Adobe's Flex technology is that Flex compile times are very slow. Yes, I know, Gumbo is going to make compiles somewhat faster. I also know about the Flex Compiler Shell, and other projects to distribute compilation. Yes, I've also tried incremental compilation. All of these things really miss the true problem with the Flex compiler. And it is really at the heart of the Flash technology itself. The problem really lies in granularity of a compilation unit that Flash and the Flex compiler produce. Basically the output of a compile is a SWC or SWF which is fully ready to be deployed. I think the scope of compilation unit that the compiler uses is way too big. The Flex compiler should be producing an intermediate level compilation unit tied to the source file level, or at least some smaller scope. I'm just a dumb Java guy, but SWCs and SWFs look a lot like JAR files to me. They include all the bytecode and embedded resources needed for ...

Pandora Desktop Hotkeys Enhanced

I noted an issue with my original Pandora Desktop Hotkey script in that the embedded Flash control in the Pandora Desktop app sometimes has a different "control" name. This change in name would _sometimes_ make the script unable to send keys to the control. Here's an updated script that tries to work around this issue by simply sending keys to either of the possible names for that embedded control. Enjoy! DetectHiddenWindows, On ; Pandora Controls ;Ctrl-Win-Alt-Right Arrow ^#!Right:: IfWinExist, ahk_class ApolloRuntimeContentWindow ControlSend, WebPluginView1, {RIGHT} ; Next ControlSend, WebPluginView2, {RIGHT} ; Next return ;Ctrl-Win-Alt-Up Arrow ^#!Up:: IfWinExist, ahk_class ApolloRuntimeContentWindow ControlSend, WebPluginView1, {UP} ; Volume Up ControlSend, WebPluginView2, {UP} ; Volume Up return ;Ctrl-Win-Alt-Shift-Up Arrow ^#!+Up:: IfWinExist, ahk_class ApolloRuntimeContentWindow ControlSend, WebPluginView1, {SHIFT}{UP} ; Volume Max ControlSend, WebPluginView2, ...