Hi is_maximum, I'm still a little confused by your scenario. Following your described scenario... Your master table would have an Id field, but your secondary table would not have an explicit Id field. The foreign key from your master to secondary would just be some arbitrary column from the secondary table? Do I have that right? And, why would removing an Id field help with performance? You mention to get rid of its sequence, but there's no requirement to define an Id field with a sequence.
Even though I'm still a little confused by your scenario, there are a couple of items to be aware of from an OpenJPA perspective. The JPA spec requires an Id field, but OpenJPA does not require one. Well, not exactly. Instead of declaring an explicit Id field, you could instead declare an Id via the @DataStoreId annotation [1]. This hides the Id field from your Entity definition, but under the covers we still use an implicit Id field in order to insert and find records. Another possibility is coming with the updated JPA 2 specification and the use of derived identities. I'm probably stretching this one a bit, but this support would allow you to derive an identity for an Entity based on the identity of a "parent" Entity. This is normally used when the dependent Entity is the owner of a many-to-one or one-to-one relationship to the parent entity. Here again, OpenJPA provides a similar functionality with their Entities as Identity fields. So, bottom line is that some type of Identity is required for proper Entity definition and usage. But, OpenJPA (and eventually the JPA 2 spec) provides for some methods to get around the explicit definition of an Id field. Hope this helps, Kevin [1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_oid_datastore [2] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_oid_entitypk On Wed, May 20, 2009 at 7:14 AM, is_maximum <[email protected]> wrote: > > Hi > We have some tables in which id is not important and actually it is > useless. > For example we have two logging tables, one is master and the other is > keeping details. The only foreign key from the master table is enough and > the second table has no relationship with other tables so if we remove its > ID we can get rid of its sequence and this will be great in terms of > performance since this table is considered to keep lots of records and its > purpose is for preserving events took place in the system > > Now my question is how to remove its @Id from the entity since the OpenJPA > complains if the entity has no field marked as id > > Thanks > -- > View this message in context: > http://n2.nabble.com/Can-we-have-an-entity-with-no-%40Id--tp2945752p2945752.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > >
