Jasig/uPortal — pull request #479 by vertein (2014-12-05 14:13:24+00:00)
Title: UP-4233 Eliminates duplicate entries

There has been a weird error that pops up from time to time in our test and production tiers. We can never reliably reproduce them. We can also never quite pinpoint the error. Since the error isn't caught, the user is redirected to our generic portal error page. A simple refresh solves the problem.

Error:
`ERROR [ajp-bio-127.0.0.1-8009-exec-135-vertein] o.h.e.j.batch.internal.BatchingBatch 2014-12-01 12:21:56,401 - HHH000315: Exception executing batch [ORA-00001: unique constraint (MYQA40.SYS_C00171188) violated
]
ERROR [ajp-bio-127.0.0.1-8009-exec-135] o.j.p.web.ExceptionLoggingFilter 2014-12-01 12:21:56,530 - uPortal: unhandled exception 'ORA-00001: unique constraint (MYQA40.SYS_C00171188) violated
; SQL [n/a]; constraint [MYQA40.SYS_C00171188]; nested exception is org.hibernate.exception.ConstraintViolationException: ORA-00001: unique constraint (MYQA40.SYS_C00171188) violated
' for URL=/portal/Login?profile=bucky, user=vertein , from IP=128.104.17.46
org.springframework.dao.DataIntegrityViolationException: ORA-00001: unique constraint (MYQA40.SYS_C00171188) violated
; SQL [n/a]; constraint [MYQA40.SYS_C00171188]; nested exception is org.hibernate.exception.ConstraintViolationException: ORA-00001: unique constraint (MYQA40.SYS_C00171188) violated`

`	at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:643) ~[spring-orm-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:104) ~[spring-orm-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:516) ~[spring-orm-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754) ~[spring-tx-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723) ~[spring-tx-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:387) ~[spring-tx-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120) ~[spring-tx-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) ~[spring-aop-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) ~[spring-aop-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at com.sun.proxy.$Proxy437.registerUserProfileSelection(Unknown Source) ~[na:na]
at org.jasig.portal.layout.profile.StickyProfileMapperImpl.onApplicationEvent(StickyProfileMapperImpl.java:124) ~[StickyProfileMapperImpl.class:na]
at org.jasig.portal.layout.profile.StickyProfileMapperImpl.onApplicationEvent(StickyProfileMapperImpl.java:60) ~[StickyProfileMapperImpl.class:na]
`

Constraint (name, table, column_name):
`SYS_C00171188	UP_PROFILE_SELECTION	USERNAME`

I think sometimes it tries to insert twice. This just guards against the consequences of this.