Changes for page Your First Rest Project
Last modified by Steve Peery on 2013/09/06 11:02
From version 21.1
edited by Filippo Laurìa
on 2013/07/22 12:25
on 2013/07/22 12:25
Change comment:
There is no comment for this version
To version 27.1
edited by Filippo Laurìa
on 2013/07/22 12:51
on 2013/07/22 12:51
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -185,8 +185,12 @@ 185 185 186 186 If you did everything well, the list of attributes should look like this: 187 187 188 +[[image:attach:list_wlock.png]] 189 + 188 188 You will notice that the attributes have a column with a lock in it. When a lock is present, it will use the value of that attribute for //UPDATE ... WHERE attribute = ''// statement. This is to do optimistic locking, aka to prevent data conflict when the data object was modified by two different users. Using timestamps for optimistic locking is not a good idea because for certain RDBMS, the value can be different because of milliseconds, so remove the locks on the **creationDate** attribute. The final list should look like this: 189 189 192 +[[image:attach:list.png]] 193 + 190 190 Next step is to create the **Author** entity. Create a new entity with **Author** at its name (and also as the table name), and for the class name, use **your.app.model.Author**. The attributes for this entity are: 191 191 192 192 |=((( ... ... @@ -220,8 +220,12 @@ 220 220 221 221 Final list of attributes should look like this: 222 222 227 +[[image:attach:author_list.png]] 228 + 223 223 Now, it's time to link the two entities together. An 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 right, 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: 224 224 231 +[[image:attach:relationship.png]] 232 + 225 225 If you check in the **Outline** tab, you should see that **Author** now have a **blogEntries** relationship, and **BlogEntry** have a **author** relationship. 226 226 227 227 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 **your.app.model**. (If this folder doesn't appear, you may need to set your preferences to automatically generate these source files; see the second suggestion on [[http:~~/~~/wiki.wocommunity.org/display/documentation/Useful+Eclipse+or+WOLips+Preferences>>url:http://wiki.wocommunity.org/display/documentation/Useful+Eclipse+or+WOLips+Preferences||rel="nofollow" shape="rect" class="external-link"]].)