HQL - get results from select with DOT seperator
select Employee.name as 'Employee.name'
I know that mysql allows that, is there any support fir that in hibernate.
This is the exeption that I get:org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hiber开发者_Go百科nate.hql.ast.QuerySyntaxException: unexpected token: . near line 1, column 42 [SELECT Affiliate.affiliateId as Affiliate.affiliateId , parent.userName as parent_userName , Affiliate.userName as Affiliate_userName , Affiliate.email as Affiliate_email , parent.affiliateId as parent_affiliateId , employee.firstName as employee_firstName , Affiliate.name as Affiliate_name FROM com.affiliates.hibernate.Affiliate Affiliate INNER JOIN Affiliate.employee as employee INNER JOIN Affiliate.parent as parent WHERE 1=1 AND Affiliate.employee='1']
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
Because of architecture problems, "_" instad of "." cant work for me.
ThanksI'm not sure if I understood your question correctly. You are thinking about writing queries. Hibernate supports its internal language called HQL. To be honest I prefer using JPA and hibernate as JPA implementation. In such case you have to write your queries with Criteria Api or using JPA query language. Query language is very convenient in conjunction with NamedQueries. So if you are using HQL or JPA, the easiest way is to select object with some name
SELECT e FROM Employee e WHERE p.name = ?1
The other possibility is using NativeQuery, here is an example.
精彩评论