Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.databases > #135
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail |
|---|---|
| From | "Matteo" <matteo@THRWHITE.remove-dii-this> |
| Subject | hibernate: mapping help |
| Message-ID | <g12f1t$aas$1@nnrp.ngi.it> (permalink) |
| X-Comment-To | comp.lang.java.databases |
| Newsgroups | comp.lang.java.databases |
| Content-Type | text/plain; charset=IBM437 |
| Content-Transfer-Encoding | 8bit |
| X-Gateway | time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] |
| Lines | 61 |
| Date | Wed, 27 Apr 2011 15:21:57 GMT |
| NNTP-Posting-Host | 96.60.20.240 |
| X-Complaints-To | news@tds.net |
| X-Trace | newsreading01.news.tds.net 1303917717 96.60.20.240 (Wed, 27 Apr 2011 10:21:57 CDT) |
| NNTP-Posting-Date | Wed, 27 Apr 2011 10:21:57 CDT |
| Organization | TDS.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.databases:135 |
Show key headers only | View raw
To: comp.lang.java.databases
Hello all,
I'm fairly new to hibernate, though I'm not new to ORM concepts.
I read the official h8 version 3 tutorial, as well as other articles and
examples out there.
Now the problem is that I can't figure out how the best way to map the
following tables:
table USERS (
`userID` int(11) unsigned NOT NULL auto_increment,
`name` varchar(255) NOT NULL,
`lastName` varchar(255) NOT NULL,
`nickname` varchar(20) NOT NULL,
PRIMARY KEY (`userID`),
KEY `nickname` (`nickname`) ---> indice
)
table FRIENDS (
`userID` int(11) unsigned NOT NULL default '0',
`friendID` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`userID`,`friendID`),
KEY `friendID` (`friendID`),
CONSTRAINT `friends_ibfk_1` FOREIGN KEY (`userID`) REFERENCES `users`
(`userID`),
CONSTRAINT `friends_ibfk_2` FOREIGN KEY (`friendID`) REFERENCES `users`
(`userID`)
)
table MESSAGES (
`messageID` int(11) unsigned NOT NULL auto_increment,
`from` int(11) unsigned NOT NULL,
`to` int(11) unsigned NOT NULL,
`message` varchar(4000) default NULL,
PRIMARY KEY (`messageID`),
KEY `from` (`from`),
KEY `to` (`to`),
CONSTRAINT `messages_ibfk_1` FOREIGN KEY (`from`) REFERENCES `users`
(`userID`),
CONSTRAINT `messages_ibfk_2` FOREIGN KEY (`to`) REFERENCES `users`
(`userID`)
)
I'm stuck with my implementation of the "friendship" relationship, as I
decided to define it with a directed-graph, thus user.A and user.B are
"friends" if and only if
( FRIENDS.userID = user.A ; FRIENDS.friendID = user.B ) AND (
FRIENDS.userID = user.B ; FRIENDS.friendID = user.A )
Hence, the composite-id (userID, friendID) of FRIENDS table.
As for MESSAGES table, both FROM and TO fields referentiate USERS.userID
(and I'm stuck with that too )
Thanks in advance !
Matteo
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.databases | Previous | Next — Next in thread | Find similar
hibernate: mapping help "Matteo" <matteo@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: hibernate: mapping he "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: hibernate: mapping he "Matteo" <matteo@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: hibernate: mapping he "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: hibernate: mapping he "Matteo" <matteo@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: hibernate: mapping he "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
csiph-web