I have class Data, which contains my data, and class DataArchive that merely extends Data and contains nothing new. The only other change in DataArchive is an xdoclet marking mapping it to table DATA_ARCHIVE rather than DATA. My generated hbm.xml files end up being exactly the same except for the class name and table mapping name. However, when I try to do a Criteria search on Data.class with setMaxResults(5), it ends up giving me 5 results from the DATA table and 5 results from the DATA_ARCHIVE table (totally unexpected!). What I really want is to get the records from the DATA table first, and then if the limit is not reached, get the additional records from the DATA_ARCHIVE table. Is there a good way to do this? I'm somewhat wary of joins and unions because both tables will end up containing millions of records.
|