Hi Trish,

Trish wrote:
Hi
Im new to appfuse and trying to implement manay to many relation for
Employee Project tables, the created model classes as follows
At a quick glance, your entities look OK to me.
 public List<Employee> getByProject(Long projectId, Long periodId) {
        return getHibernateTemplate().find("from Employee where employeeId in " 
+
                                "(select employeeId from EmployeesProject " +
                                "where projectId=?"+ projectId+")");
}
However, you're mixing styles with your search expression and that won't help you at all. You're trying to use a parameter placeholder (the ? in "where projectId=?") but then you're appending the value to your query string instead of setting the parameter value. The last line of your search expression should either be:

"where projectId=" + projectId + ")");

or

"where projectId=?)", projectId, Hibernate.LONG);

I believe the second approach is considered safer as the persistence mechanism looks after security problems like "SQL Injection" for you. It is also likely to perform better.

To learn more about Hibernate, you're better off examining Hibernate documentation, starting somewhere like here: http://www.hibernate.org/5.html

I don't think that the AppFuse project will have a lot of information about using Hibernate as that task really belongs to the Hibernate project.

HTH,

Rob Hills
Waikiki, Western Australia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to