Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.0.5
Mapping documents:hibernate annotation b2
Name and version of the database you are using:Oracle9
spring version:1.2.1
I use spring+hibernate3+annotation to develop my application, and I use Oracle9i. I use sequence as my @Id generator, I can run the test of annotation correctly, but in my application, it always can not run correctly, I put "Store" class in my application, it can not work either.
@Entity
@javax.persistence.SequenceGenerator(
name="SEQ_STORE",
sequenceName="my_sequence"
)
public class Store implements Serializable {
private Long id;
@Id(generate=GeneratorType.SEQUENCE, generator="SEQ_STORE")
public Long getId() {
return id;
}
public void setId(Long long1) {
id = long1;
}
}
Full stack trace of any exception that occurs:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [com/star/sms/dao/local-transcation-bean.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/star/sms/dao/local-transcation-bean.xml]: Initialization of bean failed; nested exception is org.hibernate.AnnotationException: Unknown Id.generator: SEQ_STORE
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/star/sms/dao/local-transcation-bean.xml]: Initialization of bean failed; nested exception is org.hibernate.AnnotationException: Unknown Id.generator: SEQ_STORE
org.hibernate.AnnotationException: Unknown Id.generator: SEQ_STORE
at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1107)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:715)
at org.hibernate.cfg.AnnotationBinder.processElementsOfAClass(AnnotationBinder.java:587)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:458)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:177)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:999)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:746)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:673)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:962)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:176)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:105)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:916)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:727)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:336)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
at org.springframework.test.AbstractSpringContextTests.loadContextLocations(AbstractSpringContextTests.java:113)
at org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadContextLocations(AbstractDependencyInjectionSpringContextTests.java:165)
at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:95)
at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:132)
at junit.framework.TestCase.runBare(TestCase.java:125)
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:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
I find in my application the annotation class can not get the javax.persistence.SequenceGenerator annotation, but in the test it can get it, why?
I need help, thank you