Hi,
I was trying to create an attribute (pwreset boolean attribute) for a
user when it's not present but I can't do it.
I guess the assumption is that the user always has the necessary
attributes on creation because there is no
userMod.addAttributeToBeAdded?
What I tried is this:
UAttr attribute = user.getAttribute("pwreset");
if (attribute == null){
UserMod userMod=new UserMod();
AttributeMod attributeMod=new AttributeMod();
attributeMod.setSchema("pwreset");
attributeMod.addValueToBeAdded("true");
userMod.addAttributeToBeUpdated(attributeMod);
userDataBinder.update(user, userMod);
}
This gives me JPA errors:
InvalidStateException: Encountered unmanaged object
"org.apache.syncope.core.persistence.beans.user.UAttrValue@4f4db965"
in life cycle state unmanaged while cascading persistence via field
"org.apache.syncope.core.persistence.beans.user.UAttr.values<element:class
org.apache.syncope.core.persistence.beans.user.UAttrValue>" during
flush. However, this field does not allow cascade persist. You cannot
flush unmanaged objects or graphs that have persistent associations to
unmanaged objects.
best regards
Bob