I'm using Hibernate 3.3 on my Struts 2 web application. In my case, I've two tables TABLE_A
, TABLE_B
which are not mapped with any relationship. But there will be a column implicitly one-to-many between TABLE_B
to TABLE_A
. So while querying on it, I've to inner join on those those tables. I could do it by running HQL with inner join. My sample HQL query is as follows:
TABLE_A->TableA.java,TableA.hbm.xml
TABLE_B->TableB.java,TableB.hbm.xml
select tabA from com.test.db.TableA as tabA,com.test.db.TableB as tabB where (tabA.tableACommonCol=tabB.tableBCommonCol and tabB.tableBConstraint='value')
In the above query I've to put sorting, searching on different types of columns like String
, Timestamp
, Long
...
Now what I'm trying to do is a common class which has the columns which are to be used to while querying or the references of these classes, and use that with criteria.
If it is possible, how should I configure the mapped class and hbm.xml
files of TABLE_A
and TABLE_B
. If not, how can I achieve this?