Hibernate @OneToMany throws MySQLSyntaxErrorException: You have an error in your SQL syntax
I try to retrieve a list with some fields from Contact and also a list of phones. For this, I'm using a query to Contacts; Also I've created a DTO with only that fields that I need. The query is: final StringBuilder query = new StringBuilder(); query.append("SELECT new com.tim.core.dto.client.MinimalContactDTO(c.id, c.version, c.name, c.title, c.email, c.createdDate, c.phones) " + " from CONTACT c "); query.append("where "); query.append("( c.localRecordStatus IS NULL "); query.append("OR c.localRecordStatus IN (:openStatusList) "); query.append(" ) "); return em.createQuery(query.toString(),