-->
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: Primary key und foreign key definieren?
PostPosted: Thu Sep 20, 2007 7:37 am 
Newbie

Joined: Wed Sep 19, 2007 3:40 am
Posts: 2
Hallo,

wie definiere ich am besten einen fremdschlüssel der gleichzeitig primary key ist.

SchemaA.TabelleA hat primary key 'id'. Dieser soll gleichzeitig ein Fremdschlüssel auf SchemaB.TabelleA sein. Bin Neuling in SQL. Vielleicht darf man das gar nicht so definieren.
Bisher habe ich Nhibernate so verwendet:

Code:
<class name="SchemaA.TabelleA,MyTest" schema="SchemaA" table="schemaA" lazy="true">
    <id name="Id" column="id" type="Int32" unsaved-value="0">
      <generator class="assigned"/>
    </id>
    <many-to-one name="Id" column="id" class="SchemaA.TabelleB,MyTest" />
    <property column="name1"... />
  </class>


Mir ist klar, dass es so nicht funktionieren kann, da id einmal vom typ integer ist und einmal vom Typ TabelleB. Wie macht man dies am besten bei Nhibernate? Nur int anlegen und wie lege ich den fremschlüssel dann an?

Vielen Dank für tipps,

Patrick[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 4:12 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Der darf nur einmal gesetzt werden.
Schau mal nach "property-ref" bzw. "foreign" in der Dokumentation.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


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.