[jboss-user] [EJB 3.0] - Re: Attribute from MappedClass as a part of composit PK ?

Wolfgang Knauf do-not-reply at jboss.com
Wed Jun 17 05:31:34 EDT 2009


I am not sure whether the following works, but I would suggest that you use an EmbedddId for your primary key. This way, you have to create an Embeddable class, and you have to duplicate the timestamp ID property to the embeddable class.

The only problem with this approach is that this would duplicate the field in insert/update statements.
So you have to annotate the timestamp property in the embeddable class this way:
  | public class MyId implements Serializable
  | {
  |   @Column(name="...", insertable=false, updateable=false)
  |   public TimeStamp getSomething()
  |   {
  |     ...
  |   }
  |   @Column(...)
  |   public Integer getOtherIdFields()
  |   {
  |     ...
  |   }
  | }

Hope this works and helps ;-)


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4238146#4238146

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4238146

More information about the jboss-user mailing list