afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
I've spent the afternoon tracing a legacy data issue, which was preventing any changes on older records from being saved. It turns out that having a null value for an optlock in the database, causes a org.hibernate.StaleObjectStateException; I also saw javax.persistence.EntityNotFoundException in the logs.

Funny, this is the reverse of what most other people have run into -- most other people getting the EntityNotFoundException were doing so because they had an invalid id, and the fix for them was to make their id NULL.

In hindsight, it was to be expected. Would it be better behavior to instead handle this case more gracefully (treat null as a 0, instead of an exception)? I can't make up my mind. It would have made things easier for me, but it does seem rather an edge case, made possible only because we'd migrated old data into the system.

enterprise java

Wednesday, October 28th, 2009 04:01 pm
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
I am discovering, to my absolute horror that enterprise Java is a lot like myself: often has a point, but unable to get there without going on long rambling tangents; requires a lot of structure to hold itself together; loves, loves, loves to scatter and repeat itself everywhere.

I am reading tutorials on how to set up and use JPA. Sooooo many things that need to be set up before you can even test whether you can, say, connect to a database. And at that, all the articles make it a point to emphasize how wow, the new API makes life so much easier and better more convenient and faster than before (perhaps I shall one day see the difference, the way I did when I was being frustrated by maven's complexity, and then had to use ant briefly, which made me realize what all the fuss about maven was about)

I definitely cannot mistake what I am doing as anything other than work. Which is not a bad thing! I have plenty of toys to play with on my off time :)

Less frustrating, more flexible, more lightweight, more exciting, more practical, toys.