persistence@glassfish.java.net

using composition with JPA

From: sud <to_sud_at_yahoo.com>
Date: Fri, 20 Jul 2007 16:20:49 -0700 (PDT)

If I have a composition type relationship between two classes (Class A and Class B where Class B is composed of Class A). Both Class A and Class B are entities and have @Entity annotation on them. When object of type Class B is created it's instance variable classA is initialized as well. This instance variable of type Class A should be a snapshot of the object and must be persisted in the Class B table. How can I achieve this. Here is my Class B @Entity Class B { A a; ..... .... } As it is now only the id field in Class A is persisted in the Class B table. I cannot used the @Embedded annotation on A because A already has an @Entity annotation as it is required in the domain. I'd appreciate any pointers. Thanks -sud ____________________________________________________________________________________ Need a vacation? Get great deals to amazing places on Yahoo! Travel. http://travel.yahoo.com/