armtuk: Cheetah (Default)
2009-03-04 12:38 am
Entry tags:

The most Awesome SQL

If you can even figure out how this works, Kudos. I'm pretty proud I figured out how to make this. There might be better ways, but this way works, and gets me what I need:

select * from task x, (select p.project_id, u.workflow_id, (select min(due_date) as min_due_date from task t where t.workflow_id=u.workflow_id) as min_due_date from task u, workflow p where u.workflow_id=p.workflow_id group by u.workflow_id, p.project_id) y where x.due_date=y.min_due_date and x.workflow_id=y.workflow_id;

Muhahahaha.
armtuk: Cheetah (Default)
2009-02-23 03:45 pm
Entry tags:

Things you can do in MySQL

Why can't I do this?

update sp_college_game n set n.game_status_ev_id=6 where n.college_game_id in (select a.college_game_id from sp_college_game a, sp_college_playoff_entry b where a.college_game_id = b.game_id)

It's not that hard! Oracle will let me do that, and so will PostgreSQL, but MySQL is too crap.

Did I mention that you have to a stupid idiot to walk outside to talk on your cell phone with nothing more than a long sleeve T-Shirt on! It's frikin cold!
armtuk: Cheetah (Default)
2008-12-07 12:35 am
Entry tags:
armtuk: Cheetah (Default)
2008-12-01 10:33 pm
Entry tags:

Today's Hibernate Lesson

So for today's hard knocks hibernate lesson we learn that putting annotations on Member variables instead of Member Functions is a really bad idea. It breaks when you use inheritance. If you inherit from a MappedSuperclass and that superclass has members that are complex objects, then when you inherit them, all the annotations are ignored in the subclass, so you end up with database fields being of type bytea (at least in PostgreSQL) instead of being correctly mapped as foreign keys.

So in summary: Don't put annotations on member variables, always put them on member functions.

*SIGH* time to refactor 32 database classes.

At least I found the problem quickly.
armtuk: Cheetah (Default)
2008-11-16 05:02 pm
Entry tags:

Hibernate Fun

I am struggling through Hibernate funness. I bought the O'Reilly book, but it's a bit thin, and after reading a few peoples' reviews, I also got the Persistence with Hibernate book from Manning which is AWESOME.

the merge method is evil. It looks like a good replacement for persist() but it isn't. merge() doesn't actually tie the object to the database state, so if you call merge() repeatedly on an object with no Id, it will save it repeatedly. persist() however does the right thing. The only thing merge gives you is the ability to save an object across sessions, but it would probably be better to attempt to re-attach the object instead of merging it.
armtuk: Cheetah (Default)
2008-10-14 04:25 pm
Entry tags:

Wicket

I have just started looking through the book on Wicket. They seem to have the same feeling towards MVC that I do: it's a fundamentally broken approach to web sites. I'm glad I'm not insane :). I got a chance to read some of it whilst Thomas got his hair cut. I am hopeful that the rest is as good as the start.