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.