Oh, man, was my question that dumb? Please forgive me for reposting this
(I've editted it somewhat)-- I'm just having a hard time climbing this
learning curve, and I'd like to put OJB to use on a project I'm just
kicking off, but if I don't get a grip on it I'll have to do something
quicker and dirtier. Any help you folks could offer me would be much
appreciated.

Thanks to your help a few days ago I've gotten my installation of OJB
into half-working order. I'm writing with another beginner's question
now. I've been trying to figure it out myself for a while, to no avail.
I'm having trouble getting going with the ODMG API: the problem seems to
center on the auto-increment feature.

I have a class I call ProfileSimple. It contains some member variables
that describe a person. I've got a table in my MySQL database that's
called Profile_simple. I've written a class called ServiceImplSimple
that creates an odmg implementation (named 'odmg') and opens a database.
Two methods in ServiceImplSimple handle storing a ProfileSimple object
and retrieving a ProfileSimple object. 

The storing method, storeProfileSimple, does successfully create a
record in Profile_simple. I've noticed, though, that it does not update
the value of _id, the int variable that identifies the object and maps
to the id column in Profile_simple. The new record in the database might
have an incremented value for id of 3 or 4 (I have auto increment set in
the db), but the object's _id remains 0.

A bigger problem occurs when I try to retrieve the object I just
persisted with a new ProfileSimple variable. I get a series of nasty
exception stack traces that each mention "Could not grab next id, failed
with / This feature is not supported by this implementation". Now, I
have no familiarity with OQL or object database concepts. I have a RDBMS
background. I've been cribbing different sources, including the ODMG
tutorial on the OJB site. I'm sure I'm missing something in the OQL
query or in the way I've set up the Service Implementation. 

I've included everything below: part of my ProfileSimple class, the
field-descriptor for _id/id from my repository_user.xml file, the
methods from ServiceImplSimple, and the stack traces. Any ideas what I'm
doing wrong?

Thanks,

Michael



class ProfileSimple
{
    private int _id;

    // other code left out for brevity

    public int get_id()
    {
        return _id;
    }

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

from: repository_otd.xml

<class-descriptor class="ProfileSimple" table="Profile_simple">

    <field-descriptor 
      name="_id" 
      column="id" 
      jdbc-type="INTEGER"
      primarykey="true" 
      autoincrement="true" />

    <!-- other field-descriptors left out for brevity -->

</class-descriptor>


class ServiceImplSimple

Service implementation methods:

    public void storeProfileSimple( ProfileSimple ps )
    {
        try 
        {
            // open transaction
            Transaction tx = odmg.newTransaction();
            tx.begin();

            // acquire write lock on new object
            tx.lock(ps, Transaction.WRITE);

            // commit transaction
            tx.commit();
        } 
        catch( LockNotGrantedException lnge ) 
        {
            System.out.println("Locking problem for store: ");
            lnge.printStackTrace(  );
        }

    }

    public ProfileSimple getProfileSimple( int id )
    {
        ProfileSimple foundProfile = null;
        Transaction tx = odmg.newTransaction();
        
        try
        {
            // 1. open a transaction
            tx.begin();

            // 2. get an OQLQuery object from the ODMG facade
            OQLQuery query = odmg.newOQLQuery();

            // 3. set the OQL select statement
            query.create("select ProfileSimple from " +
ProfileSimple.class.getName() + 
                         " where _id = " + id);

            // 4. perform the query and store the result in a persistent
Collection
            DList results = (DList) query.execute();
            tx.commit();
            foundProfile = (ProfileSimple) results.get(0);
        }
        catch( Exception ex )
        {
            // Roll back the transaction
            tx.abort(  );
            ex.printStackTrace(  );
        }
        return foundProfile;
    }



[org.apache.ojb.odmg.collections.DListImpl] ERROR: Generation of new id
failed

Could not grab next id, failed with
This feature is not supported by this implementation
Creation of new sequence failed with
This feature is not supported by this implementation
: This feature is not supported by this implementation
java.lang.UnsupportedOperationException: This feature is not supported
by this implementation
        at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.createSequenceQuery(
Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.createSeq
uence(Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Long(Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Id(Unknown Source)
        at
org.apache.ojb.odmg.collections.DListImpl.generateNewId(Unknown Source)
        at org.apache.ojb.odmg.collections.DListImpl.<init>(Unknown
Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
        at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:306)
        at java.lang.Class.newInstance(Class.java:259)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollection
ByQuery(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at ServiceImplSimple.getProfileSimple(ServiceImplSimple.java:76)
        at ServiceImplSimple.main(ServiceImplSimple.java:124)
rethrown as
org.apache.ojb.broker.util.sequence.SequenceManagerException:
Could not grab next id, failed with
This feature is not supported by this implementation
Creation of new sequence failed with
This feature is not supported by this implementation
: This feature is not supported by this implementation
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Long(Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Id(Unknown Source)
        at
org.apache.ojb.odmg.collections.DListImpl.generateNewId(Unknown Source)
        at org.apache.ojb.odmg.collections.DListImpl.<init>(Unknown
Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
        at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:306)
        at java.lang.Class.newInstance(Class.java:259)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollection
ByQuery(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at ServiceImplSimple.getProfileSimple(ServiceImplSimple.java:76)
        at ServiceImplSimple.main(ServiceImplSimple.java:124)
Caused by: java.lang.UnsupportedOperationException: This feature is not
supported by this implementation
        at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.createSequenceQuery(
Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.createSeq
uence(Unknown Source)
        ... 17 more
[org.apache.ojb.odmg.TransactionImpl] INFO: Abort transaction was called
on tx [EMAIL PROTECTED], associated PB was
[EMAIL PROTECTED]
java.lang.UnsupportedOperationException: This feature is not supported
by this implementation
        at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.createSequenceQuery(
Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.createSeq
uence(Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Long(Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Id(Unknown Source)
        at
org.apache.ojb.odmg.collections.DListImpl.generateNewId(Unknown Source)
        at org.apache.ojb.odmg.collections.DListImpl.<init>(Unknown
Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
        at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:306)
        at java.lang.Class.newInstance(Class.java:259)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollection
ByQuery(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at ServiceImplSimple.getProfileSimple(ServiceImplSimple.java:76)
        at ServiceImplSimple.main(ServiceImplSimple.java:124)
rethrown as
org.apache.ojb.broker.util.sequence.SequenceManagerException:
Could not grab next id, failed with
This feature is not supported by this implementation
Creation of new sequence failed with
This feature is not supported by this implementation
: This feature is not supported by this implementation
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Long(Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Id(Unknown Source)
        at
org.apache.ojb.odmg.collections.DListImpl.generateNewId(Unknown Source)
        at org.apache.ojb.odmg.collections.DListImpl.<init>(Unknown
Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
        at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:306)
        at java.lang.Class.newInstance(Class.java:259)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollection
ByQuery(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at ServiceImplSimple.getProfileSimple(ServiceImplSimple.java:76)
        at ServiceImplSimple.main(ServiceImplSimple.java:124)
Caused by: java.lang.UnsupportedOperationException: This feature is not
supported by this implementation
        at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.createSequenceQuery(
Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.createSeq
uence(Unknown Source)
        ... 17 more
rethrown as org.apache.ojb.broker.PersistenceBrokerException:
Could not grab next id, failed with
This feature is not supported by this implementation
Creation of new sequence failed with
This feature is not supported by this implementation
: This feature is not supported by this implementation
        at
org.apache.ojb.odmg.collections.DListImpl.generateNewId(Unknown Source)
        at org.apache.ojb.odmg.collections.DListImpl.<init>(Unknown
Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
        at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at java.lang.Class.newInstance0(Class.java:306)
        at java.lang.Class.newInstance(Class.java:259)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Unknown Source)
        at
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollection
ByQuery(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.execute(Unknown Source)
        at ServiceImplSimple.getProfileSimple(ServiceImplSimple.java:76)
        at ServiceImplSimple.main(ServiceImplSimple.java:124)
Caused by: org.apache.ojb.broker.util.sequence.SequenceManagerException:
Could not grab next id, failed with
This feature is not supported by this implementation
Creation of new sequence failed with
This feature is not supported by this implementation
: This feature is not supported by this implementation
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Long(Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.getUnique
Id(Unknown Source)
        ... 15 more
Caused by: java.lang.UnsupportedOperationException: This feature is not
supported by this implementation
        at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.createSequenceQuery(
Unknown Source)
        at
org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl.createSeq
uence(Unknown Source)
        ... 17 more
Exception in thread "main" java.lang.NullPointerException
        at
ServiceImplSimple.displayProfileSimple(ServiceImplSimple.java:113)
        at ServiceImplSimple.main(ServiceImplSimple.java:125)


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

Reply via email to