Commits

Anonymous committed 014f11a

Fixed the way Hibernate propertyset handles property set entries - not very efficient though!

git-svn-id: http://svn.opensymphony.com/svn/propertyset/trunk@93bf3cbcdd-1c1a-0410-9a68-d6f521e3fa7b

Comments (0)

Files changed (2)

 build.compiler=jikes
 
 name=propertyset
-version=1.3-dev
+version=1.3-dev-09Sep03

src/java/com/opensymphony/module/propertyset/hibernate/HibernatePropertySet.java

     }
 
     protected void setImpl(int type, String key, Object value) throws PropertyException {
-        PropertySetItem item = new PropertySetItem(entityName, entityId.longValue(), key);
+        PropertySetItem item = configProvider.getPropertySetDAO().findByKey(entityName, entityId, key);
+
+        if (item == null) {
+            System.out.println("Could not find item with key " + key + " hence creating new...");
+            item = new PropertySetItem(entityName, entityId.longValue(), key);
+        } else if (item.getType() != type) {
+            throw new PropertyException("Existing key '" + key + "' does not have matching type of " + type);
+        } else {
+            System.out.println("Found item with key " + key);
+        }
 
         switch (type) {
         case BOOLEAN: