I found the problem, It is necessary to modify the description of the class
"HighLowSequence". 
The jdbc-type of fields "MAX_KEY" must be of type "BIGINT".

<!-- The OJB HIGH/LOW SequenceManagerTable -->
   <class-descriptor
          class="org.apache.ojb.broker.util.sequence.HighLowSequence"
          table="OJB_HL_SEQ"
   >
      <field-descriptor
         name="tableName"
         column="TABLENAME"
         jdbc-type="VARCHAR"
         primarykey="true"
      />
      <field-descriptor
         name="fieldName"
         column="FIELDNAME"
         jdbc-type="VARCHAR"
         primarykey="true"
      />
      <field-descriptor
         name="maxKey"
         column="MAX_KEY"
         jdbc-type="BIGINT"
      />
      <field-descriptor
         name="grabSize"
         column="GRAB_SIZE"
         jdbc-type="INTEGER"
      />
      <field-descriptor
         name="version"
         column="VERSION"
         jdbc-type="INTEGER"
         locking="true"
      />
   </class-descriptor>

-----Message d'origine-----
De : PICARD Jérôme 
Envoyé : vendredi 4 avril 2003 11:06
À : 'OJB Users List'
Objet : RE: Problem with the assignement of primary keys.


Hi,


Hi,

I modified the jdbc-type to BIGINT, and I have always the same problem. 
I suppose that the problem comes from the classe
"SequenceManagerHighLowImpl" 

I use the revision 1.17 of the "SequenceManagerHighLowImpl".

-----Message d'origine-----
De : BURT, RANDALL (CONTRACTOR) [mailto:[EMAIL PROTECTED]
Envoyé : jeudi 3 avril 2003 18:34
À : OJB Users List
Objet : RE: Problem with the assignement of primary keys.


<class-descriptor
          class="Customer"
          table="CUSTOMER">
          
      <field-descriptor id="1"
         name="id"
         column="CUS_ID"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="true"
      />

and

public class Customer {
        protected long id;

don't match. You either need to set the jdbc-type to BIGINT in your
class-descriptor or change id to int in class Customer. What type is CUS_ID
in your database?

-----Original Message-----
From: PICARD Jérôme [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 9:50 AM
To: '[EMAIL PROTECTED]'
Subject: Problem with the assignement of primary keys.


Hello,

I have just recovered the last version of OJB.

This my problem :

        When I store the object "Customer" I obtain the following exception.

        This exception occurs on assignement of the primary key.

Can you help me ? please.

Thanks
        
java.lang.ClassCastException: java.lang.Long
        at com.ashna.jturbo.driver.x.setObject(x.java)
        at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(Pl
atformDefaultImpl.java:230)
        at
org.apache.ojb.broker.accesslayer.StatementManager.bindInsert(StatementManag
er.java:493)
        at
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImp
l.java:198)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeToDb(PersistenceBr
okerImpl.java:1835)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBroker
Impl.java:1759)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBroker
Impl.java:638)
        at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.store(DelegatingP
ersistenceBroker.java:152)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl.getSequence(S
equenceManagerHighLowImpl.java:288)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl.getUniqueLong
(SequenceManagerHighLowImpl.java:190)
        at
org.apache.ojb.broker.util.sequence.AbstractSequenceManager.getUniqueId(Abst
ractSequenceManager.java:243)
        at
org.apache.ojb.broker.util.sequence.AbstractSequenceManager.getUniqueValue(A
bstractSequenceManager.java:158)
        at
org.apache.ojb.broker.util.BrokerHelper.getAutoIncrementValue(BrokerHelper.j
ava:317)
        at
org.apache.ojb.broker.util.BrokerHelper.getKeyValues(BrokerHelper.java:218)
        at org.apache.ojb.broker.Identity.init(Identity.java:198)
        at org.apache.ojb.broker.Identity.<init>(Identity.java:135)
        at
aston.banque.test.RendezVousTechno.testCreerClientsComptes(RendezVousTechno.
java:57)
        at
aston.banque.test.RendezVousTechno.main(RendezVousTechno.java:133)
rethrown as
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: Could
not init Identity for given object class aston.banque.domaine.client.Client:
java.lang.Long
        at org.apache.ojb.broker.Identity.init(Identity.java:205)
        at org.apache.ojb.broker.Identity.<init>(Identity.java:135)
        at
aston.banque.test.RendezVousTechno.testCreerClientsComptes(RendezVousTechno.
java:57)
        at
aston.banque.test.RendezVousTechno.main(RendezVousTechno.java:133)

For the assignment of the primary keys I use the class
"SequenceManagerHiLowImpl". 

Here the mapping of the class "Customer",

  <class-descriptor
          class="Customer"
          table="CUSTOMER">
          
      <field-descriptor id="1"
         name="id"
         column="CUS_ID"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="true"
      />
      
      <field-descriptor id="2"
         name="name"
         column="CUS_NAME"
         jdbc-type="VARCHAR"
      />
      <field-descriptor id="3"
         name="firstname"
         column="CUS_FIRST_NAME"
         jdbc-type="VARCHAR"
      />
      
      <field-descriptor id="4"
         name="password"
         column="CUS_PASSWORD"
         jdbc-type="VARCHAR"
      />
      
      <field-descriptor id="5"
         name="login"
         column="CUS_LOGIN"
         jdbc-type="VARCHAR"
      />
      
      <field-descriptor id="6"
         name="version"
         column="CUS_VERSION"
         jdbc-type="INTEGER"
         locking="true"
      />
      
      
                
   </class-descriptor>

 Here the Jdbc connection descriptor

  <jdbc-connection-descriptor
        jcd-alias="default"
        default-connection="true"
          platform="MsSQLServer"
          jdbc-level="2.0"
        driver="com.ashna.jturbo.driver.Driver"
        protocol="jdbc"
        subprotocol="JTurbo://localhost:1433/TEST"
        dbalias=""
        username="sa"
        password=""
        batch-mode="false"
   >
          <connection-pool
            maxActive="5"
            whenExhaustedAction="0"
            validationQuery="select count(*) from OJB_HL_SEQ"
        />

        <sequence-manager
className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
            <attribute attribute-name="grabSize" attribute-value="5"/>
        </sequence-manager>
        
   </jdbc-connection-descriptor>

 Here the classe "Customer"

public class Customer {
        protected long id;
        protected String name;
        protected String firstname;
        protected String password;
        protected String login;
        protected int version;
        
        public Customer () {
        }


        public Customer (String pLogin,String pPassword){
                this.login      = pLogin;
                this.password   = pPassword;    
        }

        public long getId() {
                return id;
        }

        public String getName() {
                return name;
        }
        public String getPassword() {
                return password;
        }

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

        public void setName(String name) {
                this.name = name;
        }

        public void setPassword(String password) {
                this.password = password;
        }

        public String getFirstname() {
                return firstname;
        }

        public void setFirstname(String firstname) {
                this.firstname= firstname;
        }

        public String getLogin() {
                return login;
        }

        public void setLogin(String login) {
                this.login = login;
        }

        public int getVersion() {
                return version;
        }
        public void setVersion(int version) {
                this.version = version;
        }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Reply via email to