Phew!

This is my second summer here at Caltech, and one would think it would be more relaxing than my first summer, since I have more things taken care this time around. However, it has been quite busy since we are trying to put together a new and improved homework management system. It promises to be pretty slick, or at least slicker than cs1man was. It is also a Java EE (aka J2EE) application running on JBoss, like cs1man is, but I am using Hibernate for the persistence layer.

However, I kept running into problems with getting Hibernate to actually save changes back to the database! This was really confusing, since I was trying to integrate Hibernate’s session and transaction management into JBoss’ container-managed transaction (CMT) mechanism. I thought that I had gotten it all configured properly, but it just wasn’t happening.

Finally, today I had the key insight - if I am going to use CMT then the application server kind of needs to know about the data-source too! I had configured Hibernate to connect to the database directly, in order to avoid all the hassles of setting up the data-source in JBoss. That had the unintended side-effect of removing my database interactions from the CMT mechanism, and lo and behold I ended up with no committed transactions.

D’oh!

Once I figured that out, I reconfigured JBoss to expose the database as a JNDI data-source, got Hibernate to pull its DB connection from JNDI, and everything started working properly.

Phew!

One Response to “Phew!”

  1. Ben Says:

    I look forward to hearing about the replacement. :)

    I will be in town in a few weeks; let me know what your schedule is on Friday Oct 6. Hopefully I can stop by and say howdy to all the geeks!

Leave a Reply