Hi Sean,

Part of the problem could also be that you are using the SequenceManagerNativeImpl. Please see the following bug for details <http://scarab.werken.com/issues/id/OJB204>.

Mike

On Monday, September 22, 2003, at 01:05 PM, Sean Kleinjung wrote:

Hello,

We are attempting to use the Object-Relational Bridge in a web
application that is being deployed to the Novell eXtend application
server. We seem to have gotten everything installed and configured
correctly, and are working through a simple servlet we wrote based
heavily on the ODMG tutorial.

We have, however, run into a bizarre problem. If we package and deploy
the web application, then call a servlet that is supposed to insert a
new (id,name) tuple into a test table, the operation succeeds. Once. If
we call the servlet multiple times, only the first object gets inserted.
Repeated calls appear to have no effect on the database. No exception or
error condition occurs, and as far as the servlet code can tell the
operation succeeds, but there is no change on the database.


Following is the code in question:

/*
 * SNIP
 */

public class TestServlet extends HttpServlet {
        Implementation odmg = null;

        /**
         *
         */
        public TestServlet() {
                super();
        }
        
        
        /*
         * @see javax.servlet.GenericServlet#init()
         */
        public void init() throws ServletException {
                super.init();
                
                odmg = OJB.getInstance();
                Database db = odmg.newDatabase();
                try {
                        db.open( "users", Database.OPEN_READ_WRITE);
                } catch (ODMGException ex) {
                        throw new ServletException(
                                "Failed to open database: ", ex);
                }
        }


protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Test test = new Test(); test.setName(req.getParameter("name"));

                Transaction tx = null;
                try {
                        tx = odmg.newTransaction();
                        tx.begin();
                        tx.lock(test, Transaction.WRITE);
                        tx.commit();
                } catch (LockNotGrantedException lnge) {
                        //lnge.printStackTrace();
                        throw new ServletException(lnge);
                }

                resp.getWriter().println("Done.");
        }
}

/*
 * /SNIP
 */

I tried an alternate implementation where the ODMG implementation object
and database objects were created/opened and closed during every
invocation of the servlet's doGet method, but this exhibited the same
effect.


We are stumped on this, and any help would be greatly appreciated.

Thanks for your time,
Sean Kleinjung
Web Application Developer
Agri ImaGIS Technologies, Inc.
http://www.satshot.com

----------------------------------------------------------------------- ---

For reference, the repository_user.xml file for this application is
included below:

----------------------------------------------------------------------- ---

<!-- Please keep user defined mappings in this file only
     to avoid mixing user defined and system mappings. -->
<!-- Mapping of User defined classes starts here -->

<!-- The mappings for the tutorial classes are placed here to make it
     easier to find them for OJB newbies.
     Please remove them if you don't need them in your environment. -->

     <!-- mssql database description -->
     <jdbc-connection-descriptor
                jcd-alias="users"
                platform="MsSQLServer"
                jdbc-level="2.0"
                jndi-datasource-name="java:comp/env/jdbc/UsersDB"/>
                

<!-- Definitions for com.satshot.test.Test -->
   <class-descriptor
          class="com.satshot.test.Test"
          table="Test"

      <field-descriptor
         name="oid"
         column="oid"
         jdbc-type="INTEGER"
         primarykey="true"
         access="readonly"
      />
      <field-descriptor
         name="name"
         column="name"
         jdbc-type="VARCHAR"
      />
   </class-descriptor>


<!-- Mapping of User defined classes ends here -->



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



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



Reply via email to