14.01.2013 Views

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.2.4. Generating Primary Key Values<br />

Now, if you need to code logic in the Employee Entity Object that requires access to the<br />

departments an employee manages, you can call the getDepartmentsManaged()<br />

method rather than the confusing getEmployees() method.<br />

In many cases, artificial primary keys are used (also known as surrogate primary key).<br />

Typically, these primary key columns are called ID. Because they are artificial, they are<br />

meaningless to the user. The system generates the values and uses them internally, but<br />

they should be hidden for the user.<br />

Before starting to generate applications with <strong>JHeadstart</strong>, examine your Model for<br />

artificial primary keys. Make sure they are correctly populated. Test this with the<br />

Business Components Application Module Tester. See section Test the model.<br />

An artificial primary key can be populated in two ways:<br />

• In the Business components: The create method of the entity object is used for<br />

that.<br />

• In the database: A database trigger is in added to the table that gets the next<br />

value from a database sequence and populates the primary key.<br />

3.2.4.1. Surrogate primary key populated in the Business Components Model layer<br />

In the Entity object implementation, a create method is added that takes the value out of<br />

a database sequence and sets the primary key.<br />

This is described in detail in the JDeveloper Help. Check topic ‘Populating an Attribute<br />

from a Database Sequence’.<br />

<strong>JHeadstart</strong> <strong>Developer's</strong> <strong>Guide</strong> Creating ADF Business Components 3 - 7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!