Hi team,
I am deleting bulk identities using refreshrule so that i can run in partition , however we are getting lazyinitalization exception : no procy session .I belive this is because the identity is fetched directly as the input from refresh task and deleted
Terminator t = new terminator(context);
terminator.deleteObject(identity):
Anything we can do to overcome lazy initialization error
1 Like
Hi @sureshbommareddy98 ,
if you use a queryOption to search the identites that you want delete try to add this command:
qo.setCloneResult(true);
@enistri_devo we are not using any query options.
Suresh Reddy:
lazy initialization
Hi Suresh,
The LazyInitializationException can occur in several scenarios, such as when you attempt to save a complete object and pass it to another part of your code, when there is an index mismatch, or due to issues with full-text search. These errors are common if you are not retrieving objects properly in your rules. Please share your code or more details.
@jainanimesh
import sailpoint.object.Identity;
import sailpoint.api.Terminator;
import sailpoint.api.SailPointContext;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import java.util.Iterator;
QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq(“name”, identity.getName()));
qo.setCloneResults(true); // Ensures result is detached from Hibernate session to avoid LazyInitializationException
Iterator iter = context.search(Identity.class, qo);
if (iter != null && iter.hasNext()) {
Identity fullIdentity = (Identity) iter.next();
if (fullIdentity != null && fullIdentity.getName() != null && fullIdentity.getName().startsWith("test_")) {
try {
Terminator terminator = new Terminator(context);
terminator.deleteObject(fullIdentity);
log.info("Deleted identity: " + fullIdentity.getName());
} catch (Exception e) {
log.error("Error deleting identity: " + fullIdentity.getName(), e);
}
}
}
This is the full code..we tried qo but not working .Please not that we are using refresh task to run this and this is the refresh rule
Suresh Reddy:
import sailpoint.object.Identity;
import sailpoint.api.Terminator;
import sailpoint.api.SailPointContext;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import java.util.Iterator;
QueryOptions qo = new QueryOptions();
qo.addFilter(Filter.eq(“name”, identity.getName()));
qo.setCloneResults(true); // Ensures result is detached from Hibernate session to avoid LazyInitializationException
Iterator iter = context.search(Identity.class, qo);
if (iter != null && iter.hasNext()) {
Identity fullIdentity = (Identity) iter.next();
if (fullIdentity != null && fullIdentity.getName() != null && fullIdentity.getName().startsWith("test_")) {
try {
Terminator terminator = new Terminator(context);
terminator.deleteObject(fullIdentity);
log.info("Deleted identity: " + fullIdentity.getName());
} catch (Exception e) {
log.error("Error deleting identity: " + fullIdentity.getName(), e);
}
}
}
Hello @sureshbommareddy98 ,
Could you please try below code?
import sailpoint.object.Identity;
import sailpoint.api.Terminator;
import sailpoint.api.SailPointContext;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import java.util.Iterator;
try {
Identity fullIdentity = (Identity) context.getObjectByName(Identity.class, identity.getName());
if (fullIdentity != null && fullIdentity.getName().startsWith("test_")) {
Terminator terminator = new Terminator(context);
terminator.deleteObject(fullIdentity);
log.info("Deleted identity: " + fullIdentity.getName());
}
} catch (Exception e) {
log.error("Error deleting identity: " + identity.getName(), e);
}
Can you try below code and see if it works??
import sailpoint.object.Identity;
import sailpoint.api.Terminator;
import sailpoint.api.SailPointContext;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
import java.util.Iterator;
try {
Identity fullIdentity = context.getObjectByName(Identity.class, identity.getName());
if (fullIdentity != null && fullIdentity.getName().startsWith("test_")) {
Terminator terminator = new Terminator(context);
terminator.deleteObject(fullIdentity);
context.commitTransaction();
log.error("Successfully deleted identity: " + fullIdentity.getName());
} else if (fullIdentity == null) {
log.error("Identity not found: " + identity.getName());
} else {
log.error("Identity does not match deletion criteria: " + fullIdentity.getName());
}
} catch (Exception e) {
log.error("Error deleting identity: " + identity.getName(), e);
}
Arpitha1
(Arpitha Halaguru Kunne Gowda)
July 24, 2025, 6:27am
9
Hi @sureshbommareddy98 As per my understanding, refresh task locks the identity during its execution and release it when the execution is over. So I suggest you to use rule runner task instead of refresh rule.
system
(system)
Closed
September 22, 2025, 6:27am
10
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.