This chapter is under construction. Do not expect it to be useful... yet! (smile)

Model

One of the greatest things about WebObjects is the Enterprise Objects Framework (EOF) that handles all your data management. More than 10 years old, it's still one of the most powerful OR mapping tools available, if not the most powerful. It even inspired Code Data, an EOF clone used in the Mac desktop for all the data handling an application needs, introduced in Mac OS X Tiger (10.4).

One great feature of EOF is data modeling. EOF allows you to define your data model in one or more Model files that are contain all the information needed by the application to, in run time, access the database to create, search and delete your data. Here we'll see some useful advices about data modeling and Model file creation.

Prototypes

EOF is a great tool, and one good thing about it is that it doesn't try to hide or make decisions for you. Enterprise applications is serious stuff, and many factors, like backward compatibility with existing databases must be taken care. One place where EOF leaves the decision to you is how it should map your Java objects to the database internal data types.

There are two main reasons for this:

If you already tried to create a model, by following Janine's tutorial or so, you know how flexible it can be - and how tedious it is. It shouldn't be needed to choose, for every integer in your model, the data type for it. Or the data type for every primary key. Or the data type for every string. Worse, if you decide you want to use higher precision floats on all your application, or if you want to increase the size of some of the strings you use in your data model, you should be able to change that information on only one place. After all, duplicating code is bad, right? So why can't you do it?

Well, you can! That's what prototypes are for. A prototype allows you to:

Let's look at an example for a prototype. This is the definition of "shortString", a prototype defined in the WONDER's ERPrototypes framework (we'll talk more about this framework later). The screenshot was taken from the Entity Modeler plugin in Eclipse, part of WOLips.

We can see here that:

(The other fields are not relevant for the prototype definition)

eogenerator

to-many relationships