-->
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.  [ 1 post ] 
Author Message
 Post subject: Fremdschlüssel id benötigt trotz Hibernate Objekt
PostPosted: Thu Mar 05, 2009 8:00 am 
Newbie

Joined: Mon Mar 02, 2009 6:42 am
Posts: 6
Hibernate version:
Hibernate 3

Name and version of the database you are using:
Oracle 10g

Problem:
Hallo,

ich habe zwei Tabellen:

Item:
Code:
CREATE TABLE "Test"."ITEM" (
    "ID" NUMBER NOT NULL,
    "RECONSTRUCTION_ID" NUMBER,
    "TYPE" VARCHAR2(45),
   
    CONSTRAINT "PK_ITEM" PRIMARY KEY("ID")
    CONSTRAINT "FK_RID" FOREIGN KEY("RECONSTRUCTION_ID")
    REFERENCES "Test"."RECONSTRUCTION"("ID")
    )


Dort wurde eine entsprechende Sequence angelegt welche die ID hochzählt.

ImageData:

Code:
CREATE TABLE "Test"."IMAGE_DATA" (
    "ITEM_ID" NUMBER NOT NULL,
    "IMAGE_ID"  NUMBER,
    "ATTRIBUTE" VARCHAR2(100 byte),
   
    CONSTRAINT "PK_IMGDAT" PRIMARY KEY("ITEM_ID")
    CONSTRAINT "FK_ITEM" FOREIGN KEY("ITEM_ID")
    REFERENCES "Test"."ITEM"("ID")
    CONSTRAINT "FK_IMG" FOREIGN KEY("IMAGE_ID")
    REFERENCES "Test"."IMAGE"("ID")
    ) 


Hibernate erstellt mir den folgenden Konstruktor für ImageData
Code:
    /** minimal constructor */
    public ImageData(int itemId, Item item) {
        this.itemId = itemId;
        this.item = item;
    }


Wie kann ich Hibernate sagen, dass die dort verlangte itemId bereits in Item enthalten ist? Ich hätte den folgenden Konstruktor erwartet:

Code:
    /** minimal constructor */
    public ImageData(Item item) {
        this.item = item;
    }


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

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.