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