Sean,

This reminds me of a similar problem I had while using PersistenceBroker, I
believe I had to call broker.close() in a finally block to resolve the
problem:

        PersistenceBroker broker = null;
        try {
                broker = broker = PersistenceBrokerFactory.defaultPersistenceBroker();
                broker.beginTransaction();
                broker.store(myTransferObject);
                broker.commitTransaction();
        } catch (PersistenceBrokerException e) {
                broker.abortTransaction();
        } finally {
                if (broker != null) {
                        broker.close(); //must close broker
                }
        }

I'm not familiar with ODMG but is there an odmg.close() method that needs to
be called?

Hope this helps,

Joss



> -----Original Message-----
> From: Sean Kleinjung [mailto:[EMAIL PROTECTED]
> Sent: 22 September 2003 18:05
> To: [EMAIL PROTECTED]
> Subject: Only one insert succeeds per application deploy
>
>
> 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