Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing HibernateTemplate.find(...) with a String[]
    text
    copied!<p>I'm having troubles with HQL again :( </p> <p>My desired SQL is this: </p> <pre><code>select employee.idemployee as id, employee.age as age, employee.birthday as birthday, employee.firstName as firstName, employee.gender as gender, employee.lastName as lastName from employee employee inner join employee_skillgroups skillgroup1 on employee.idemployee=skillgroup1.idemployee inner join employee_skillgroups skillgroup2 on employee.idemployee=skillgroup.idemployee where skillgroup1.idskillgroup = 'Sprachen' and skillgroup.idskillgroup = 'SoftSkills' </code></pre> <p>But i just can't get HQL to generate me this ... "Sprachen" and "SoftSkills" are two string coming out of a String[] I'm giving the method as a parameter. The method currently looks like this:</p> <pre><code>public List&lt;Employee&gt; findEmployeeWithTwoSkillGroups(final String[] skillGroups) { return template.find("from Employee e join e.skillGroups as s where s in ?", Arrays.asList(skillGroups).toString ().substring(1, Arrays.asList(skillGroups).toString().length()-1)); } </code></pre> <p>I "cast" the array to a list, execute <code>toString()</code> on it (so i get "[Sprachen, SoftSkills]") and cut off the first and the last char (so i get "Sprachen, SoftSkills").<br> I guess the problem is that HQL generates "[...].idskillgroup in ('Sprachen, SoftSkills')", like it treats the two strings like ONE string ...<br> And i just can't get it to work like i want it to :/ </p> <p>Can someone please help me and give me a hint what to try/do next? :-) </p> <p>Greetz gilaras</p> <p>Simmilar question:</p> <h3><a href="https://stackoverflow.com/questions/2879161/hql-to-get-elements-that-possess-all-items-in-a-set">HQL to get elements that possess all items in a set</a></h3>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload