Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Final list of attributes should look like this:

Now, it's time to link the two entities together. A Author can have multiple blog entries, and a BlogEntry can only have one author. To create the relationship (the join), right-click on Author and select New Relationship. On your right, select BlogEntry in the list. On your left, select to many BlogEntries, and on your left, select to one Author. Now, in BlogEntry, we need to store the primary key of the author so that we can make the join. The relationship builder allow us to add that attribute, so make sure and a new foreign key named is checked (it is checked by default). The Create Relationship pane should look like this:

If you check in the Outline tab, you should see that Author now have a blogEntries relationship, and BlogEntry have a author relationship.

You are now ready to save the model. Save it (File -> Save) and close the Entity Modeler window. If you open the Sources in the main Eclipse window, you will notice that the Sources folder contains a package named

That package have four Java classes: _Author, Author, _BlogEntry and BlogEntry. Those classes were generated by Veogen, a templating engine build on Velocity. The two classes that starts with a underscore are recreated every time you change the EOModel, so if you want to change something in those classes, you need to change the template (no need for that right now). But you can change freely the two classes that don't have the underscore, and this is what we will be doing.

What we are going to do is to write a simple method that returns the full name of an author, e.g. a method that simply concatenate the first name, a space and the last name of the author. To do so, double-click on and add the following methods:

Code Block

	public String fullName() {
	  return this.firstName() + " " + this.lastName();

Nothing fancy here. And you are now ready to create REST controllers.

Creating REST controllers and routes