-->
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.  [ 4 posts ] 
Author Message
 Post subject: Please help me with mapping
PostPosted: Thu Mar 11, 2004 9:37 pm 
Newbie

Joined: Mon Mar 08, 2004 8:56 pm
Posts: 5
Hi

I have the following schema, how do I map it to Hibernate (create *.hbm.xml file)?

Schema:

Code:
CREATE TABLE categories (
      cat_id           INT     NOT NULL,
      parent_cat_id    INT,
      PRIMARY KEY(cat_id),
      FOREIGN KEY cat_id REFERENCES categories(cat_id)
)

CREATE INDEX categories_parent_cat_id ON categories(parent_cat_id);

_________________
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 9:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The foreign keys not quite right. Anyway, I would suggest you try out Middlegen as it will generate mapping documents from your database directly. This way you can make changes and the see what the mapping document is - good way to learn quickly.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 10:11 pm 
Newbie

Joined: Mon Mar 08, 2004 8:56 pm
Posts: 5
Thanks for the suggestion, I actually used Middlegen to generate the mapping documnts for my SQL schema but somehow I don't think they look right.

The foreign key should be this:

Code:
FOREIGN KEY parent_cat_id REFERENCES categories(cat_id)

_________________
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 10:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
OK - so show me the mapping generated for the categories table. It should be fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.