Hey,
I have a "tricky/legacy" problem that I want to sort out with hibernate ...
Each time I need to do something with with a text, I need to:
1) obtain table name from "book_index" table by "using book_ref" column
2) search for the entity in obtained table
Note that,
I know that I can solve this with direct queries,
I can not change the DB structure (it a legacy optimization try that's heavily used by other systems),
There are hundreds of "book_tablename_XXXX" like tables with same structure,
and finally I need to do search/CRUD operations across all the "book_tablename_XXXX" like tables.
Thanks for any ideas,
Dusan
Db structure:
CREATE TABLE `book_index` (
`book_ref` int(11) NOT NULL auto_increment,
`tablename` varchar(255) default NULL,
`date` date default NULL,
`active` int(11) default NULL,
PRIMARY KEY (`ref`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1
CREATE TABLE `book_tablename_XXXX` (
`text_ref` int(11) NOT NULL auto_increment,
`book_ref` int(11) NOT NULL,
`element_id` int(11) default NULL,
`record_id` int(11) default NULL,
`chapter_id` int(11) default NULL,
`chapter_order` int(11) default NULL,
PRIMARY KEY (`ref`),
KEY `element_id` (`element_id`),
KEY `record_id` (`record_id`),
KEY `chapter_id` (`chapter_id`),
KEY `chapter_order` (`chapter_order`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
book_index.book_ref = book_tablename_XXXX.book_ref
|