You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by YanSh <sh...@yahoo.co.uk> on 2007/07/27 18:23:23 UTC
Sqeuences, Foreign Keys and Master-detail Relationship
Hi.
I have a few questions. If anyone can answer any of the 3, I would really
appreciated it.
1. We have problems using sequences, sometimes the correct id is not given
back, but instead they send back a zero id. Can anyone tell me what is
causing this?
2. We have problems with foreign keys ( generation and referencing).
3. There seems to be problems with out of order writing for master-detail
relationships. ( detail records are written before master thus making
referntial integrity violation on detail table.) Is it possible to receive
any timeframe estimations for this problem to be fixed?
Many thanks.
Yan
--
View this message in context: http://www.nabble.com/Sqeuences%2C-Foreign-Keys-and-Master-detail-Relationship-tf4158883.html#a11832433
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
Re: Sqeuences, Foreign Keys and Master-detail Relationship
Posted by Marc Prud'hommeaux <mp...@apache.org>.
Yan-
On Jul 27, 2007, at 9:23 AM, YanSh wrote:
>
> Hi.
>
> I have a few questions. If anyone can answer any of the 3, I would
> really
> appreciated it.
>
> 1. We have problems using sequences, sometimes the correct id is
> not given
> back, but instead they send back a zero id. Can anyone tell me what is
> causing this?
Can you show us how you are declaring the sequences?
> 2. We have problems with foreign keys ( generation and referencing).
We'd need more details about your mappings and sequences and a
description of the actual problem to hope to help with this.
> 3. There seems to be problems with out of order writing for master-
> detail
> relationships. ( detail records are written before master thus making
> referntial integrity violation on detail table.) Is it possible to
> receive
> any timeframe estimations for this problem to be fixed?
Your problem that OpenJPA does not read foreign keys by default. The
following excerpt from OPENJPA-39 might be helpful:
OpenJPA has to know where the DB foreign keys are. You have a few
options:
- Using the org.apache.openjpa.persistence.ForeignKey annotation, and
related annnotations
(ElementForeignKey, etc) to tell OpenJPA exactly which relations and
joins have foreign keys
on them.
- Setting the "openjpa.jdbc.SchemaFactory" property to "native
(ForeignKeys=true)" will tell
OpenJPA to read the existing schema from the DB, including foreign
key locations, using JDBC
schema reflection. Under this setting OpenJPA will also validate
that the schema and mappings
match.
- Setting the "openjpa.jdbc.MappingDefaults" property to "jpa
(ForeignKeyDeleteAction=restrict,
JoinForeignKeyDeleteAction=restrict)" will tell OpenJPA to just
assume that all relations
and joins are backed by database foreign keys.
The first and third options also affect schema creation, in that
OpenJPA's schema creation
tools will add foreign keys to to the annotated relations and joins /
to all relations and
joins under those settings.
> Many thanks.
>
> Yan
> --
> View this message in context: http://www.nabble.com/Sqeuences%2C-
> Foreign-Keys-and-Master-detail-Relationship-tf4158883.html#a11832433
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>