"left join Parents ps on (c.Parents_ID = ps.id)" +
"left join Set_Meal sm on (sm.ID = c.Set_Meal_ID)" +
"left join Picture p on (p.Children_ID = c.id)" +
"where ps.id =? GROUP by c.id";
/ / SQLQuery
SQLQuery sqlQuery = getSession (). createSQLQuery (springquerysql) ;/ /
sqlQuery.setParameter (0, 1);
List list = sqlQuery.list ();
Object [] obj = list.toArray ();
for (int i = 0; i
for (Object object: objects) {
System.out.print (object);
}
System.out.println ();
}
This code will be a problem, that is, the query field is the same, the data will be the same, and this how to solve it?
------ Solution ------------------------------------ --------
creatSqlQuery (sql) if there is the same field, such as r.id, c.id that hibernate c.id behind that will be used to cover r.id, that is no r query . id, which is hibernate existence of the bug, the graduates if they pay attention to ah, it is best to use nested queries, ... I've tried to avoid possible
------ Solution - ------------------------------------------
Why not use it during storage
------ For reference only -------------------------------------- -
field from the alias ah
------ For reference only ------------------------------ ---------
tried, no. Error.
------ For reference only -------------------------------------- -
[size = 30px] who gave an opinion ah! [/ Size]
------ For reference only ---------------------------------- -----
you put stickers sql tool directly executed on the client being given to try it?
should be resolved with an alias.
------ For reference only -------------------------------------- -
executed on the client tool sql no error.
------ For reference only -------------------------------------- -
did not quite understand what you mean, what is the same field, there is the same data?
------ For reference only -------------------------------------- -
of the query field in the table is the same, for example c.id, the id field of the table, sm.id, the id field is in another table.

------ For reference only ---------------------------------------
ah, it is worth a try!
------ For reference only ----------------------------------- ----
nested queries, ah. Worth a try, is a good way to solve method.
没有评论:
发表评论