Well the underlying SQL looks like the following:
String queryString = "from Category c where c.typeString = :type and c.description.titles[:code] = :title";
Query q = session.createQuery(queryString);
q.setText("type", CategoryType.ALPHABETICAL.getName());
q.setText("title", title);
q.setText("code", "de");
Category c = q.uniqueResult();
SQL:
====
select category0_.ENTITY_ID as ENTITY_ID, category0_.PARENT_CATEGORY as PARENT_C8_, category0_.CATEGORY_TYPE as CATEGORY9_, category0_.CREATION_DATE as CREATION3_, category0_.MODIFICATION_DATE as MODIFICA4_, category0_.LAST_EDITOR_ID as LAST_EDI5_, category0_.DEFAULT_LANGUAGE_ID as DEFAULT_6_, category0_.STATUS as STATUS from ENTITY category0_, TITLES titles1_ where category0_.TYPE='CATEGORY' and ((category0_.CATEGORY_TYPE=? )and(titles1_.TITLE=? and category0_.ENTITY_ID=titles1_.ENTITY_ID and titles1_.ISO_LANG_CODE = ?))
The return value of the query is null. If I construct the query like this:
String queryString = "from Category c where c.typeString = :type and c.description.titles['de'] = :title";
Query q = session.createQuery(queryString);
q.setText("type", CategoryType.ALPHABETICAL.getName());
q.setText("title", title);
Category c = q.uniqueResult();
everything works fine. On q.uniqueResults() plenty of SQL-queries are generated, much to many to post in here. Reason for this is, that there are several Map-mappings and relationships queried for. Here is the underlying SQL:
select category0_.ENTITY_ID as ENTITY_ID, category0_.PARENT_CATEGORY as PARENT_C8_, category0_.CATEGORY_TYPE as CATEGORY9_, category0_.CREATION_DATE as CREATION3_, category0_.MODIFICATION_DATE as MODIFICA4_, category0_.LAST_EDITOR_ID as LAST_EDI5_, category0_.DEFAULT_LANGUAGE_ID as DEFAULT_6_, category0_.STATUS as STATUS from ENTITY category0_, TITLES titles1_ where category0_.TYPE='CATEGORY' and ((category0_.CATEGORY_TYPE=? )and(titles1_.TITLE=? and category0_.ENTITY_ID=titles1_.ENTITY_ID and titles1_.ISO_LANG_CODE = 'de'))
The queries are looking quite the same - as expected. Perhaps there is a problem with inserting "'" for the map key when replacing the named parameters?
Christian
|