Re: Newbie: connected user

From: Koka (22605..mail.com)
Date: Mon Jan 10 2005 - 14:44:44 EST

  • Next message: Andrus Adamchik: "Re: Newbie: connected user"

    Hi again,

    Reproducing my problems is easy: I created the database tables using
    SQL supplied with tutorials\cayenne-tapestry-app and added
    PK_PAINTINGS sequence manually and entered that sequence in modeller
    under 'Customize PK generation'. Now INFO QueryLogger output is:
    SELECT t0.GALLERY_NAME, t0.GALLERY_ID FROM KOKA.GALLERY t0
    compare to
    SELECT PK_PAINTING.nextval FROM DUAL
    Obviously the latter should read
    SELECT KOKA.PK_PAINTING.nextval FROM DUAL

    Now about unique constraint violated error. ALL I modified in
    cayenne-tapestry-app is that I did add the following loop just after
    ctxt.commitChanges() line in savePaintingAction
    (AddPaintingPage.java):

           Gallery gallery = painting.getToGallery();
            for (int i = 0; i < 3; i++) {
                Painting paintingLoop = new Painting();
    // seems like modern artist - enumaretes his painting
                paintingLoop.setPaintingTitle(painting.getPaintingTitle()
    + " No " + i);
                ctxt.registerNewObject(paintingLoop);
                paintingLoop.setToGallery(gallery);
                artist.addToPaintingArray(paintingLoop);
            }
            ctxt.commitChanges();
    and tested it for different sequence caches (I just wanted to see how
    cursors are opened/closed running the loop for larger values)

    Couple of words more about multiuser stuff and solutions from Andrus'
    post. Ours is an intranet application with couple of hundred users
    with rare requests for retrieving/updating secure data. So most
    requests are served using connection pool with some default
    credentials, but actual user credentials are kept in session, so if
    the user attempts to access secure object his credentials are used to
    create new (not pooled) connection. So, following the link you
    provided I think I can simply add a method getNamedDataContext to my
    Visit object (naturally username/password/url are stored in the Visit
    object too)
       public DataContext getUserDataContext () {
            DataContext dataContext = DataContext.createDataContext();
            DataDomain qe = dataContext.getParentDataDomain();
            DataNode dn = qe.getNode("datanode");
            java.sql.Driver d = new oracle.jdbc.OracleDriver();
            DriverDataSource ds = new
    DriverDataSource(d,actualUrl,userName,password);
            dn.setDataSource(ds);
            return dataContext; }
    and use that userdatacontext in rare occasions when users access secure pages.
    Sorry for loooong post.
    P.S.
    >Haven't had this problem either, but I have sequence cache parameters of 1.
    and what's your sequence cache parameter in oracle? Value 1 forbidden
    in Oracle, it should be 0 or >1.



    This archive was generated by hypermail 2.0.0 : Mon Jan 10 2005 - 14:44:45 EST