-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @ManyToOne annotaion and fk (foreign key) duplication
PostPosted: Mon Nov 30, 2009 1:59 pm 
Newbie

Joined: Tue Dec 16, 2008 6:59 am
Posts: 6
Hi everyone
I am experimenting a (for me) weird issue with my database (PostgreSQL 8.3) and @ManyToOne annotations. In addtion, I am using Hibernate3 and annotations.

Given the context such that many interviews can belong to one project, I have a codprj field on table Interview as foreign key referencing to table Project id field such that:
Code:
CONSTRAINT "fk_interview_is_formed_project" FOREIGN KEY ("codprj")
    REFERENCES "public"."project"("idprj")
    ON DELETE CASCADE
    ON UPDATE CASCADE
    NOT DEFERRABLE

For my entity class Interview I have a many-to-one mapping (many interviews can belong to a single projec) as follows:
Code:
@ManyToOne(targetEntity=Project.class)
@JoinColumn(name="codprj")
private Project parentPrj;

On the referenced entity class (Project in this example) I have the other way relationship as I have read on several tutorials, which looks as follows:
Code:
@OneToMany(mappedBy="parentPrj", cascade = ALL)
   private List<Interview> interviews;

But, every time I reload my web application or I run for testing some new feature from my IDE, I got all foreign keys -all mapped as @ManyToOne- duplicated, as you can see next:
Code:
CONSTRAINT "fk1dfcd181bc927c7a" FOREIGN KEY ("codprj")
    REFERENCES "public"."project"("idprj")
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    NOT DEFERRABLE,


All "new" foreign keys have the same "template" (name seems to be fk+some random id and constraints are NO ACTION -anyhow conservative-). I didn't find any explanation all over internet and this forum about this issue.The application works fine except when you want to delete something, then the application complaints if you want to remove any object with the NO ACTION foreign keys...

Does anybody have ANY suggestions about what can be going on? May I have forgotten anything?
Thanks in advance and sorry for the weird and maybe stupid question

Cheers

w i l l y


Top
 Profile  
 
 Post subject: Re: @ManyToOne annotaion and fk (foreign key) duplication
PostPosted: Mon Dec 07, 2009 10:32 am 
Newbie

Joined: Tue Dec 16, 2008 6:59 am
Posts: 6
No proposals? So, I think this one can be a bug, as I am absolutely sure that, if nobody says nothing, the source code is ok and it is hibernate which is corrupting the database...

Anyway, sorry if I am annoying, any proposals are welcome or should open a bug?
Cheers

w i l l y


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.