Archive for August, 2005

Playing with Maya

I decided to pick up an “old” hobby and start playing with 3d modeling and animation again. So I downloaded the Personal Learning Edition of Maya 6. This is a free learning edition of Maya Complete version 6. It allows you to create, model, render and save models and projects. There are only two real limitations which are that the rendered output size is limited to something like 640×480 and the rendered output has a big ugly watermark across it. But for learning, it does work and it is cheaper then buying the full version.

So far I don’t really know anything and am watching any and all videos that I can find on the web. As such, I don’t have amazing examples of things that I have modeled. I don’t even have any crappy models. So there is nothing to show so far.

Hibernate Question - how to work with history

I have a small hibernate question that I can not seem to find an answer to, however, this may be due to my not knowing how to search for it properly.

The question is: how to work with objects in Java that, in the database, must preserve history? A lot of database schemas, instead of updating rows, do a new insert and mark the new row as active in some way. This allows an organization to basically version their data and ensures that they never loose or delete anything.

Below is a common schema for capturing history. You have a central table, Person, that contains only the fields that are unlikely to change. In this example, I am assuming that most people do not change their names. Off of that central table, are tables that hold all the other data related to the central table. In this case, the two other tables hold a person’s address and phone number. As this data changes, the records in the respective table are not updated. Instead, another row is added to the table and it becomes the active record. Below is a diagram showing the database schema.

Diagram showing common schema to handle record history in a database

Just to make this completely clear, below shows the data in the three tables as they would exist after a few updates.

Person
personID | firstname | lastname
---------|-----------|----------
  1      | mickey    | mouse

Address
addressID | street             | Person_personID
----------|--------------------|----------------
  1       | 112 somewhere str. |  1
  2       | 20 elsewhere ave.  |  1

Phone
phoneID | phone_number | Person_personID
--------|--------------|----------------
  1     | 555-555-1234 |  1
  2     | 555-555-4321 |  1
  3     | 555-444 4444 |  1

So, here is the question. In Java, I would create the following class diagram:

Class diagram of History hibernate question

The problem is that if I modify any of the associated objects, Hibernate will simply go in and update the associated rows in the database. So, is there any way to force Hibernate to insert a new row instead of updating the existing row?

Presentation by Rod Johnson on Persistence Strategy

The ServerSide has posted a presentation by Rod Johnson on Persistence Strategy. This is an excellent presentation that every Java developer should check out. In it he outlines the problems with persisting objects and some of the solutions. He also goes into why the “roll your own” solution to persistence is bad. This is something that I definitely agree with. If you have the choice between coding something yourself or using Hibernate, use Hibernate. At the end of the presentation, he goes into how Spring implements persistence and how it abstracts that persistence away from the business layer, but still provides all the functionality and power of the underlying database.

In the presentation, Rod outlines eight points or lessons:

  1. Data tends to stick where it lands. You can’t assume that any Java application controls the schema, and the schema may outlive the application.
  2. Tools are useful, but are a bandaid solution. If you’re using tools to do things that could not be done by hand - you’ve got problems.
  3. Peristence should not be tied to a specific environment.
  4. Databases are very good at what they do - but it’s necessary to let them do it in a natural way.
  5. Don’t attempt to build your own persistence framework, unless your requirments are truly unique (like not accessing common types of persistent stores).
  6. O/R mapping works well in 90-95% of cases, but many developers get burnt applying it everywhere.
  7. Using JDBC directly should be a sackable [english slang for fired] offence.
  8. Don’t afraid to use DB specific features if you have a sound architecture (isolate them behind interfaces).

I personally like the seventh lesson.

Intellij IDEA 5 Released

JetBrains has released version 5 of their Java IDE, IntelliJ IDEA. I have downloaded this new release and will be trying it out over the next several weeks so look for a review in the near future. I have used version 4.5 a little and have been very impressed with what I have see.

Both Javalobby and The ServerSide have official releases and discussions.

« Previous Page