Guest User

Untitled

a guest
Mar 17th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <hibernate-mapping>
  2. <class name="MutableEvent" table="events"
  3. mutable="true" dynamic-insert="true" dynamic-update="true">
  4.  
  5. <id name="id">
  6. <generator class="assigned" />
  7. </id>
  8. <property name="sourceTimestamp" />
  9. <property name="entryTimestamp" />
  10.  
  11. <map name="attributes" table="event_attribs"
  12. access="field" cascade="all">
  13. <key column="id" />
  14. <map-key type="string" column="key" />
  15. <element type="VariantHibernateType">
  16. <column name="value_type" not-null="false" />
  17. <column name="value_string" not-null="false" />
  18. <column name="value_integer" not-null="false" />
  19. <column name="value_double" not-null="false" />
  20. </element>
  21. </map>
  22.  
  23. </class>
  24. </hibernate-mapping>
  25.  
  26. ...
  27. m.getAttributes().put("other", new Variant("aValue"));
  28. this.storeEvent(MutableEvent.fromEvent(e));
  29. getSession().clear();
  30. MutableEvent m = (MutableEvent) getSession().get(MutableEvent.class, e.getId());
  31. Assert.assertNotNull(m.getAttributes().get("other"));
  32. Assert.assertEquals(new Variant("aValue"), m.getAttributes().get("other"));
  33. Assert.assertNull(m.getAttributes().get("other2"));
  34. getSession().clear();
  35. crit = DetachedCriteria.forClass(MutableEvent.class);
  36. crit.add(Restrictions.eq("attributes.other", new Variant("aValue")));
  37. List l = this.findByCriteria(crit);
  38. Assert.assertEquals(1, l.size());
  39.  
  40. crit.add(Restrictions.eq("attributes.other", new Variant("aValue")));
  41. List l = this.findByCriteria(crit);
  42.  
  43. List l = find("from MutableEvent M where M.attributes['other'] = ?", new Variant("aValue"));
  44.  
  45. ...
  46. private static final String[] PROPERTY_NAMES = { "type", "string", "integer", "double" };
  47.  
  48. public String[] getPropertyNames() {
  49. return PROPERTY_NAMES;
  50. }
  51. ...
Add Comment
Please, Sign In to add comment