You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Chris Lennert <ca...@gmail.com> on 2011/04/03 20:21:24 UTC

Possible to ignore FK constraints?

Is it possible to instruct OpenJPA to ignore foreign keys to unmapped tables
that may exist in the database?

My situation:  Large ERP database (thousands of tables) that I'm only
reading (never inserting or updating) data from.  My app only is only
concerned with reading records from two tables.  One of the tables has
numerous foreign key constraints, all of which are outside the scope of my
app.  Thus, my entity bean class defines only the fields from that table I'm
interested in.  Unfortunately, the app blows up when OpenJPA queries the
database to determine the constraints that exist on that table and promptly
complains about unmapped FK constraints.

I'm hoping that I can do this without creating entity beans for all these
other tables.

Thanks for any help you can offer,
Chris

Re: Possible to ignore FK constraints?

Posted by Michael Dick <mi...@gmail.com>.
Hi Chris,

It looks like you're using the openjpa.jdbc.SynchronizeMappings property
(with ForeignKeys=true). Could you verify whether that is the case in your
environment?

This setting is useful during application development, but you probably
don't want to use this setting in your production environment. When it's
enabled OpenJPA may attempt to update the table definitions to match your
entities.

HTH

-mike

On Tue, Apr 5, 2011 at 12:49 PM, Rick Curtis <cu...@gmail.com> wrote:

> Chris -
>
> Can you paste the exception that you are seeing?
>
> Thanks,
> Rick
>
> On Sun, Apr 3, 2011 at 1:21 PM, Chris Lennert <ca...@gmail.com> wrote:
>
> > Is it possible to instruct OpenJPA to ignore foreign keys to unmapped
> > tables
> > that may exist in the database?
> >
> > My situation:  Large ERP database (thousands of tables) that I'm only
> > reading (never inserting or updating) data from.  My app only is only
> > concerned with reading records from two tables.  One of the tables has
> > numerous foreign key constraints, all of which are outside the scope of
> my
> > app.  Thus, my entity bean class defines only the fields from that table
> > I'm
> > interested in.  Unfortunately, the app blows up when OpenJPA queries the
> > database to determine the constraints that exist on that table and
> promptly
> > complains about unmapped FK constraints.
> >
> > I'm hoping that I can do this without creating entity beans for all these
> > other tables.
> >
> > Thanks for any help you can offer,
> > Chris
> >
>

Re: Possible to ignore FK constraints?

Posted by Rick Curtis <cu...@gmail.com>.
Chris -

Can you paste the exception that you are seeing?

Thanks,
Rick

On Sun, Apr 3, 2011 at 1:21 PM, Chris Lennert <ca...@gmail.com> wrote:

> Is it possible to instruct OpenJPA to ignore foreign keys to unmapped
> tables
> that may exist in the database?
>
> My situation:  Large ERP database (thousands of tables) that I'm only
> reading (never inserting or updating) data from.  My app only is only
> concerned with reading records from two tables.  One of the tables has
> numerous foreign key constraints, all of which are outside the scope of my
> app.  Thus, my entity bean class defines only the fields from that table
> I'm
> interested in.  Unfortunately, the app blows up when OpenJPA queries the
> database to determine the constraints that exist on that table and promptly
> complains about unmapped FK constraints.
>
> I'm hoping that I can do this without creating entity beans for all these
> other tables.
>
> Thanks for any help you can offer,
> Chris
>