Bug 1039924

Summary: Cannot delete users with OracleDB because of "ORA-02292: integrity constraint (XXXXX) violated"
Product: [JBoss] JBoss Enterprise Portal Platform 6 Reporter: Peter Palaga <ppalaga>
Component: PortalAssignee: mposolda
Status: VERIFIED --- QA Contact: Tomas Kyjovsky <tkyjovsk>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1.1CC: cnakamura, epp-bugs, mposolda, tkonishi, tkyjovsk
Target Milestone: DR02   
Target Release: 6.1.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
It was discovered that the way the user.language value was stored in Oracle databases caused issues when trying to delete a user record. Oracle expects empty strings to be saved with null, and the portal left the value of user.language blank until a user selected their preferred locale. The fix populates the user.language field with null for new users created by the portal administrator, which corrects the originally reported issue. Existing users may still have issues with deletion because the corresponding JBID_IO_ATTR_TEXT_VALUES Oracle table values contains incorrect user attributes. Customers in this situation must manually clean the table by executing the following SQL query against the database: delete from JBID_IO_ATTR_TEXT_VALUES where ATTR_VALUE is null;
Story Points: ---
Clone Of: 1038482 Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1038482    
Bug Blocks:    

Description Peter Palaga 2013-12-10 10:32:44 UTC
+++ This bug was initially created as a clone of Bug #1038482 +++

Description of problem:
Cannot delete users with OracleDB because of "ORA-02292: integrity constraint (XXXXX) violated - child record found"[1]. The child record is in the JBID_IO_ATTR table[2].

[1]
2013-12-05 15:40:25,846 DEBUG [org.hibernate.util.JDBCExceptionReporter] (http-127.0.0.1-8080-1) Could not execute JDBC batch update [delete from jbid_io where ID=?]
java.sql.BatchUpdateException: ORA-02292: integrity constraint (ORAUSER.FK4DC61D7E992317F0) violated - child record found

    at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10345)
    at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:230)
    at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeBatch(CachedPreparedStatement.java:476)
    at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:774)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:171)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1030)
    at sun.reflect.GeneratedMethodAccessor346.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:343)
    at com.sun.proxy.$Proxy266.flush(Unknown Source)
    at org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreImpl.removeIdentityObject(HibernateIdentityStoreImpl.java:622)
    at org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository.removeIdentityObject(WrapperIdentityStoreRepository.java:158)
    at org.picketlink.idm.impl.api.session.managers.PersistenceManagerImpl.removeUser(PersistenceManagerImpl.java:231)
    at org.exoplatform.services.organization.idm.UserDAOImpl.removeUser(UserDAOImpl.java:268)

[2]
JBID_IO_ATTR:

ATTRIBUTE_ID	423
IDENTITY_OBJECT_ID	413
NAME	user.language
ATTRIBUTE_TYPE	text
BIN_VALUE_ID	NULL


How reproducible: 100 %

Steps to Reproduce:
1. Change gatein-idm and gatein-jcr to use OracleDB.
2. Start EPP
3. Login as root
4. Create a user
5. Delete the user

Actual results:

Cannot delete the user. 

Expected results:
The user is deleted.

Additional info:
Some user attributes are deleted, so this process is not transactional.

--- Additional comment from JBoss JIRA Server on 2013-12-09 17:47:24 EST ---

Marek Posolda <mposolda> made a comment on jira GTNPORTAL-3341

The issue is caused by the fact that Oracle doesn't know empty strings and it treats them as null.
I added the fix on GateIn side. The fix will always use value null for value of UserProfile attribute if it's empty string. It's quite dirty fix IMO, but it works for all scenarios I tested (The empty string is used in GateIn just for attribute "user.language" of UserProfile as this attribute is in UI represented by comboBox. Other UserProfile attributes represented by text-fields are already send to UserProfileHandler with value null if they are empty).

Comment 1 Peter Palaga 2013-12-10 10:33:51 UTC
Fixed in upstream for 6.1.1.

Comment 3 Tomas Kyjovsky 2014-01-02 17:30:35 UTC
Verified with 6.1.1.DR2.

Comment 4 mposolda 2014-02-06 16:22:50 UTC
I've already proposed "Doc text" in cloned issue https://bugzilla.redhat.com/show_bug.cgi?id=1038482 so I am just copy-pasting here.