1 2 Previous Next 15 Replies Latest reply on May 28, 2013 8:54 AM by uwe.risse

    Oracle custom sequence instead of select hibernate_sequence.

    jmichel

      Hi,

      I use Oracle 9i on windows 2000 and JBOSS 4 with EJB3 preview 4.

      I want to use the sequences of oracle so, i defined one MY_SEQ

      In a entity bean, i have:

      @Id(generate = GeneratorType.AUTO, generator = "sequence")
      @SequenceGenerator(name = "sequence", sequenceName = "hibernate_sequence")
      @Column(name = "COVT_ID", primaryKey=true)
      public int getId() {
      return m_id;
      }

      I have created a hibernate_sequence, then everything is OK.

      Now, let's use the MY_SEQ sequence

      @Id(generate = GeneratorType.AUTO, generator = "sequence")
      @SequenceGenerator(name = "sequence", sequenceName = "MY_SEQ")
      @Column(name = "COVT_ID", primaryKey=true)
      public int getId() {
      return m_id;
      }

      It is not running, i have the next message:

      2005-03-13 19:24:41,309 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not get next sequence value [select hibernate_sequence.nextval from dual]
      java.sql.SQLException: ORA-02289: sequence does not exist

      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
      at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
      at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
      at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
      at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:830)
      at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2391)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2672)
      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:296)
      at org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:75)
      at org.hibernate.event.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:84)
      at org.hibernate.event.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:171)
      at org.hibernate.event.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:31)
      at org.hibernate.event.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:160)
      at org.hibernate.event.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:25)
      at org.hibernate.event.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:64)
      at org.hibernate.impl.SessionImpl.save(SessionImpl.java:574)
      at org.jboss.ejb3.entity.EntityManagerImpl.persist(EntityManagerImpl.java:89)
      at com.be.o2.server.ejb.session.impl.CoverTypeDAOBean.create(CoverTypeDAOBean.java:68)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:77)
      at org.jboss.aspects.tx.TxSupport.invokeInOurTx(TxSupport.java:141)
      at org.jboss.aspects.tx.TxSupport$Required.serverInvoke(TxSupport.java:438)
      at org.jboss.aspects.tx.TxInterceptor.internalInvoke(TxInterceptor.java:112)
      at org.jboss.aspects.tx.TxInterceptor.invoke(TxInterceptor.java:60)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:72)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:36)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:80)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:90)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:66)
      at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:165)
      at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:102)
      at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:74)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:295)
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:169)
      at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:259)
      at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:321)
      at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:141)

      What can i do to use my custom sequence ????????

        • 1. Re: Oracle custom sequence instead of select hibernate_seque
          jmichel

          Nobody can answer ? I just want to use 1 sequence/table (technical primary key). Perhaps is there another way ? (auto increment)

          Thanks

          JMi

          • 2. Re: Oracle custom sequence instead of select hibernate_seque
            bill.burke

            Sorry, I am at a conference all week and I don't have access to a machine running Oracle to diagnos your problem.

            • 3. Re: Oracle custom sequence instead of select hibernate_seque
              jmichel

              no problemo, i start this week with hibernate_sequence then next week... ;-)))

              Thanks for your help

              JMi

              • 4. Re: Oracle custom sequence instead of select hibernate_seque
                deb

                Can you post the generated hibernate-mapping xml you're getting? (You can find this in the log files with the default configuration, I think, in JBOSS_HOME/server/all/log/server.log. I added a line to my server/all/conf/log4j.xml to log org.hibernate.cfg DEBUG events to a hibernate.log file to make it easier to extract, but I think it's in the server.log by default.)

                I don't see anything obvious in the code, but it's possible seeing what's getting spit out would make it clearer what's going on. One thing to check is whether you have more than one sequence generator annotation named "sequence". Looking through the code, that shouldn't be a problem in this particular instance because of the way it resolves sequence generators, but that's the only thing I can see offhand that could cause the behaviour your describing.

                • 5. Re: Oracle custom sequence instead of select hibernate_seque
                  jmichel

                  Here it is:

                  2005-03-24 12:08:19,312 DEBUG [org.hibernate.cfg.Configuration] Mapping XML:
                  <?xml version="1.0"?>
                  <!DOCTYPE hibernate-mapping PUBLIC
                  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
                  <hibernate-mapping>
                  <class name="com.be.o2.server.ejb.entity.CoverType"
                  table="COVER_TYPE"
                  entity-name="com.be.o2.server.ejb.entity.CoverType"
                  lazy="false">




                  <property name="name"
                  access="property" column="COVT_NAME"
                  not-null="false"
                  unique="false"
                  insert="true"
                  update="true"/>
                  <property name="code"
                  access="property" column="COVT_CD"
                  not-null="false"
                  unique="false"
                  insert="true"
                  update="true"/>
                  <property name="act"
                  access="property" column="COVT_ACT"
                  not-null="false"
                  unique="false"
                  insert="true"
                  update="true"/>
                  <property name="dencod"
                  access="property" column="COVT_DENCOD"
                  not-null="false"
                  unique="false"
                  insert="true"
                  update="true"/>
                  <property name="signed"
                  access="property" column="COVT_SIGNED"
                  not-null="false"
                  unique="false"
                  insert="true"
                  update="true"/>
                  <many-to-one name="SBranch"
                  access="property"
                  entity-name="com.be.o2.server.ejb.entity.SBranch"
                  cascade="none">
                  <column name="COVT_SBRA"
                  not-null="false"/>
                  </many-to-one>


                  <!-- other classes -->

                  </hibernate-mapping>

                  • 6. Re: Oracle custom sequence instead of select hibernate_seque
                    jmichel

                    Some part are missing in the previous post:

                    2005-03-24 12:08:19,312 DEBUG [org.hibernate.cfg.Configuration] Mapping XML:
                    
                    <?xml version="1.0"?>
                    <!DOCTYPE hibernate-mapping PUBLIC
                     "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
                    <hibernate-mapping>
                     <class name="com.be.o2.server.ejb.entity.CoverType"
                     table="COVER_TYPE"
                     entity-name="com.be.o2.server.ejb.entity.CoverType"
                     lazy="false">
                     <id name="id"
                     type="long"
                     column="COVT_ID"
                     access="property">
                     <generator class="native"/>
                     </id>
                     <version name="tcn"
                     column="COVT_TCN"
                     access="property"/>
                     <property name="name"
                     access="property" column="COVT_NAME"
                     not-null="false"
                     unique="false"
                     insert="true"
                     update="true"/>
                     <property name="code"
                     access="property" column="COVT_CD"
                     not-null="false"
                     unique="false"
                     insert="true"
                     update="true"/>
                     <property name="act"
                     access="property" column="COVT_ACT"
                     not-null="false"
                     unique="false"
                     insert="true"
                     update="true"/>
                     <property name="dencod"
                     access="property" column="COVT_DENCOD"
                     not-null="false"
                     unique="false"
                     insert="true"
                     update="true"/>
                     <property name="signed"
                     access="property" column="COVT_SIGNED"
                     not-null="false"
                     unique="false"
                     insert="true"
                     update="true"/>
                     <many-to-one name="SBranch"
                     access="property"
                     entity-name="com.be.o2.server.ejb.entity.SBranch"
                     cascade="none">
                     <column name="COVT_SBRA"
                     not-null="false"/>
                     </many-to-one>
                     </class>
                    
                     ...
                    
                    </hibernate-mapping>


                    • 7. Re: Oracle custom sequence instead of select hibernate_seque
                      deb

                      For the moment, use GeneratorType.SEQUENCE in your @Id declaration instead of GeneratorType.AUTO.

                      The spec is unclear (to me at least) on what should happen when you specify both a generator type and a generator in @Id and they aren't the same. I'll bug Bill about it. But the current implementation should do what you want if you explicitly use GeneratorType.SEQUENCE.

                      • 8. Re: Oracle custom sequence instead of select hibernate_seque
                        jmichel

                        Well,

                        If i use the next code:

                        @Id(generate = GeneratorType.SEQUENCE, generator = "mysequence")
                         @SequenceGenerator(name = "mysequence", sequenceName = "MY_SEQ")
                         //@SequenceGenerator(name = "mysequence", sequenceName = "hibernate_sequence")
                         @Column(name = "COVT_ID", primaryKey=true)
                         public long getId() {
                         return m_id;
                         }


                        i have the next error:

                        2005-03-27 21:39:26,895 ERROR [org.jboss.ejb3.Ejb3Module] Starting failed jboss.j2ee:service=EJB3,module=testjmd.ejb3
                        java.lang.RuntimeException: Unable to resolve SequenceGenerator: mysequence of property id
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleSequenceGenerator(EntityToHibernateXml.java:1381)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleId(EntityToHibernateXml.java:1326)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handlePrimaryKey(EntityToHibernateXml.java:1084)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleBasicClass(EntityToHibernateXml.java:1814)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleClass(EntityToHibernateXml.java:1431)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.convert(EntityToHibernateXml.java:134)
                         at org.jboss.ejb3.entity.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:144)
                         at org.jboss.ejb3.Ejb3Module.createHibernateSessionFactory(Ejb3Module.java:252)
                         at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:264)
                         at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
                         at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                         at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
                         at $Proxy0.start(Unknown Source)
                         at org.jboss.system.ServiceController.start(ServiceController.java:416)
                         at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy16.start(Unknown Source)
                         at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:166)
                         at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
                         at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                         at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                         at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy8.deploy(Unknown Source)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:463)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)
                        2005-03-27 21:39:28,518 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] process(): process the sitting node events in region: Regions--- fqn: /_default_/ maxNodes 1000000 TimeToIdleSeconds 300
                        2005-03-27 21:39:28,518 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] process(): current eviction queue size is 0
                        2005-03-27 21:39:28,528 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] processQueues(): process 0 node events
                        2005-03-27 21:39:28,528 DEBUG [org.jboss.cache.eviction.LRUAlgorithm] process(): trimming the nodes if ncessary ...
                        2005-03-27 21:39:28,528 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=testjmd.ejb3
                        java.lang.RuntimeException: Unable to resolve SequenceGenerator: mysequence of property id
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleSequenceGenerator(EntityToHibernateXml.java:1381)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleId(EntityToHibernateXml.java:1326)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handlePrimaryKey(EntityToHibernateXml.java:1084)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleBasicClass(EntityToHibernateXml.java:1814)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.handleClass(EntityToHibernateXml.java:1431)
                         at org.jboss.ejb3.entity.EntityToHibernateXml.convert(EntityToHibernateXml.java:134)
                         at org.jboss.ejb3.entity.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:144)
                         at org.jboss.ejb3.Ejb3Module.createHibernateSessionFactory(Ejb3Module.java:252)
                         at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:264)
                         at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
                         at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
                         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                         at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
                         at $Proxy0.start(Unknown Source)
                         at org.jboss.system.ServiceController.start(ServiceController.java:416)
                         at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy16.start(Unknown Source)
                         at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:166)
                         at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
                         at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
                         at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
                         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                         at java.lang.reflect.Method.invoke(Method.java:585)
                         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                         at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                         at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
                         at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                         at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                         at $Proxy8.deploy(Unknown Source)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
                         at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:463)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:215)
                         at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:194)


                        Who can help pme to resolve this ?

                        Thanks

                        JMi

                        • 9. Re: Oracle custom sequence instead of select hibernate_seque
                          deb

                          I'm not sure what's going on there. However...try putting the @SequenceGenerator annotation on the class instead of the property and see if that helps.

                          That error happens when it can't find the @SequenceGenerator annotation on the same property that has the @Id and then can't find it on the class either. I'm not sure why it's not finding it on the property, though.

                          • 10. Re: Oracle custom sequence instead of select hibernate_seque
                            deb

                            Also...I'd do a whole lot more digging but it currently looks like this is all moving over to Hibernate's EJB3 support in Preview 5. So I'm just doing my best to get you unstuck for the moment. Hope that's okay!

                            • 11. Re: Oracle custom sequence instead of select hibernate_seque
                              jmichel

                              Thanks Deb,

                              Unfortunately, i've also tried putting @SequenceGenerator annotation on the class. I've the same error.

                              There is perhaps a problem in my import clause (need to be checked) I use :

                              import javax.persistence.Column;
                              import javax.persistence.Entity;
                              import javax.persistence.GeneratorType;
                              import javax.persistence.Id;
                              import javax.persistence.JoinColumn;
                              import javax.persistence.ManyToOne;
                              import javax.persistence.SequenceGenerator;
                              import javax.persistence.Table;
                              import javax.persistence.Version;


                              but when you look for samples you usually find
                              import javax.ejb.SequenceGenerator;


                              Is there a difference ? There is a difference of package but are the class the same ? I've never found javax.ejb.SequenceGenerator ?

                              For the moment, i can continue with the AUTO flag and MY_SEQ (-> use hibernate_sequence) Later, i suppose that the bug will be corrected. When is the Preview 5 will be available ?

                              Thanks for your help

                              JMi

                              • 12. Re: Oracle custom sequence instead of select hibernate_seque
                                kkoster

                                Just to add to this thread. I am trying to do the exact same thing with PostgreSQL and have the same exceptions. There seems to be a failure of the resolution of the sequence generator even when the @SequenceGenerator annotation is placed at the class level:

                                Example:

                                @Entity(access = AccessType.PROPERTY)
                                @Remote
                                @Local
                                @org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true, optimisticLock = OptimisticLockType.VERSION)
                                @Table(schema = "risk", name = "common_lookup")//$NON-NLS-1$ //$NON-NLS-2$
                                @SequenceGenerator(name = "cl_sequence", sequenceName = "seq_common_lookup")//$NON-NLS-1$ //$NON-NLS-2$
                                @NamedQueries( {
                                @NamedQuery(name = "CommonLookup.selectType", queryString = "select cl from DefaultCommonLookup cl where cl.type = :type "), //$NON-NLS-1$ //$NON-NLS-2$
                                @NamedQuery(name = "CommonLookup.selectTypeId", queryString = "select cl from DefaultCommonLookup cl where cl.type = :type and cl.typeId = :typeId"), //$NON-NLS-1$ //$NON-NLS-2$
                                @NamedQuery(name = "CommonLookup.deleteTypeId", queryString = "delete from DefaultCommonLookup where type = :type and typeId = :typeId") })//$NON-NLS-1$ //$NON-NLS-2$
                                public class DefaultCommonLookup implements CommonLookup, Serializable {
                                private static final long serialVersionUID = 1L;

                                private Integer id;

                                private CommonLookupType type;

                                private String typeId;

                                private String data;

                                private int version = 0;

                                protected DefaultCommonLookup() {
                                }

                                public DefaultCommonLookup(CommonLookupType type, String typeId) {
                                this.type = type;
                                this.typeId = typeId;
                                }

                                @Basic
                                @Id(generate = GeneratorType.SEQUENCE, generator="cl_sequence")//$NON-NLS-1$
                                public Integer getId() {
                                return this.id;
                                }

                                public void setId(int id) {
                                this.id = id;
                                }

                                @Basic
                                @ManyToOne(targetEntity = "com.amaranth.lookup.DefaultCommonLookupType")//$NON-NLS-1$
                                @JoinColumn(name = "type")//$NON-NLS-1$
                                public CommonLookupType getType() {
                                return this.type;
                                }

                                protected void setType(CommonLookupType type) {
                                this.type = type;
                                }

                                @Basic
                                @Column(name = "type_id", nullable = false)//$NON-NLS-1$
                                public String getTypeId() {
                                return this.typeId;
                                }

                                protected void setTypeId(String typeId) {
                                this.typeId = typeId;
                                }

                                @Lob(type = LobType.CLOB)
                                @Column(name = "data")//$NON-NLS-1$
                                public String getData() {
                                return this.data;
                                }

                                public void setData(String data) {
                                this.data = data;
                                }

                                @Basic
                                @Version
                                @Column(name = "version", nullable = false)//$NON-NLS-1$
                                public int getVersion() {
                                return this.version;
                                }

                                protected void setVersion(int version) {
                                this.version = version;
                                }

                                }

                                Stack trace generated:

                                08:26:37,727 ERROR [AnnotationConfiguration] Could not compile the mapping annotations
                                org.hibernate.AnnotationException: Unknown Id.generator: cl_sequence
                                at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1113)
                                at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:699)
                                at org.hibernate.cfg.AnnotationBinder.processElementsOfAClass(AnnotationBinder.java:573)
                                at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:436)
                                at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:94)
                                at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClasses(AnnotationConfiguration.java:62)
                                at org.jboss.ejb3.entity.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:196)
                                at org.jboss.ejb3.Ejb3Module.createHibernateSessionFactory(Ejb3Module.java:231)
                                at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:263)
                                at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
                                at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
                                at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:585)
                                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
                                at $Proxy0.start(Unknown Source)
                                at org.jboss.system.ServiceController.start(ServiceController.java:416)
                                at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:585)
                                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                                at $Proxy16.start(Unknown Source)
                                at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:166)
                                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
                                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
                                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
                                at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:585)
                                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                                at $Proxy8.deploy(Unknown Source)
                                at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:305)
                                at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:481)
                                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
                                at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:277)
                                at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
                                at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:585)
                                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:891)
                                at $Proxy0.start(Unknown Source)
                                at org.jboss.system.ServiceController.start(ServiceController.java:416)
                                at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:585)
                                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
                                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                                at $Proxy4.start(Unknown Source)
                                at org.jboss.deployment.SARDeployer.start(SARDeployer.java:261)
                                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
                                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
                                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
                                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:722)
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                at java.lang.reflect.Method.invoke(Method.java:585)
                                at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
                                at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
                                at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:122)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                                at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:131)
                                at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
                                at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
                                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
                                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                                at $Proxy5.deploy(Unknown Source)
                                at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:413)
                                at org.jboss.system.server.ServerImpl.start(ServerImpl.java:310)
                                at org.jboss.Main.boot(Main.java:162)
                                at org.jboss.Main$1.run(Main.java:423)
                                at java.lang.Thread.run(Thread.java:595)

                                • 13. Re: Oracle custom sequence instead of select hibernate_seque

                                  Dit someone find a sollution to this problem. I've got exactly the same problem (when i remove the sequence the bean works fine):

                                  Configuration:
                                  Database: Oracle9
                                  Jboss4.02 (final)
                                  EJB3.0 Preview 5

                                  package mypackage;
                                  
                                  import javax.persistence.Entity;
                                  import javax.persistence.GeneratorType;
                                  import javax.persistence.SequenceGenerator;
                                  import javax.persistence.Table;
                                  import javax.persistence.Column;
                                  import javax.persistence.Id;
                                  
                                  
                                  @Entity
                                  @Table(name = "F_TALEN")
                                  @SequenceGenerator(name="seq", sequenceName="tal_seq")
                                  public class Language implements java.io.Serializable {
                                  
                                   private static final long serialVersionUID = 1L;
                                  
                                   private Long id;
                                   private String code;
                                   private String name;
                                   private String prlsCode;
                                   private Boolean defaultInd;
                                  
                                   public void setId(Long id) {
                                   this.id = id;
                                   }
                                  
                                   @Id(generate=GeneratorType.SEQUENCE, generator="seq")
                                   @Column(name="TAL_SEQ", primaryKey=true)
                                   public Long getId() {
                                   return this.id;
                                   }
                                  
                                   public void setCode(String code) {
                                   this.code = code;
                                   }
                                  
                                   @Column(name="TAL_CODE")
                                   public String getCode() {
                                   return this.code;
                                   }
                                  
                                   public void setName(String name) {
                                   this.name = name;
                                   }
                                  
                                   @Column(name="TAL_NAAM")
                                   public String getName() {
                                   return this.name;
                                   }
                                  
                                   public void setPrlsCode(String prlsCode) {
                                   this.prlsCode = prlsCode;
                                   }
                                  
                                   @Column(name="TAL_PLRS_CODE", nullable=true)
                                   public String getPrlsCode() {
                                   return this.prlsCode;
                                   }
                                  
                                   public void setDefault(Boolean defaultInd) {
                                   this.defaultInd = defaultInd;
                                   }
                                  
                                   @Column(name="TAL_IND_POPBANDEN", nullable=true)
                                   public Boolean getDefault() {
                                   return this.defaultInd;
                                   }
                                  }
                                  


                                  i've tried putting the @SequenceGenerator on method/class and package (package-info.java) level.

                                  I'm recieving the following message on deployment:

                                  12:33:18,123 ERROR [Ejb3Module] Starting failed jboss.j2ee:service=EJB3,module=ejb3.ejb3
                                  org.hibernate.AnnotationException: Unknown Id.generator: seq
                                   at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1113)
                                   at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:699)
                                   at org.hibernate.cfg.AnnotationBinder.processElementsOfAClass(AnnotationBinder.java:573)
                                   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:436)
                                   at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:94)
                                   at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClasses(AnnotationConfiguration.java:62)
                                  ...
                                  


                                  • 14. Re: Oracle custom sequence instead of select hibernate_seque

                                    I've olso reproduced the problem in de 2005-05-22 build of JBoss 5.0 Alpha ( JBoss [TheOne] 5.0.0alpha (build: CVSTag=HEAD date=200505222202) )

                                    I've oslo updated the Jiri entry. (EJBTHREE-139)

                                    1 2 Previous Next