【发布时间】:2012-01-31 21:04:32
【问题描述】:
我希望有一种灵活的方式来编组对象。单个对象的详细版本和多个对象版本的不太详细的版本。
以我的部门模型为例:
GET /locations/1:
<location id='1'>
<link rel="self" href="http://example.com/locations/1"/>
<link rel="parent" href="http://example.com/serviceareas/1"/>
<name>location 01</name>
<departments>
<department id='1'>
<link rel="self" href="http://example.com/departments/1"/>
<name>department 01</name>
</department>
<department id='2'>
<link rel="self" href="http://example.com/departments/2"/>
<name>department 02</name>
</department>
<department id='3'>
<link rel="self" href="http://example.com/departments/3"/>
<name>department 03</name>
</department>
</departments>
</location>
GET /department/1:
<department id='1'>
<link rel="self" href="http://example.com/departments/1"/>
<link rel="parent" href="http://example.com/locations/1"/>
<name>department 01</name>
<abbr>dept 01</abbr>
....
<specialty>critical care</specialty>
</department>
有没有办法做到这一点?我需要有单独的实体对象吗?一个引用表进行 CRUD 操作,另一个引用列表?
【问题讨论】:
标签: jpa-2.0 jersey eclipselink jax-rs jaxb2