-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: @Id (use sequence generator) has error
PostPosted: Wed Jun 15, 2005 9:38 pm 
Newbie

Joined: Fri Apr 01, 2005 1:05 am
Posts: 10
Location: China
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 9:08 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Man it would be really cool if you can spend some time on this problem. I know people experience this problem, but I can't reproduce it. Please take some time with your debugger to help me.
Here are some hints:
- try with ant instead of eclispe test launch
- put some debug breaks and check if the QequenceGenerator is actually seen
- be sure to set the latest version of the ejb3 apis (ie the one with hib ann distro)

Let me know. Don't hesitate to email me your progress
Thanks, this would be very helpful

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 2:51 am 
Newbie

Joined: Fri Apr 01, 2005 1:05 am
Posts: 10
Location: China
I have debug my code for a long time, I found in my application the SequenceGenerator annotation was not load in the function "parseAnnotations" of AnnotationParser class

Could someone give me some advice? Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 05, 2005 4:33 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 4:16 pm
Posts: 27
It is an strange error indeed. I had this error for a long time without finding an answer... but one day the problem was solved and I thought it was due to a fix...

Bruno


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 3:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Guys, the only reason I can see is that the @SequenceGenerator annotation is not annotated with @Retention(RUNTIME), can you check that?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 9:26 pm 
Newbie

Joined: Fri Apr 01, 2005 1:05 am
Posts: 10
Location: China
emmanuel wrote:
Guys, the only reason I can see is that the @SequenceGenerator annotation is not annotated with @Retention(RUNTIME), can you check that?


Thannk you for your hint.

I found the reason for this strange error. In my application, I use "jboss-ejb3x.jar" provided by jboss4. when test is run, I found application use @SequenceGenerator of "jboss-ejb3x.jar", not of "ejb-3.0-edr2.jar" provided by hibernate-annotation, when I remove "jboss-ejb3x.jar", the test is ok!!!

I hope what I found will help for the develop of hibernate-annotation, and I want to know if I can use both jars without conflict. Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 9:46 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hum, interesting.
This code is quite old now, can you try with the latest version of JBoss EJB3 (ie the beta1)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 10:17 pm 
Newbie

Joined: Fri Apr 01, 2005 1:05 am
Posts: 10
Location: China
emmanuel wrote:
hum, interesting.
This code is quite old now, can you try with the latest version of JBoss EJB3 (ie the beta1)


I have try JBoss EJB3 beta1, but some annotation is not supported,such as "@AssociationTable", I use "ejb3-persistence.jar"
Could you tell me the reason and solution? Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 12:18 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Some have been renamed by the expert group @AssociationTable is now @JoinTable.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.