use of com.xpn.xwiki.objects.BaseStringProperty in project xwiki-platform by xwiki.
the class BaseStringPropertyTest method testHashCode.
@Test
public void testHashCode() {
final String value = "test value";
BaseStringProperty p1 = new BaseStringProperty();
BaseStringProperty p2 = new BaseStringProperty();
p1.setValue(value);
p2.setValue(value);
Assert.assertEquals(p1.hashCode(), p2.hashCode());
}
use of com.xpn.xwiki.objects.BaseStringProperty in project xwiki-platform by xwiki.
the class XWikiHibernateStore method loadXWikiProperty.
private void loadXWikiProperty(PropertyInterface property, XWikiContext context, boolean bTransaction) throws XWikiException {
try {
if (bTransaction) {
checkHibernate(context);
bTransaction = beginTransaction(false, context);
}
Session session = getSession(context);
try {
session.load(property, (Serializable) property);
// safe to assume that a retrieved NULL value should actually be an empty string.
if (property instanceof BaseStringProperty) {
BaseStringProperty stringProperty = (BaseStringProperty) property;
if (stringProperty.getValue() == null) {
stringProperty.setValue("");
}
}
((BaseProperty) property).setValueDirty(false);
} catch (ObjectNotFoundException e) {
// Let's accept that there is no data in property tables but log it
this.logger.error("No data for property [{}] of object id [{}]", property.getName(), property.getId());
}
// Without this test ViewEditTest.testUpdateAdvanceObjectProp fails
if (property instanceof ListProperty) {
((ListProperty) property).getList();
}
if (bTransaction) {
endTransaction(context, false, false);
}
} catch (Exception e) {
BaseCollection obj = property.getObject();
Object[] args = { (obj != null) ? obj.getName() : "unknown", property.getName() };
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_LOADING_OBJECT, "Exception while loading property {1} of object {0}", e, args);
} finally {
try {
if (bTransaction) {
endTransaction(context, false, false);
}
} catch (Exception e) {
}
}
}
Aggregations