When I finished the blog features on this site, the next big thing on my list was developing a way to index and search the contents. I didn't want to let Google do it for me, because that's like cheating. I had heard good things about Lucene (actually great things, I know a guy who uses it for everything from searching for products in a web store to indexing biological information), so I started looking into that.
I was happy when I discovered Hibernate Search, a library that simplifies mapping a Hibernate domain model to Lucene's searching capabilities. I was even happier when I discovered that Hibernate Search has excellent support for JPA, which is the API I used for this site. In the rest of this post I'll outline the steps I had to take to add Hibernate Search to this site. It ended up being much easier and more intuitive than I had expected...
Woot.com has been running a woot-off for the last couple of days, selling tons and tons of random stuff. I didn't check on it until tonight, when I noticed to my great shock and amazement that I had arrived just in time for Bacon Salt®!!! I had no choice but to order all three flavors, Original, Hickory, and Peppered.
I just have to put a plug in for Snyder's of Hanover Honey Mustard and Onion pretzel pieces. They are without a doubt the best snack food on the planet. Every piece just bursts with an addictive flavor that's not too mustardy or oniony. They have totally redefined what a pretzel is capable of. I can no longer go one day without eating some of them.
I remember a time when I didn't write unit tests. I'm not sure why I didn't. Maybe because I thought that the projects I was working on were too simple to warrant unit testing (which actually wasn't true, my thesis project would have really benefited from it). Or maybe because I thought it would take too much time when the schedule was really tight. Or maybe because I doubted the time-effectiveness of spending time writing a lot of basic tests.
I found this months ago on YouTube, and I still find myself watching it at least once a week. The song itself (Rachmaninoff Prelude Op. 23 No. 5) is fantastic, but Gilels' performance is simply perfect, with expression that blows away all the other ones I've heard. I had to go out and buy the music, but it's crazy hard – I still haven't gotten the first 30 seconds down yet.
Maybe it would help if I grew an awesome combover-style hairdo like his.
I've been working on an update to this site that adds blogging & commenting features. It's a Spring + JPA site, so I created a Post object and a PostDAO and built all the new features using those classes. Everything worked perfectly until I implemented the delete controller. When trying to delete a Post, I was getting the following exception:
org.springframework.dao.InvalidDataAccessApiUsageException: Removing a detached instance com.musicstore.model.Post
I debugged the exception, searched all over the place and couldn't figure what was causing the exception, which was occurring within a getJpaTemplate().remove(post) call. After an hour or two of fruitless googling, I decided to read up on JpaSupport (which the PostDAO extends) and look more closely at my code. I finally realized what the problem was when I noticed that JpaSupport provides callbacks when you need to access an EntityManager directly – but I wasn't using them...
| Newer posts » |