Hi All!!
My problem is that I want to do a simple inner join only with criteria or with minimun mapping elements.
More data:
I Have 2 entities:
movimiento and
categoriaCode:
mysql> describe movimiento;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| mo_id | bigint(20) | NO | PRI | NULL | auto_increment |
| mo_cl_id | bigint(20) | YES | | NULL | |
| mo_em_id | bigint(20) | YES | | NULL | |
| mo_tipo | varchar(255) | NO | | NULL | |
| mo_categoria_id | bigint(20) | NO | | NULL | | <--- categoria ID
| mo_importe | float | YES | | NULL | |
| mo_fecha | bigint(20) | NO | | NULL | |
| mo_detalle | varchar(500) | YES | | NULL | |
+-----------------+--------------+------+-----+---------+----------------+
mysql> describe categoria;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| cat_id | bigint(20) | NO | PRI | NULL | auto_increment |
| cat_nombre | varchar(255) | NO | | NULL | |
| cat_descripcion | varchar(255) | YES | | NULL | |
| cat_has_persona | varchar(255) | YES | | NULL | |
| cat_mov_tipo | varchar(255) | YES | | NULL | |
+-----------------+--------------+------+-----+---------+----------------+
I want to get a list of
movimiento when
mo_categoria_id (ID of
categoria) is a
categoria with (
categoria.)
cat_mov_tipo = 'Egreso'.
The simple query is this:
Code:
SELECT * FROM movimiento mov INNER JOIN categoria cat ON mov.mo_categoria_id=cat.id WHERE cat_mov_tipo = 'Egreso';
With criteria, I made a criteria of movimiento entities and I want to make a inner join with categoria to restrict cat_mov_tipo to 'Egreso'.
I don't know if this is a many-to-many, or one-to-many or who.
I don't put here my mapping configuration because I don't want to make a list with many-* on mapping files. So, if the only way is with mapping please tell me and I will put these xml.
Thanks in advance
Sorry About my english
Regards Juan Pablo