After searching over SO and hibernate docs I can't seem to find an answer for my questions(?). Every answer will be helpful for my problem, here it is.
I'm new to hibernate hbm.xml mapping files and my task is to output really big and complex queries that involves many tables, joins, counts and so on, with hbm.xml.
The HQL code is already done and running, and I have no access to it unless asking for new functions / methods, I can print all the tables using and hbm.xml mapping for each one, for example:
table1.hbm.xml:
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC '-//Hibernate/Hibernate Mapping DTD 3.0//EN' 'http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd'>
<hibernate-mapping>
<class name="authorization.model.table1" table="table1">
<composite-id>
<key-property name="Id" type="long" column="Id" />
<key-property name="Sys" type="string" column="Sys" />
</composite-id>
<property name="Cod" column="Cod" type="long" />
</class>
</hibernate-mapping>
that combined with my output code will print a column with id,sys and cod from table1 which is on DB. So far so good, I can print many to one too, combining columns from two different tables and print the description for example (column from table2 and PK from table 1).
The problem is when I need to join tables and print more complex queries using various tables and relations between them.
My question is: can I use the already done SQL query and generate the hbm file?
Do I need an hbm file to left join tables for example, and then call that file (result).
I'm sorry for the vague question, I am confused too.
I can post one of the queries I want/need to map, having all the tables mapped.
Ok i've found a solution, for someone else having this problem, i recomend you to create a view into data base from all complex queryes, and then mapping the result columns and types from that view into hibernate hbm.xml.
With that there's no need of complex cardinalities into .hbm files.