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.
|