| 
					
						 Can someone tell me if I am missing something?  I have a class, see mapping below,  with a unique-key set on 2 columns.  My understanding is that I should not receive a Data Integrity violation if all the columns in the unique-key are themselves unique within the rest of the table.  Am I wrong in thinking this?  I am guessing that I should get a data integrity violation if both of those columns equal another set of those columns with the same values.  This doesn't seem to be the case.
 
 Could someone please explain this to me?
 
 Thanks for your help.
 
 Dan
 
 
 Hibernate version: 
 2.1.6
 
 Mapping documents:
 	<class 
 		name="PasswordHistory" 
 		table="password_history">
 
 		<id
 			name="id"
 			column="password_history_id"
 			unsaved-value="-1"
 			type="long">
 			<generator class="native" />
 		</id>
 
 		<version name="version"
 			column="version"
 			access="org.dmfrey.app.model.persistence.DirectSetAccessor" />
 
 		<component
 			name="passwordComponent"
 			class="org.dmfrey.app.model.components.PasswordComponent"
 			update="false">
 				
 			<property 
 				name="password" 
 				type="string">
 			
 				<column 
 					name="password" 
 					length="16" 
 					not-null="true" 
 					unique-key="unique_password_key" />
 			
 			</property>
 
 			<property
 				name="dateExpires"
 				type="java.util.Date">
 			
 				<column
 					name="date_expires"
 					not-null="true" />
 			
 			</property>
 
 			<property
 				name="expired"
 				type="yes_no">
 				
 				<column
 					name="expired"
 					not-null="true" />
 			
 			</property>
 
 		</component>
 
 		<many-to-one 
 			name="userInfo"
 			class="UserInfo"
 			update="false"
 			outer-join="false"
 			access="org.dmfrey.app.model.persistence.DirectSetAccessor"
 			foreign-key="fk1_user_info_id">
 			
 			<column 
 				name="user_info_id"
 				not-null="true"
 				unique-key="unique_password_key" />
 			
 		</many-to-one>
 
 	</class>
 
 Full stack trace of any exception that occurs:
 11:06:03,842  WARN JDBCExceptionReporter:net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:38) - SQL Error: 1062, SQLState: 23000
 11:06:03,845 ERROR JDBCExceptionReporter:net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:46) - Duplicate key or integrity constraint violation,  message from server: "Duplicate entry 'password-3' for key 2"
 11:06:03,846  WARN JDBCExceptionReporter:net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:38) - SQL Error: 1062, SQLState: 23000
 11:06:03,847 ERROR JDBCExceptionReporter:net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:46) - Duplicate key or integrity constraint violation,  message from server: "Duplicate entry 'password-3' for key 2"
 11:06:03,849 ERROR JDBCExceptionReporter:net.sf.hibernate.JDBCException.<init>(JDBCException.java:38) - could not insert: [org.dmfrey.app.model.PasswordHistory]
 java.sql.SQLException: Duplicate key or integrity constraint violation,  message from server: "Duplicate entry 'password-3' for key 2"
 	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1977)
 	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1163)
 	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272)
 	at com.mysql.jdbc.Connection.execSQL(Connection.java:2236)
 	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1741)
 	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1588)
 	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
 	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
 	at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
 	at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
 	at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
 	at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
 	at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
 	at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
 	at org.springframework.orm.hibernate.HibernateTemplate$11.doInHibernate(HibernateTemplate.java:325)
 	at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:200)
 	at org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:322)
 	at org.dmfrey.app.dao.impl.hibernate.PasswordHistoryDaoHibernateImpl.addPasswordHistory(PasswordHistoryDaoHibernateImpl.java:54)
 	at org.dmfrey.app.service.impl.UserServicesImpl.addPasswordHistory(UserServicesImpl.java:55)
 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 	at java.lang.reflect.Method.invoke(Unknown Source)
 	at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61)
 	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116)
 	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56)
 	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
 	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
 	at $Proxy1.addPasswordHistory(Unknown Source)
 	at org.dmfrey.app.bus.impl.UserManagerImpl.updateUserInfo(UserManagerImpl.java:102)
 	at org.dmfrey.app.bus.impl.UserManagerImpl.addPaymentProfile(UserManagerImpl.java:138)
 	at org.dmfrey.app.bus.UserManagerTest.testAddPaymentProfile(UserManagerTest.java:121)
 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 	at java.lang.reflect.Method.invoke(Unknown Source)
 	at junit.framework.TestCase.runTest(TestCase.java:154)
 	at junit.framework.TestCase.runBare(TestCase.java:127)
 	at junit.framework.TestResult$1.protect(TestResult.java:106)
 	at junit.framework.TestResult.runProtected(TestResult.java:124)
 	at junit.framework.TestResult.run(TestResult.java:109)
 	at junit.framework.TestCase.run(TestCase.java:118)
 	at junit.framework.TestSuite.runTest(TestSuite.java:208)
 	at junit.framework.TestSuite.run(TestSuite.java:203)
 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
 
 Name and version of the database you are using: 
 MySql 4.0.20-standard 
					
  
						
					 |