Using custom properties in your own data models In the object class you wish to extend with dynamic properties, add the following 1. Imports import com.k_int.svc.custprops.datamodel.* 2. Implement.. In order to use the static helper methods, your class must implement the following interface: public interface DynamicPropertyObject { public Map getProperties(); } found in the datamodel package. 3. A map to contain the dynamic properties protected Map properties = new HashMap(); protected Set tags = new Set(); 4. getters and setters 4.1. For dynamic properties @ManyToMany(cascade = CascadeType.ALL) @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) @JoinColumn(name="MY_CLASS_FK") @JoinTable(name="MY_CLASS_PROP_VALUE") public Map getProperties() { return properties; } public void setProperties(Map properties) { this.properties = properties; } 4.2. For being able to tag objects @ManyToMany(cascade = CascadeType.ALL) @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) @JoinColumn(name="MY_CLASS_FK") @JoinTable(name="MY_CLASS_TAG") public Set getTags() { return tags; } public void setTags(Set tags) { this.tags = tags; } ** use a JoinTable name MY_CLASS_PROP_VALUE specific to your source class. This table will contain only custom properties for the ** specified class. 5. Hibernate annotated classes: Add the following to the spring definitions com.k_int.svc.custprops.datamodel.PropertyDefinitionHDO com.k_int.svc.custprops.datamodel.PropertyValueHDO com.k_int.svc.custprops.datamodel.LocalisedStringValueHDO com.k_int.svc.custprops.datamodel.SimpleStringValueHDO com.k_int.svc.custprops.datamodel.IdentifierValueHDO com.k_int.svc.custprops.datamodel.TagHDO 6. Programatically Adding and removing properties... Supposing we have a class called Resource containing only an identifieri (And implementing the DynamicPropertyObject interface, and using the steps above we have added a properties map to that resource. In order to set the dynamic simple property dublin core title to "Test Widget" we would need to do something like public static String DC_TITLE_PROP_URI = ""; Resource my_res = xxx; DynamicPropertyHelper.setSimpleProperty(session,my_res,DC_TITLE_PROP_URI,"Test Widget"); to Set a dynamic localised property (What a DC Title really should be); DynamicPropertyHelper.setLocalisedStringProperty(session,my_res,DC_TITLE_PROP_URI,java.util.Locale.UK,"Test Widget"); DynamicPropertyHelper.setLocalisedStringProperty(session,my_res,DC_TITLE_PROP_URI,java.util.Locale.FRANCE,"Le Widget du Test"); 7. Hibernate searching against dynamic properties 8. Future directions 8.1 Alternatives.. Currently, a resource may only have one value of a property, for example one DC.title, althoug it may have many language variants. We will need to add "Alternates" at some point for lists of values etc. 9. Using schemas to manage collections of dynamic factories @ManyToMany(cascade = CascadeType.ALL) @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}) @JoinColumn(name="MY_CLASS_FK") @JoinTable(name="MY_CLASS_SCHEMA") public Set getSchemas() { return schemas; } public void setSchemas(Set schemas) { this.schemas = schemas; }