我用hibernate4+Spring3做测试遇到一个问题:当关系表中无主键是,不能入库处理。有关系表时候能处理。。什么原因。各位大侠麻烦看看:
不能处理日志:
2013-2-22 12:27:36 org.springframework.test.context.TestContextManager retrieveTestExecutionListeners
信息: @TestExecutionListeners is not present for class [class com.uc.common.dao.BaseDBDaoTest]: using defaults.
2013-2-22 12:27:36 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext_test.xml]
2013-2-22 12:27:37 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext_db.xml]
2013-2-22 12:27:37 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.GenericApplicationContext@12152e6: startup date [Fri Feb 22 12:27:37 CST 2013]; root of context hierarchy
2013-2-22 12:27:37 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
信息: Loading properties file from class path resource [jdbc.properties]
2013-2-22 12:27:37 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@958bb8: defining beans [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,testService,commonDao,dataSource,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,sessionFactory,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,txPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
2013-2-22 12:27:37 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2013-2-22 12:27:37 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.6.Final}
2013-2-22 12:27:37 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2013-2-22 12:27:37 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2013-2-22 12:27:38 org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2013-2-22 12:27:38 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2013-2-22 12:27:38 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
2013-2-22 12:27:38 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2013-2-22 12:27:38 org.hibernate.cache.spi.UpdateTimestampsCache <init>
INFO: HHH000250: Starting update timestamps cache at region: org.hibernate.cache.spi.UpdateTimestampsCache
2013-2-22 12:27:38 org.hibernate.cache.internal.StandardQueryCache <init>
INFO: HHH000248: Starting query cache at region: org.hibernate.cache.internal.StandardQueryCache
2013-2-22 12:27:39 org.springframework.test.context.transaction.TransactionalTestExecutionListener startNewTransaction
信息: Began transaction (1): transaction manager [org.springframework.jdbc.datasource.DataSourceTransactionManager@15a4523]; rollback [true]
com.uc.common.dao.impl.CommonDao@c360a5
com.uc.common.dao.impl.CommonDao@c360a5

2013-2-22 12:27:39 org.springframework.test.context.transaction.TransactionalTestExecutionListener endTransaction
信息: Rolled back transaction after test execution for test context [[TestContext@e16785 testClass = BaseDBDaoTest, testInstance = com.uc.common.dao.BaseDBDaoTest@5388b5, testMethod = testCreate@BaseDBDaoTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@3461d1 testClass = BaseDBDaoTest, locations = '{classpath:applicationContext_test.xml, classpath:applicationContext_db.xml}', classes = '{}', activeProfiles = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader']]]
2013-2-22 12:27:39 org.springframework.context.support.AbstractApplicationContext doClose
信息: Closing org.springframework.context.support.GenericApplicationContext@12152e6: startup date [Fri Feb 22 12:27:37 CST 2013]; root of context hierarchy正常的日志:
2013-2-22 12:29:21 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1be2d65: startup date [Fri Feb 22 12:29:21 CST 2013]; root of context hierarchy
2013-2-22 12:29:21 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext_test.xml]
2013-2-22 12:29:21 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext_db.xml]
2013-2-22 12:29:22 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
信息: Loading properties file from class path resource [jdbc.properties]
2013-2-22 12:29:22 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@16e1fb1: defining beans [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,testService,commonDao,dataSource,org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0,sessionFactory,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,txPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
2013-2-22 12:29:22 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2013-2-22 12:29:22 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.6.Final}
2013-2-22 12:29:22 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2013-2-22 12:29:22 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2013-2-22 12:29:23 org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2013-2-22 12:29:23 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2013-2-22 12:29:23 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
2013-2-22 12:29:23 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2013-2-22 12:29:23 org.hibernate.cache.spi.UpdateTimestampsCache <init>
INFO: HHH000250: Starting update timestamps cache at region: org.hibernate.cache.spi.UpdateTimestampsCache
2013-2-22 12:29:23 org.hibernate.cache.internal.StandardQueryCache <init>
INFO: HHH000248: Starting query cache at region: org.hibernate.cache.internal.StandardQueryCache
com.uc.common.dao.impl.CommonDao@6f947b
Hibernate: insert into test.test_tab (name) values (?)
com.uc.common.dao.impl.CommonDao@6f947b
hibernatespring