Hi buddies!
I have a web application and I have used those frameworks: Spring Hibernate Struts
Until now I had no relationships between tables but I would like to add a Many-To-One relationship in my web application. I'm using annotations and I have found some examples where I could see how implement it and I think that is well implemented.
I have a Category table whose fields are: Id (Integer) Name (String)
I have a GreenPoint table whose fields are: Id (Integer) City (String) Location (String) Adress (String) etc.
I have a GreenPointHasCategory table (linked table) whose fields are: id (Integer) greenpoint_id (it is a FK to GreenPoint id table) category_id (it is a FK to Category id table)
The question is the following: I have a form where an user can do a search by city or location but I also would like to do a search by category.
I know how I should do it in MySQL:
SELECT DISTINCT p.* FROM greenpoint as p, category as c, greenpoint_has_category as pc WHERE p.id = pc.greenpoint_id AND c.id = pc.category_id AND c.id = 4; In this case the category selected is the number 4.
But I don't know how can do an SQL sentence from GreenPointDaoHibernate and in this class call to Category and GreenPointHasCategory tables.
I don't know if I have explained me.
Any advice?
Thanks in advance!
If you need some code, just tell me! ;)
-Samuel- PS: Sorry for my english!
|