1

I am new to Hibernate, I want to convert the following query to Hibernate coding.

SELECT a.RegisterCount, b.Id, b.Type, COUNT(a.RegisterCount) AS Expr1 
FROM Student AS a INNER JOIN 
Search_OldStudent AS b ON a.StudentId = b.Id 
GROUP BY a.RegisterCount, b.Id, b.Type

In that, there is no primary relation between a.StudentId and b.Id. And also there is no mapping between them.

Can you please suggest how to do this one?

Sampathkumar
  • 121
  • 1
  • 11
  • You can use session.createSQLQuery() to run this as a native SQL query if there are no additional constraints. By the way, if you are counting RegisterCount, the SQL query needs to be corrected. RegisterCount should not be added as a column in Select and Group By clause – Vin Dec 06 '15 at 13:09
  • It will add more constraints based on criteria. – Sampathkumar Dec 07 '15 at 02:10

0 Answers0