I don't know if I'm going to be able to explain it property but I'm going to try it.
Basically I've got projects, that they have inside galleries. Each gallery has media associated sorted.
I've got 4 tables, witch ones I can't change the structure, because there is a big system behind them.
This is the database structure:
CREATE TABLE `_projects` (
`ID` int(11) NOT NULL auto_increment,
`active` int(11) default '1',
`projectName` text,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
---------------------------------------------------------
CREATE TABLE `_galleriesType` (
`ID` int(11) default NULL,
`description` varchar(252) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
---------------------------------------------------------
CREATE TABLE `_siteMedia` (
`ID` int(11) NOT NULL auto_increment,
`source` text,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
------------------------------------------------------------
CREATE TABLE `_projectsPagesMediaLookup` (
`ID` int(11) NOT NULL auto_increment,
`FK_siteMediaID` int(11) default NULL,
`FK_projectsPagesID` int(11) default NULL,
`FK_galleryID` int(11) default NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
I would like to get my object formatted on this way:
Project
-id
-description
-galleries
-----------gallery 1
----------------------------media1
----------------------------media2
----------------------------media3
-----------gallery 2
----------------------------media4
----------------------------media5
----------------------------media6
And I wouldn't like to add a new gallery row each time I add a new project, because the only reason why galleries it's there is because I want to get the media separate in groups, but it shouldn't be a big problem to add galleries for each project.
The problem I've got is that I don't know how to create the list with galleries in the Project.hbm.xml, basically I don't know if it's a composite component or a many to any or any other relation.
Any idea of how can I create the project.hbm.xmll??
Thanks.
|