Code:
INFO : org.hibernate.tool.hbm2ddl.SchemaUpdate - Running hbm2ddl schema update
INFO : org.hibernate.tool.hbm2ddl.SchemaUpdate - fetching database metadata
INFO : org.hibernate.tool.hbm2ddl.SchemaUpdate - updating schema
INFO : org.hibernate.validator.engine.resolver.DefaultTraversableResolver - Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - table found: crm4.person
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - columns: [id, username, email, lastname, firstname, password, companyname, ispoweruser]
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - foreign keys: [fk8e488775db099ed4, fk8e48877545c5d646]
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - indexes: [fk8e488775db099ed4, username, fk8e48877545c5d646, primary]
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - table found: crm4.personrole
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - columns: [id, emailpermission, name]
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - foreign keys: []
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - indexes: [primary]
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - table found: crm4.team
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - columns: [id, name]
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - foreign keys: []
INFO : org.hibernate.tool.hbm2ddl.TableMetadata - indexes: [primary]
INFO : org.hibernate.tool.hbm2ddl.SchemaUpdate - schema update complete
INFO : org.springframework.test.context.transaction.TransactionalTestExecutionListener - Began transaction (1): transaction manager [org.springframework.orm.jpa.JpaTransactionManager@1ef2fe6]; rollback [true]
Hibernate: insert into Team (name) values (?)
***10
Hibernate: insert into Person (companyName, email, firstName, isPowerUser, lastName, password, team_id, userName) values (?, ?, ?, ?, ?, ?, ?, ?)
WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: 1452, SQLState: 23000
ERROR: org.hibernate.util.JDBCExceptionReporter - Cannot add or update a child row: a foreign key constraint fails (`crm4`.`person`, CONSTRAINT `FK8E48877545C5D646` FOREIGN KEY (`id`) REFERENCES `team` (`id`))
INFO : org.springframework.test.context.transaction.TransactionalTestExecutionListener - Rolled back transaction after test execution for test context [[TestContext@182dc66 testClass = PersonControllerTest, locations = array<String>['classpath:/test-context.xml'], testInstance = org.grassfield.crm4.controller.PersonControllerTest@53c1d4, testMethod = shouldReturnPersonListView@PersonControllerTest, testException = javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert: [org.grassfield.crm4.model.Person]]]
INFO : org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@2589c3: startup date [Thu Nov 29 10:20:49 GMT 2012]; root of context hierarchy
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@c03da9: defining beans [placeholderConfig,entityManagerFactory,dataSource,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,dataInitializer,homeController,personController,personDao,personRoleDao,teamDao,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor]; root of factory hierarchy
INFO : org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'acme'
INFO : org.hibernate.impl.SessionFactoryImpl - closing
The new Team object is saved, I could get the ID as 10. But it fails when it updates the Person record.