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: Linked table mapping?
PostPosted: Fri Jun 19, 2009 11:56 am 
Newbie

Joined: Tue Jun 19, 2007 2:11 pm
Posts: 9
Hello maybe someone can help me map this (or point me in the right direction), this is my table structure: (so in short, a dealership can have many cars)

CREATE TABLE `cars` (
`id` int(11) NOT NULL auto_increment,
`carType` varchar(11) default NULL,
`carModel` varchar(11) default NULL,
`carDescription` text(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;

CREATE TABLE `dealership` (
`mapid` int(11) NOT NULL auto_increment,
`dealerid` int(11) NOT NULL,
`carid` int (11) NOT NULL,
PRIMARY KEY (`mapid`)
) ENGINE=MyISAM;

How do I do hibernate mapping for an object "cars" if that object has a field called "dealerid" that comes from a different table. My sql query would look like this:


select id, c.carType, c.carModel, c.carDescription, d.dealderid from cars c, dealership d where c.id=d.carid and d.dealerid=224;

would hibernate query look like this?

String sql ="from cars c, dealership.d where d.dealderid=? ";
getHibernateTemplate().find(sql, new Integer(id));

Thanks in advance! I am still learning, any insight would be appreciated.


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.