Auto Increment in hibernate

Hello every one,
i have to write the code that used for diffrent databases like oracle,sql-server2000..
the problem has generated at the auto increment field...
the problem is as follows....
1) Identity field in sql-server but not in oracle because for oracle it uses index
i try like
<id name="id" column="id">
<generator class="increment"/>
</id>
it works fine for oracle but not for sql-server and ....
<id name="id" column="id">
<generator class="identity"/>
</id>
it works fine for sql-server but not for oracle because the id field is not null and it gives error that null field is not allowed ....
is there any other solution....then please help me
thanks
pandev84

hello frnd,
thanx for reply..
but how can i map these files in config file...
pls help..
thanx and regards,
Pandev84If you can't be bothered to spell out these words, and historically you also can't be bothered to answer questions or read documentation (hint: the answer to your question can be found here http://hibernate.org) why should people help you?

Similar Messages

  • Hibernate data insertion not working with oracle auto increment

    hi i have created a table and the id is set to auto increment by a sequence trigger pair
    when i manually giving value to id its working fine
    but when i tried without maually giving the id i am getting this error
    org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.pojo.Example
    at org.hibernate.id.Assigned.generate(Assigned.java:33)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
    at hibernetsample.Main.main(Main.java:30)

    >
    hi i have created a table and the id is set to auto increment by a sequence trigger pair
    when i manually giving value to id its working fine
    but when i tried without maually giving the id i am getting this error
    org.hibernate.id.Assigned
    >
    That is because you are using the hibernate 'assigned' generator which, by definition
    >
    lets the application to assign an identifier to the object before save() is called.
    This is the default strategy if no <generator> element is specified.
    >
    For your use case you can use the 'sequence' generator.
    The valid generator options and one way to use a sequence generator is shown in this article
    http://www.hibernate-training-guide.com/identifiers-generators.html
    The hibernate section of this article also uses a trigger with sequence generator
    http://blog.lishman.com/2009/02/auto-generated-primary-keys-in-oracle.html
    You should check the hibernate documention and tutorial for examples or search 'hibernate generator sequence example'

  • How to use auto-increment and search option for MS Access DB

    Dear All,
               I have configured our invoice in Adobe Livecycle and connected it to MS Acess 2007 as per http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/.
    All is working fine, I can insert, retrieve data from DB to invoice and vice versa.
    Now I want few things to be implemented on our invoice.
    When ever I open our invoice, it populate the first entry from DB, Is it possible to populate the last entry ?
    Auto increment invoice number from MS Access DB every time we open our invoice after save.
    How to implement search option from DB for invoice number ?
    Please let me know if someone can provide me help on my scenario, so that I can share more stuff related to invoice and DB.
    Look forward to hearing soon from experts and other team members.
    Thanks & Regards
    Riyad...

    As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
    CREATE SEQUENCE Test_Sequence ;
    CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
    ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
    INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ;

  • Trying to create cmp correctly(auto-increment);error while running

    I am using the latest versions of Jboss(4.0.5.GA) and Lomboz(R-3.2-200610201336) along with SQL Server 2005 and Microsoft's SQL Server 2005 JDBC driver.
    Lomboz used xdoclet to create the java files based on the SQL table but it did not put anything in the DoctorBean.java file telling it that the primary key was auto-incremented.
    Using the JSP files, I can retreive data out of the database fine so I know the connection and drivers are set up properly.
    Here is the error:
    09:16:46,815 WARN  [ServiceController] Problem starting service jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
    java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(Unknown Source)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:197)
        at org.jboss.mx.loading.UnifiedLoaderRepository3.loadClassFromClassLoader(UnifiedLoaderRepository3.java:277)
        at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:284)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:511)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:89)
        at org.jboss.mx.loading.LoaderRepositoryClassLoader.loadClass(LoaderRepositoryClassLoader.java:90)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:89)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityCommandMetaData.<init>(JDBCEntityCommandMetaData.java:73)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityMetaData.<init>(JDBCEntityMetaData.java:952)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMetaData.java:378)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:89)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:736)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:424)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:368)
        at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:172)
        at org.jboss.ejb.EjbModule.startService(EjbModule.java:414)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy25.start(Unknown Source)
        at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:662)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
        at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
        at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
        at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
        at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy26.start(Unknown Source)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy8.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy4.start(Unknown Source)
        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy5.deploy(Unknown Source)
        at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
        at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
        at org.jboss.Main.boot(Main.java:200)
        at org.jboss.Main$1.run(Main.java:490)
        at java.lang.Thread.run(Unknown Source)
    09:16:46,862 INFO  [EJBDeployer] Deployed: file:/C:/java/jboss-4.0.5.GA/server/default/deploy/MedicalEJB.jar
    09:16:46,987 INFO  [TomcatDeployer] deploy, ctxPath=/MedicalWeb, warUrl=.../tmp/deploy/tmp63256MedicalWeb-exp.war/
    09:16:47,315 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
    09:16:47,503 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
    --- MBeans waiting for other MBeans ---
    ObjectName: jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
      State: FAILED
      Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
      State: FAILED
      Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: 01Simple Doctor table:
    CREATE TABLE [dbo].[Doctors](
        [DoctorId] [int] IDENTITY(1,1) NOT NULL,
        [firstName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [lastName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    CONSTRAINT [PK_Doctors] PRIMARY KEY CLUSTERED
        [DoctorId] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]Most of DoctorBean.java was createded automatically with xdoclet, I created these items manually but with no success:
    * @jboss.entity-command
    * name="mssql-get-generated-keys"
    * @jboss.unknown-pk
    * class="java.lang.Integer"
    * column-name="doctorid"
    * field-name="doctorid"
    * jdbc-type="INTEGER"
    * sql-type="int"
    * auto-increment="true"DoctorBean.java:
    package com.bdintegrations.MedicalApp.EJB;
    import java.rmi.RemoteException;
    import javax.ejb.EJBException;
    import javax.ejb.EntityContext;
    import javax.ejb.RemoveException;
    * <!-- begin-xdoclet-definition -->
    * @ejb.bean name="Doctor"
    *    jndi-name="Doctor"
    *    type="CMP"
    *  primkey-field="doctorid"
    *  schema="DoctorSCHEMA"
    *  cmp-version="2.x"
    *  @ejb.persistence
    *   table-name="dbo.Doctors"
    * @ejb.finder
    *    query="SELECT OBJECT(a) FROM DoctorSCHEMA as a" 
    *    signature="java.util.Collection findAll()" 
    * @ejb.pk
    *  class="java.lang.Object"
    *  generate="false"
    * @jboss.entity-command
    * name="mssql-get-generated-keys"
    * @jboss.unknown-pk
    * class="java.lang.Integer"
    * column-name="doctorid"
    * field-name="doctorid"
    * jdbc-type="INTEGER"
    * sql-type="int"
    * auto-increment="true"
    * @jboss.persistence
    * datasource="java:/MSSQLDS"
    * datasource-mapping="MS SQLSERVER2005"
    * table-name="dbo.Doctors"
    * create-table="false" remove-table="false"
    * alter-table="false"
    * <!-- end-xdoclet-definition -->
    * @generated
    public abstract class DoctorBean implements javax.ejb.EntityBean {
         * <!-- begin-user-doc -->
         * The  ejbCreate method.
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.create-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public java.lang.Object ejbCreate(String firstName, String lastName) throws javax.ejb.CreateException {
            setFirstname(firstName);
            setLastname(lastName);
            return null;
            // end-user-code
         * <!-- begin-user-doc -->
         * The container invokes this method immediately after it calls ejbCreate.
         * <!-- end-user-doc -->
         * @generated
        public void ejbPostCreate() throws javax.ejb.CreateException {
            // begin-user-code
            // end-user-code
         * <!-- begin-user-doc -->
         * CMP Field doctorid
         * Returns the doctorid
         * @return the doctorid
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="DoctorId"
         *     jdbc-type="INTEGER"
         *     sql-type="int identity"
         *     read-only="false"
         * @ejb.pk-field
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.Integer getDoctorid();
         * <!-- begin-user-doc -->
         * Sets the doctorid
         * @param java.lang.Integer the new doctorid value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setDoctorid(java.lang.Integer doctorid);
         * <!-- begin-user-doc -->
         * CMP Field firstname
         * Returns the firstname
         * @return the firstname
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="firstName"
         *     jdbc-type="VARCHAR"
         *     sql-type="varchar"
         *     read-only="false"
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.String getFirstname();
         * <!-- begin-user-doc -->
         * Sets the firstname
         * @param java.lang.String the new firstname value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setFirstname(java.lang.String firstname);
         * <!-- begin-user-doc -->
         * CMP Field lastname
         * Returns the lastname
         * @return the lastname
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="lastName"
         *     jdbc-type="VARCHAR"
         *     sql-type="varchar"
         *     read-only="false"
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.String getLastname();
         * <!-- begin-user-doc -->
         * Sets the lastname
         * @param java.lang.String the new lastname value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setLastname(java.lang.String lastname);
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbActivate()
        public void ejbActivate() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbLoad()
        public void ejbLoad() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbPassivate()
        public void ejbPassivate() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbRemove()
        public void ejbRemove() throws RemoveException, EJBException,
                RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbStore()
        public void ejbStore() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
        public void setEntityContext(EntityContext arg0) throws EJBException,
                RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#unsetEntityContext()
        public void unsetEntityContext() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        public DoctorBean() {
            // TODO Auto-generated constructor stub
    }JSP client page snippet:
    <%
    DoctorHome home = DoctorUtil.getHome();
    Doctor doctor = home.create("Jon","Smith");
    %>
    <%=doctor.getDoctorid() %>thanks

    Nevermind.. no one bothered to inform the developer that the path to the collection AND the path to the directory that the collection is for are different on this other server.
    Fixed.

  • Auto increment with collection is not working

    I am using KODO 3.0 with MYSQL 4.0.16. I have created two JDO object as
    follows
    BankAccount contains a collection of Contacts object. My metadata looks
    like this
    <class name="BankAccount">
    <field name="contacts">
    <collection element-type="Contacts"/>
    <extension vendor-name="kodo" key="element-dependent"
    value="true"/>
    </field>
    </class>
    <class name="Contacts" objectid-class="Contacts$contactId">
    <field name="contactId" primary-key="true">
    <extension vendor-name="kodo" key="jdbc-auto-increment"
    value="true"/>
    </field>
    </class>
    There is no problem in the persisting of BankAccount object and adding
    Contacts to it, but Contacts collation is not retrieved along with parent
    object. In the database join table, the contact Id value it is always set
    to null.
    Things are working well with out contact id in Contacts.
    Can anyone help?
    Regards,
    dharmi

    Set the following property:
    kodo.jdbc.AutoIncrementConstraints: true
    Described here:
    http://www.solarmetric.com/Software/Documentation/latest/docs/ref_guide_pc_oid.html#ref_guide_pc_oid_pkgen_autoinc

  • How can i create an auto increment column

    Hello Everyone
    We are working on an EAM package which has an auto number facility but that is not meeting our requirement because some 10s and 100s of numbers keep on jumping based on the number of records the child table has.Means every record in my parent table will have some child records in another table which we call it a child table.The number of numbers that will be jumped each time will depend on the number of child records it has. Now we want to create a new column and generate a sequential unique number in my parent table with out linking it to its child table and use this number as a reference number. And we cant do that through our package customization. Can any one guide us if we can meet our requirement through oracle triggers or so.
    Thanks and Regards

    Hi,
    For "Auto-Increment" functionality - you can use a combination of a sequence and a trigger like so:
    create table roles ( role_id INT
                       , role_name VARCHAR2(30) NOT NULL
                       , creation_date DATE DEFAULT SYSDATE NOT NULL
                       , role_description VARCHAR2(255)
                       , CONSTRAINT roles_pk PRIMARY KEY (role_id)
                       , CONSTRAINT roles_uk1 UNIQUE (role_name)
    create sequence role_id_seq
    start with 1
    increment by 1
    nocache;
    CREATE OR REPLACE TRIGGER roles_pk_trig
    BEFORE
    insert on roles
    for each row
    begin
    IF :new.role_id IS NULL THEN
       SELECT role_id_seq.NEXTVAL
       INTO :new.role_id
       FROM dual;
    END IF;
    end;
    /Now any insert which leaves the "ROLE_ID" column NULL will have an auto-incremented value put in for that column. This is similar to an "Autonumber" column in Access.
    Hope this helps...
    Take care.

  • Auto Increment of Primary Field in Table Maintainance

    Hi,
    We want to give an Auto increment to the Primary Key, when ever the table is updated/inserted with a new record. How to get the value updated????
    For Eg,
    Table ZTEST Contains     MANDT, ITEM,   EBELN.
    It should have the values 800    001   000977
    And when the next record is created, the ITEM value should be Automatically get the value 002.. and so on for every Record.
    Pls do let me know if any other details is reqd.
    Thanx in Advance.
    Ajaz

    Dear Syed,
       You can do many things in table maintenance screen like validation of some field, making some field required or displayed etc.
       For auto increment you have to use Number-Ranges. FM NUMBER_GET_NEXT is helpful in this case.
       Where to write the code??? The Function-Group you have made. There will be includes. You can easily locate the place to write these codes.
       Caution point is that if you re-generate the table maintenance then all code will be gone.
    Regards,
    Deva.

  • HSQL DB Identity & Auto Increment

    We are trying to write records to this table:
    create table location_groups
    group_id identity
    ,jdoversion integer
    ,jdoclass varchar(255) default 'path.impl.LocationGroup' not null
    ,group_name varchar(100) not null
    ,group_parent_id integer
    Package.jdo is:
    <package name="path">
    <class name="LocationComponent">
    </class>
    </package>
    <package name="path.impl">
    <class name="LocationGroup" persistence-capable-superclass="path.LocationComponent">
    <!--<extension vendor-name="kodo" key="jdbc-field-map" value="one-one"/>-->
    <extension vendor-name="kodo" key="jdbc-auto-increment" value="true"/>
    <field name="children" persistence-modifier="persistent" default-fetch-group="true">
    <collection element-type="path.impl.Location"/>
    </field>
    </class>
    and package.mapping is:
    <package name="path">
    <class name="LocationComponent">
    <jdbc-class-map type="horizontal"/>
    </class>
    </package>
    <package name="path.impl">
    <class name="LocationGroup">
    <jdbc-class-map type="base" pk-column="GROUP_ID" table="LOCATION_GROUPS"/>
    <jdbc-version-ind type="version-number" column="JDOVERSION"/>
    <jdbc-class-ind type="in-class-name" column="JDOCLASS"/>
    <field name="path.LocationComponent.name">
    <jdbc-field-map type="value" column="GROUP_NAME"/>
    </field>
    <field name="children">
    <jdbc-field-map type="one-many" table="LOCATIONS" ref-column.GROUP_ID="GROUP_PARENT_ID"/>
    </field>
    </class>
    </package>
    I have tried all manner of configurations but the error remains the same:
    25-Apr-2008 16:05:24 com.ea.albt.infrastructure.persistence.jdo.JDODataStore BeginTransaction
    CONFIG: Starting transaction
    25-Apr-2008 16:05:24 com.ea.albt.infrastructure.persistence.jdo.JDODataStore updateObjects
    FINE: Updating object ALBT Loc1209135924484 (has not yet been persisted)
    25-Apr-2008 16:05:25 com.ea.albt.infrastructure.persistence.jdo.JDODataStore updateObjects
    WARNING: Failed to persist/update objectALBT Loc1209135924484
    kodo.util.FatalDataStoreException: Attempt to update the sequence table "JDO_SEQUENCE" failed. The sequence table is typically created when you run the mappingtool's refresh action on any datastore identity class. If you have not run the mappingtool but want to create the sequence table, run:
    java kodo.jdbc.schema.DBSequenceFactory -action add
    NestedThrowables:
    Why is Kodo trying to use the jdo_sequence table when we want it to use the HSQLdb identity field ?

    We have many users using single field identity and auto-increment together.

  • How to create auto increment value in my column using identity ?

    hi Team,
    I have an requirement where i create an auto increment value ,with my table column
    Create table Temp(
    DeptID int IDENTITY(1,1) PRIMARY KEY,
    Name varchar(50),
    Emailid nvarchar(50),
    Phone varchar(50)
    so this is my table structure ,Here my column name is
    Deptid here i need to creat an autoincrement value with today's date like below
    ex:STM0000120012015
        STM0000221012015
        STM0000322012015(Currentdate)
    .......................................... like this
    Here i need  only one column like identity column with the given incremental order,not more than one column
    so can u pls help me out any one.
    Thanks!

    Here the output came like this ,
    1 STM0000120150121
    2 STM0000220150121
    3 STM0000320150121
    4 STM0000420150121
    5 STM0000520150121
    6 STM0000620150121
    7 STM0000720150121
    8 STM0000820150121
    9 STM0000920150121
    10 STM00001020150121 --see this exceed length
    and here i dnt need to increment that Stm000010,Here my output will come like this, idnt need to increment my charcter size
    1 STM0000120150121
    2 STM0000220150121
    3 STM0000320150121
    4 STM0000420150121
    5 STM0000520150121
    6 STM0000620150121
    7 STM0000720150121
    8 STM0000820150121
    9 STM0000920150121
    10 STM0001020150121
    11    STM0001120150121
    12    STM0001220150121 
    so here i dont  need to increment my charcter length(16)
    The length should be STM(3char)+00001(5Charcters)+CurrentDateFormat,
    see the above suggested o/p
    so can u pls help me out Dimant

  • Auto-increment column increase performance in this case ?

    hi.
    i have the following facts to construct a set of tables.
    1. A Lecturer has an ID, Name and Date Joined
    2. A Classroom has an ID, Number Of Students
    3. A Lecturer can Teach in Many Classes
    4. A Class Can be lectured by Many Lecturers
    5. Each Lecture Date should be Stored in the DB.
    considering those facts, the following schema can be derived
    Lecturer
    (Lecturer_ID (PK), Lecturer_name, Date_Joined)
    Classroom
    (Classroom_ID (PK), NumOfStudents)
    Class_Lectures
    (Classroom_ID, Lecturer_ID (Composte PK), LectureDate)
    this is the normal practice we do.
    but what if the 3rd Table is constructed as follows ?
    Class_Lectures
    (LectureSeriesID (Auto-Increment, PK), Classroom_ID, Lecturer_ID (Composte Unique Key), LectureDate)
    if the 3rd Table is created as above, will there be any performance differences ? will the performance improve or get reduced ? any advantages / disadvantages of having that structure ?
    please do advise my any further best practices as well.
    Thanks and Regards

    http://technet.oracle.com:89/ubb/Forum88/HTML/000944.html
    null

  • Filename generation & Auto increment filename

    Hi,
    I would like my program to create a filename automatically, im using the "Filename Generator" which was available online, and also the "Unique Filename" VI. The way im using this is, I let the user select a path, and feed the path to the filename generator.vi. The output of that VI is the input to the Unique filename.vi .And the output of this VI is the root where the actual output file will be located. Im getting an error:
    Error 7 occurred at Open/Create/Replace File in Write Spreadsheet String.vi->Write To Spreadsheet File (string).vi->Write Header & Waveform Ref.vi->Main.vi
    I have attached my main VI, and the two above mentioned VIs. Also attached is the png file of the frames that contains these functions.
    Is there a way to get over this???
    Thank you,
    Eureka 
    Solved!
    Go to Solution.
    Attachments:
    Main.vi ‏111 KB
    Filename Generator.llb ‏117 KB
    Unique File Name.vi ‏35 KB

    I think i see what the problem is,
    This function creates a path, but not a file. So, the input given to the write to spreadsheet file is not actually the location of a file, i would say it is something virtual.
    If i use the Unique filename.vi alone and not the filename generator.vi, my program works fine, it does increment the filename, but, the user has to select the file every time.
    For instance, i have a txt file "Current". The VI generates a file path for "Current(1)" and writes the data in the new file.
    The next time, if the user fails to select "Current(1)" as the input path, and if the input path is just the same as the 1st run, it over writes the data in "Current(1)", as expected!
    The basic problem is, i need to avoid over writing data. Because, i read the waveforms from the file and it will me messed up big time.
    Is there a function to auto-increment filenames as we write them?
    Thank you,
    Eureka

  • Auto-increment  identity column through procedure in oracle 10g on windows

    Hi,
    I need identity primary key which should be auto increment before while inserting data into table.
    for this i had use sequence and then trigger to increment it.
    but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary key

    Hi,
    SNEHA RK wrote:
    Hi,
    I need identity primary key which should be auto increment before while inserting data into table.
    for this i had use sequence and then trigger to increment it.Right. Some database products have auto-increment columns, and they are really handy. Unfortunately, Oracle does not have auto-increment columns. A sequence is an auto-increment object, and it's the right way to automatically generate unique identifiers, but you need to explicity reference the sequence, either in you DML statements, or in a trigger that will automatically fire before a DML statement.
    but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary keyAre you saying that you need to increment the sequence, completely aside from INSERTing into the table?
    If so, just reference sequence_name.NEXTVAL wherever you want to. In PL/SQL, you can say
    SELECT  sequence_name.NEXTVAL
    INTO    number_variable
    FROM    dual;This works in any version of Oracle, but starting in Oracle 11, you also have the option of referencing te sequence without using dual, or any other table.
    I hope this answers your question.
    If not, post a complete script that people can run to re-create the problem and test their ideas.
    For example:
    -- Here are the table and the seqauence that I created:
    CREATE TABLE table_x ...
    CREATE SEQUENCE ...
    -- Here is the BEFORE INSERT trigger I wrote:
    CREATE OR REPLACE TRIGGER ...
    -- The trigger works exactly how I want it to in statements like this:
    INSERT INTO table_x ...
    -- So there are no problems (that I know of) with anything up to this point.
    -- Now I want to use the same sequence to ...
    -- so that when I execute a statement like this
    -- then the next time  I add a new row to the orginal table, like this
    INSERT INTO table_x ...
    -- then the contents of table_x should be ... because ...

  • Auto Incrementing in Text Field

    I imported a tab file and one column was the city, state and zip code. For some reason, the Zip code auto increments. It just so happened that the first cell was Durham, NC 27701. All subsequent cells incremented the Zip code by one, so the second cell became Durham, NC 27702. I have tried making the column a text field, and that did not work. I do not find any formula in the field, so am at a loss as to how to prevent the auto-incrementing from hapening.

    rha3675 wrote:
    Which Vallauris is your home city? Provence, or Pyrenees?
    None, Vallauris is not in Provence but in 'Provence-Alpes-Côte-d'Azur'
    At this time there is a great discussion about this name.
    Some wish to change it because they think that thge acronym PACA is not their cup of tea.
    Given that, inhabitants of "Provence" refuse to drop "Provence",
    inhabitants of "Alpes" refuse to drop "Alpes",
    inhabitants of "Cote d'Azur" refuse to drop "Cote d'Azur".
    My own advice is simply : don't use an acronym !
    I searched heavily and din't find a Vallauris in Pyrénées.
    The only town whose name approach is :
    I just found :
    Valaurie
    Code postal: 26230
    Département: Drôme
    Région: Rhône-Alpes
    Vallauris sits between Cannes and Antibes.
    Yvan KOENIG (VALLAURIS, France) mardi 2 février 2010 17:45:21

  • Not authorised to have auto increment trigger on server

    Hello all. I need a few triggers set up, I have no problems setting up sequences and "before insert" triggers on my home PC setup but on the live server where I study I do not have the authority.
    I got around this before by using Forms so I set the trigger at Form level.
    I am developing a DB system that will at some stage in the future use Forms, but for now it will use HTML forms via a web browser.
    I need to have the primary key for user accessible tables to be auto incremented (on the server where I study), but how can get around the authority issue ??
    Any ideas are extremely welcome !!

    Hello all - yeah I am on a course. I too have no idea why they will not allow the students to create triggers at table level.
    The 1st system I developed at home I had auto incremented primary keys. It was using Oracle Forms as the front end. Because I am the admin on my home setup I didn't have any problems.
    When I went to the course site to implement exactly what I had at home (which worked 100% properly) inserting data via the forms was not working. I had no idea why. the lecturer guy took a look at my code and told me its because of the trigger, I do not have authority to create triggers on the server.
    "create or replace trigger cust_trg
    before insert on customer
    for each row
    begin
    select cust_seq.nextval into :new.cust_id
    from dual;
    end;"
    The above code works fine on my home PC. I used Pre Insert triggers on the block on the Form instead to get around the problem (I presumed it was because they wanted us to learn Forms more thoroughly).
    This next project does not involve forms but they will not change my access rights so I don't have a clue as to how to get an auto incremented primary key whilst using a HTML form.
    Kevin

  • The great SQL ColdFusion Auto Increment fiasco

    Hello all and thanks in advance for your help. I am
    working on an Insert Record page using ColdFusion 7, Dreamweaver 8
    and SQL Server 2000.
    The SQL DB has a table called Articles. The table Articles
    has a Primary Key field called ArticleID which is set to a type of
    "Numeric, Identity:Yes, Seed:1, Increment:1" and no Null allowed.
    I am getting an error message of:
    Variable
    PAGENUM_RSARTICLES is undefined.
    The error occurred in
    D:\Inetpub\guardyourself\backend\article_add.cfm: line 107
    105 : </cfquery>
    106 : <cfset MaxRows_rsArticles=10>
    107 : <cfset
    StartRow_rsArticles=Min((PageNum_rsArticles-1)*MaxRows_rsArticles+1,Max(rsArticles.Record Count,1))>
    So. How do I get the ArticleID field on the CF page to see
    what the last SQL row shows for an ArticleID... and then add one?
    I'm stumped. Any help you can provide would be greatly appreciated.
    Code for the page in question is as follows or you can just go to :
    http://www.guardyourself.org/backend/article_add.cfm

    I think there may be a little confusion about what a
    uniqueidentifier field type is. You're talking about two separate
    concepts as though they are one. To create a field which
    "auto-increments" in SQL Server, you need to create the field as a
    numeric type and then specify that the field is an identity field
    (you can also specify the start and increment values). On insert,
    SQL Server will assign values to this field based on the criteria
    you supplied. If you do this, you will typically want to omit the
    value and field from your ColdFusion inserts as you have described
    below.
    What you have done instead is to create the field as a
    uniqueidentifier which requires a GUID value to be stored there.
    You cannot "increment" a GUID. The GUID for new records must either
    be generated by SQL Server (using the newID() function) or
    externally in your code. You must pass this value on insert from
    ColdFusion.
    Hope this helps.
    Adam

Maybe you are looking for

  • Recover a zip file on mac?

    Sorry for the somewhat off topic question. I have a very important zip file that no longer exists on an FTP site. I let it sit too long before checking to make sure it was legit and it was corrupted. The file size is about 200 meg and I know there is

  • ADF Page execution

    Hi , I am new to ADF. I am trying to run the simple page in ADF. I am using Jdev 11.1.1. I created a JSF page under view controller and i am running the page. I am not using any data base controls. The page is deployed in Default server (i.e weblogic

  • Manage Substitutes in Solution Manager 7.1 SP4

    Hello, I made configuration according to pdf: http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/a026ba4e-d5fa-2d10-4995-8e516dd372b0 It works fine in tx. SOLMAN_WORKCENTER but it is possibility to working at web browser ITSM Solution Manager 7.1

  • Shorten Clips In The Timeline And Shorten The Project Duration

    When I shorten a clip in the timeline by dragging on one end a blank space appears. I know this is in order to keep the project the same duration but I do not want this. I am happen for the project duration to reduce in accordance with my timeline cl

  • Excel VBA Macros - Hide/UnHide Cells

    I am tyring to create macro that will hide cells depending on what data is in the cell. I am currently using this and it is working but I want to be able to use 2 or more as I have different cells that I want hidden depending on what is entered into