Hi Tony,
You should be able to do this by enabling cascading on your relationship.
Something like this:
@OneToMany(cascade={PERSIST})
With this setting, when you call persist on an object, all the objects on the
other side of this relationship will be automatically be persisted.
-Tom
Tony Huang wrote:
> Hi, All
> I created 3 classes: Class A has a collection of class B; B has a
> collection of class C
> When saving the instance of A to DB table, I want also save the children
> and grandchildren of B and C.
> But I failed to do this.
>
> My question is JPA support the 3 layer hierarchy?
> What should I do to solve my problem?
>
> Thanks
>
> *Tony Huang*
> Developer,Foundation
> The Active Network,LTD (Xi’an)
>
> _Tony.Huang_at_ActiveNetwork.com_ <mailto:Tony.Huang_at_ActiveNetwork.com>
> Mobile 86-13389240842
> MSN _hdp214_at_163.com_ <mailto:hdp214_at_163.com>
> Skype tony.huang214
> QinFengGeD201 68 Keji No. 2 Rd.
> Xian, China 710075
> _www.ActiveNetwork.com_ <http://www.ActiveNetwork.com>
>
>
>