Mit HQL nach values in Map suchen?

Hallo,

ich möchte in der Map attributes z.B. alle Objekte (Article) herausfiltern die als uncastedValue "Hund" haben.

-> Später möchte ich noch den Schritt gehen in referencedValue zu suchen. Vorrangig geht es mir jetzt aber darum die gefilterten Objekte zu bekommen.

Code:
<hibernate-mapping>

    <class name="bo.Article" table="ZZZZ_ARTICLE">

        <id name="id" type="long" unsaved-value="-1">
            <column name="ID" not-null="true"/>
            <generator class="native"/>
        </id>

        <property name="name" type="string">
            <column name="NAME" not-null="true"/>
        </property>

		<map name="attributes" table="ZZZZ_ARTICLE_DYNAMIC" inverse="true" cascade="all-delete-orphan">
            <key column="ARTICLE_ID"/>
            <map-key type="string" column="DYNAMIC_ATTRIBUTE_NAME"/>
            <one-to-many class="staticbo.ArticleDynamicAttribute"/>
        </map>

    </class>

</hibernate-mapping>

Code:
<hibernate-mapping>

	<class name="staticbo.ArticleDynamicAttribute" table="ZZZZ_ARTICLE_DYNAMIC">
	
		<id name="id" type="long" unsaved-value="-1">
            <column name="ID" not-null="true"/>
            <generator class="native"/>
        </id>
        
        <property name="uncastedValue" type="string">
        	<column name="UNCASTED_VALUE" not-null="false"/>
        </property>

        <property name="valueClass" type="class">
        	<column name="VALUE_CLASS" not-null="false"/>
        </property>

		<many-to-one name="referencedValue" column="ATTRIBUTE_META_VALUE_ID" class="wilken.openshop.dynamic.attribute.AttributeMetaValue" cascade="none"/>

		<many-to-one name="attributeMeta" column="ATTRIBUTE_META_ID" class="wilken.openshop.dynamic.attribute.AttributeMeta" cascade="none"/>

	</class>

</hibernate-mapping>

Danke
 
Ja, das ist nicht ganz das was ich suche.

Zum einen wird folgendes erzeugt. Ich möchte aber die Map quasi durchlaufen und alle value nach einem Treffer untersuchen. Leider kenn ich die key erst zur Laufzeit.

Code:
select
  distinct person0_.ID as ID8_,
  person0_.NAME as NAME8_,
  person0_.ATTRIBUTE_META_SET_ID as ATTRIBUTE3_8_ 
 from
  ZZZZ_PERSON person0_,
  ZZZZ_PERSON_DYNAMIC attributes1_ 
 where
  person0_.ID=attributes1_.PERSON_ID 
  and attributes1_.DYNAMIC_ATTRIBUTE_NAME = 'attribute1' 
  and attributes1_.ID='Romsl'

sowas sollte ich haben können :confused:

Code:
select
  distinct person0_.ID as ID8_,
  person0_.NAME as NAME8_,
  person0_.ATTRIBUTE_META_SET_ID as ATTRIBUTE3_8_ 
 from
  ZZZZ_PERSON person0_,
  ZZZZ_PERSON_DYNAMIC attributes1_ 
 where
  person0_.ID=attributes1_.PERSON_ID 
  and attributes1_.UNCASTED_VALUE = 'Romsl'

Danke
 
Ich komm hiermit z.B. nur auf die keys der Map

Code:
select distinct person from bo.Person person where 'attribute0' in indices(person.attributes)

nicht aber auf die values der Map.
 
Ok, zum ersten Teil "es wurde Licht"...

Code:
select distinct person from bo.Person as person join person.attributes attribute where attribute.uncastedValue = 'Romsl'

Gruß

Romsl
 

Neue Beiträge

Zurück