|
|
||
Jacob Hookom's BlogDecember 2005 ArchivesHandling Type Codes in Your Domain ModelsPosted by jhook on December 14, 2005 at 09:43 AM | Permalink | Comments (3)With complex enterprise systems, we often times find ourselves with lots of 'flags' or 'types' within our database tables. Utilizing Hibernate's UserType facility, we can handle these types in such a way that will carry extra behavior and information within your domain models. You probably all have them, those VARCHAR(2) or VARCHAR(1) fields in your tables that describe the type or source of the data. One approach would be to explicitly map that character data as a String or char property to your domain models. I've also seen a lot of discussion around using enums within JSE 5 to handle these values. But often, you need to translate that code into additional behavior or just human-readable format. The approach we've taken is to create simple Objects that have an identity to match the 'type' in the database and then include extra information. An example of handling purchase orders, where each line item has a status:
Now we have a basic Domain Type that we can program off of in relation to our OrderLines. This Domain Type will also include additional (static) data that can be carried into your application, based on that one two character field from the database. The addition of 'summary' and 'detail' properties also provides our applications with consistent, human-readable, information as it relates to that status. The next step is configuring this Type for Hibernate by creating a LineStatusType.
That's it. Some more complex objects could have a few of these Domain Types allotted. Are there other approaches to handling type flags in your databases? Move Over ApachePosted by jhook on December 08, 2005 at 09:47 PM | Permalink | Comments (1)A little over a year ago, the JavaServer Faces specification caught my interest. I've always considered myself a 'do it yourself' programmer and went as far as to start my own implementation of the JavaServer Faces specification. I reached a point where I thought I really had something and was left with a few options: contribute to Apache, publish it on my own, or contribute to Sun's reference implementation. After much thought, here's an opportunity to contribute to 'the' standard and I joined the reference implementation at Java.net. By far, it was the best decision I'd ever made in my programming career. One year later. In that time, I've been able to be a committer on the reference implementation of JSF, immediately joined the JSF EG, then invited to the Web Tier EG, given my own sub-project (Facelets) under Sun, added as one of the first Java Champions, and even had a few job offers since. I'd like to throw in the fact that because of that one decision, I've had the opportunity to meet and talk with industry names that I've only read on bindings of books or in articles-- Jason Hunter, Gavin King, Craig McClanahan, Ed Burns, David Geary, Kito Mann, etc. The reason why I'm writing this blog is that so many out there have shied away from contributing to Sun's open source initiative under the CDDL. I'd like to use my last year as an example of the opportunities that are provided by making that one decision, the same decision that any of you can pursue. Apache isn't the only body out there accepting eager developers and I guarantee that you will get a lot more recognition with an industry name like Sun. I know that joining an open source project is driven by your own personal interests, maybe it's the new EJB3, Web Services, or JSF to name a few? | ||
|
|