DefaultMappingFromEntityToResource

Default Mapping From Entity To Resource

Persistence Entity Resource

  • NB 6.0 REST support, by default, uses XML representation for generated resource from persistence entities.
  • Each entity property of primitive data type will be mapped to an XML element with text representation.
  • If the entity property is a reference to an entity, we will provide the referenced resource URI as an attribute of the ref element along with the foreign key values.
  • For example, we will have:
<customer>
    <id>0001</id>
    <name>John Doe</name>
    <address-ref uri="/customer/0001/address">
       <id>123456</id>
    </address-ref">
</customer>

instead of:

<customer>
    <id>0001</id>
    <name>John Doe</name>
    <address>
        <id>123456</id>
        <line1>333 Market St.</line1>
        <line2></line2>
        <city>San Jose</city>
        <state>CA</state>
        <zip>95121</zip>
    </address>
</customer>

Container Resource

  • NB 6.0 REST support, by default, uses XML representation for generated resource from container entities.
  • By default, each contained entity resource will be presented as as child element with an URI attribute linked to the actual resource. The primary key values are also provided.
  • For example, we will have:
<customers>
    <customer-ref uri="/customer/1">
        <customer_id>1</customer_id>
    </customer-ref>
    <customer-ref uri="/customer/2">
        <customer_id>2</customer_id>
    </customer-ref>
    <customer-ref uri="/customer/3">
        <customer_id>3</customer_id>
    </customer-ref>
</customers>
  • Note: if needed developer could modified the JAXB class to fine-tune the returned XML representation to add more information of the contained resource aside from the primary key.

Questions:

1. Is HTML or other representations more useful than XML for Container Pattern?

2. Is this plain list of URI values or full entity XML content is more useful for Container pattern in most web applications? Wouldn't this cause performance problem if the single web page is to display selected details of all resources in the container?

3. Is sub-resource supported supported yet? (e.g., 'address' in /customer/0001/address).

4. What do you have in mind for J1 demo? Is the described UI sufficient?

-- Main.NamNguyen - 12 Mar 2007

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo