You might want to experiment with validating the schema rather than
auto-creating it; see the DN docs [2]


[2] http://www.datanucleus.org/products/datanucleus/jdo/schema.html


On 5 March 2014 10:01, <[email protected]> wrote:

> Hi Dan,
>
> Even after using the constraint name at the database side in
> @ForeignKey(name="om_geo_location_parent_location_id"), it is trying to
> create the FK constraint again but with the same name and hence error
> occurred:
>
>
> 15:22:53,852  [Schema               main       DEBUG]  Creating foreign
> key constraint : "om_geo_location_parent_location_id" in catalog "" schema
> "gemsods"
> 15:22:53,852  [Schema               main       DEBUG]  ALTER TABLE
> gemsods."om_geo_location" ADD CONSTRAINT
> "om_geo_location_parent_location_id" FOREIGN KEY
> ("parent_location_id","org_id") REFERENCES gemsods."om_geo_location"
> ("location_id","org_id") ON DELETE RESTRICT ON UPDATE RESTRICT INITIALLY
> DEFERRED
> 15:22:53,865  [Schema               main       DEBUG]  An error occurred
> while auto-creating schema elements - rolling back
>
> One more thing: The other FK works with a match of constraint name. It
> doesn't create FK for it again (as seen in the log).This FK is to other
> table.
>
> Problem is coming with self-referential case.
>
> BR
> Ranganath Varma
>
> -----Original Message-----
> From: Dan Haywood [mailto:[email protected]]
> Sent: Wednesday, March 05, 2014 2:54 PM
> To: users
> Subject: Re: Creating foreign key constarints again with autoCreateSchema=
> true
>
> On 5 March 2014 09:04, <[email protected]> wrote:
>
> > Hi,
> >
> > I have database schema is present already. And I have created domain
> > objects mapping to the tables with JDO annotations.
> >
> > I have a table with two foreign keys already present, one to the other
> > table and second to the self. And there are respective domain objects
> > mapped to these tables.
> >
> > When I start Isis-project webappp with autoCreateSchema= true, it is
> > creating again two more foreign keys constraints with different names
> >
> > Why it is creating foreign keys when already present?
> >
>
> I would imagine because it uses the constraint names to match.
>
>
> > How to avoid this issue? Please help.
> >
>
> It is possible to specify the constraint name, I reckon that'll fix it.
>  Check the JDO docs [1]
>
>
> Dan
>
> [1]
> http://www.datanucleus.org/products/datanucleus/jdo/orm/constraints.html
>
>
> > BR
> > Ranganath Varma
> >
> >
>
> The information contained in this electronic message and any attachments
> to this message are intended for the exclusive use of the addressee(s) and
> may contain proprietary, confidential or privileged information. If you are
> not the intended recipient, you should not disseminate, distribute or copy
> this e-mail. Please notify the sender immediately and destroy all copies of
> this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses.
> The company accepts no liability for any damage caused by any virus
> transmitted by this email.
>
> www.wipro.com
>

Reply via email to