I believe in named queries you use ':column_name' instead of '?'
so instead of
<query name="getSecondProducts"><![CDATA[
from ProductGroup pb where pb.firstProductCode IN (?)]]>
</query>
try
<query name="getSecondProducts"><![CDATA[
from ProductGroup pb where pb.firstProductCode IN (
aram)]]>
</query>