-->
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: Unidirectional associations with join tables (one-to-many)
PostPosted: Thu Mar 02, 2006 4:10 pm 
Newbie

Joined: Thu Mar 02, 2006 2:50 pm
Posts: 3
Well, I'm trying to implement unidirectional associations with join tables (one-to-many)

and getting erorr: System.Xml.Schema.XmlSchemaException: The 'unique' attribute is not declared.


since nHibernate reference chapter for unidirectional associations with join tables is not ready yet, I'm following common Hibernate reference for Java...
http://www.hibernate.org/hib_docs/v3/re ... l-join-12m
my mappings are almost exaclty the same:


XML mappings:

Code:
<class name="Test1.DUser,Test1" table="Users">
    <id name="UId" column="Id" type="int">
        <generator class="increment"/>
    </id>
   
      <property name="UName" column="Name"  type="String" length="40"/>
      <property name="UPassword" column="Pass"  type="String" length="20"/>
      <property name="UEmail" column="Email" type="String" length="40"/>
      <bag name="Emails" table="UserEmails">
       <key column="uID"/>
       <many-to-many column="ID" unique="true" class="Test1.UDirectory,Test1"/>
      </bag>
</class>


<class name="Test1.UDirectory,Test1" table="Dirs">
    <id name="DId" column="ID" type="int">
      <generator class="increment"/>
    </id>
    <property name="DName"  column="Name"   type="String" length="40"/>
    <property name="DLevel"  column="Level"  type="String" length="5"/>
    <property name="DParent"  column="Parent" type="String" length="5"/>
    <property name="UserId"     column="uID"    type="String" length="20"/>
  </class>



tables:

Code:
CREATE TABLE Users (
  ID nvarchar(20) NOT NULL  PRIMARY KEY,
  Name    nvarchar(40) default NULL,
  Pass    nvarchar(20) default NULL,
  Email nvarchar(40) default NULL,   
);


CREATE TABLE UserEmails (
  uID nvarchar(20) NOT NULL,          
  ID  nvarchar(20) NOT NULL primary key
);



CREATE TABLE Dirs (
  ID nvarchar(20) NOT NULL  PRIMARY KEY,
  Name    nvarchar(40) default NULL,
  Level nvarchar(5) default NULL,
  Parent nvarchar(5) default NULL,
  uID nvarchar(20) NOT NULL    
);




So, any ideas what unique attribute is not declared yet ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 4:33 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I think that unique for many-to-many is a Hibernate 3 feature. NHibernate only supports Hibernate 2.1 features.


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.