Hey Kevin,

thank you, that clarifies it definitly. My problem now is, that as I'm 
unable to change the schema in the database by adding the missing 
PK-field, I've to
use a native query to retrieve the values. Maybe I can convince the guys 
that maintain the database to rethink their entities, as the entity I need 
to
retrieve is not week, thus the relationship model is not fulfiled at all.

Thanks again for clarifying things,

Heiko

[email protected] schrieb am 22.05.2009 20:23:54:

> Hi Heiko,
> My apologies if my other reply implied that no PK would be required. 
What
> the @DataStoreId provides is the ability to hide an PK field from the 
Entity
> definition.  But, JPA itself (and OpenJPA) requires a PK field of some 
sort
> in order to perform normal Entity operations (insert, find, etc).  Hope 
this
> helps clarify the usage.
> 
> Kevin
> 
> 
> On Fri, May 22, 2009 at 8:24 AM, <[email protected]> wrote:
> 
> > Hello,
> >
> > as I was reading the thread 'Can we have entities without @Id' 
carefully,
> > I read about the possibility to use @DataStoreId to modify the way a
> > primary key column can be retrieved. However, I do NOT understand
> > correctly how to do this.
> >
> > I have an issue where I'm not able to change the table-model within 
the
> > database, but have to create entities from a table that does not 
provide a
> > primary key at all. As it is simply necessary to read information from
> > this table I wanted to use DataStoreId to let JPA generate an Id 
Column
> > itself and add it to the entity.
> >
> > However, this does not seem to work as I expected. I added the 
following
> > code:
> >
> > @Entity
> > @Table(name = "WBZ")
> > @DataStoreId(strategy = GenerationType.SEQUENCE, generator="time")
> > public class WirtschaftlicheBeziehung
> > {
> >        // no id fields in here
> > }
> >
> > As far as I can see in the openJPA source, this leads to an automatic
> > generation of an 'id' column. My problem now is, I do not have an 'id'
> > column in the database, thus this crashes with an exception, that the
> > table WBZ lacks a column named 'id'.
> >
> > My question now is, is there a way to use DataStoreId to handle tables
> > without primary key columns? I do not fully understand the usage of 
the
> > special annotation of DataStoreId when it still searches for a column 
in
> > the database. I thought I do not have to have such a column?
> >
> > Thanks for your time!
> >
> > Heiko
> >
> > If you are not the intended addressee, please inform us immediately 
that
> > you have received this e-mail in error, and delete it. We thank you 
for your
> > cooperation.


If you are not the intended addressee, please inform us immediately that you 
have received this e-mail in error, and delete it. We thank you for your 
cooperation.  

Reply via email to