Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <hibernate-mapping>
- <class name="MutableEvent" table="events"
- mutable="true" dynamic-insert="true" dynamic-update="true">
- <id name="id">
- <generator class="assigned" />
- </id>
- <property name="sourceTimestamp" />
- <property name="entryTimestamp" />
- <map name="attributes" table="event_attribs"
- access="field" cascade="all">
- <key column="id" />
- <map-key type="string" column="key" />
- <element type="VariantHibernateType">
- <column name="value_type" not-null="false" />
- <column name="value_string" not-null="false" />
- <column name="value_integer" not-null="false" />
- <column name="value_double" not-null="false" />
- </element>
- </map>
- </class>
- </hibernate-mapping>
- ...
- m.getAttributes().put("other", new Variant("aValue"));
- this.storeEvent(MutableEvent.fromEvent(e));
- getSession().clear();
- MutableEvent m = (MutableEvent) getSession().get(MutableEvent.class, e.getId());
- Assert.assertNotNull(m.getAttributes().get("other"));
- Assert.assertEquals(new Variant("aValue"), m.getAttributes().get("other"));
- Assert.assertNull(m.getAttributes().get("other2"));
- getSession().clear();
- crit = DetachedCriteria.forClass(MutableEvent.class);
- crit.add(Restrictions.eq("attributes.other", new Variant("aValue")));
- List l = this.findByCriteria(crit);
- Assert.assertEquals(1, l.size());
- crit.add(Restrictions.eq("attributes.other", new Variant("aValue")));
- List l = this.findByCriteria(crit);
- List l = find("from MutableEvent M where M.attributes['other'] = ?", new Variant("aValue"));
- ...
- private static final String[] PROPERTY_NAMES = { "type", "string", "integer", "double" };
- public String[] getPropertyNames() {
- return PROPERTY_NAMES;
- }
- ...
Add Comment
Please, Sign In to add comment