object regsitered in a different DataContext

From: Andrea Borgogelli Avveduti (borgogell..otmail.com)
Date: Fri Dec 02 2005 - 05:23:41 EST

  • Next message: tibolists: "newbie questions to well inderstand cayenne framework."

    Hello boys
      
    I'm a newbie, and I'd like to simply delete a DataOject in Cayenne. I have tried this code:
     
             PersonaFisica persona = (PersonaFisica) ( (DOTableModel)  jPanelTable.table.getModel()).getDataObject(selRows[0]);
             CayenneConnection.dataContext.deleteObject(persona);  // here persona is not null
             CayenneConnection.dataContext.commitChanges();
     .....
     
     
    But I got the following error:
     
     
    org.objectstyle.cayenne.CayenneRuntimeException: [v.1.2M8 November 24005]  Attempt to delete object regsitered in a different DataContext
     
     
    What does it mean ? Could someone help me please ? Any advices will be useful.
     
    For connection I use a class like this:
     
     
    public class CayenneConnection {
     
       public static DataContext dataContext;
       public static DataView dataView;
       public static Configuration conf;
     
    ......
     
     
       /**
        * connect
        */
       public static void connect() {
         init();
         try {
           dataContext = DataContext.createDataContext();
         }
         catch (Exception ex) {
           ex.printStackTrace();
     
           JOptionPane.showMessageDialog(
               null,
               ex.getMessage(),
               "Connection Error",
               JOptionPane.ERROR_MESSAGE);
           return;
         }
       }
     
       /**
        * loadDataView
        */
       public static void loadConfig() {
         dataView = new DataView();
         dataView.setEntityResolver(dataContext.getEntityResolver());
         try {
           conf.loadDataView(dataView);
         }
         catch (IOException ioex) {
           ioex.printStackTrace();
           throw new CayenneRuntimeException("Error loading DataView", ioex);
         }
       }
     
       /**
        * init
        */
       public static void init() {
         DataSource dataSource1 = null;
         DataSource dataSource2 = null;
         try {
           dataSource1 = new PoolManager(Config.defaultFirebirdDriver,
                                         Config.defaultFirebirdUrlPrefix +  Config.firebirdUrl + Config.defaultDbAnagrafica,
                                         1,
                                         5,
                                         Config.firebirdUser,
                                         Config.firebirdPassword);
     
           dataSource2 = new PoolManager(Config.defaultFirebirdDriver,
                                         Config.defaultFirebirdUrlPrefix +  Config.firebirdUrl + Config.defaultDbPaghe,
                                         1,
                                         5,
                                         Config.firebirdUser,
                                        Config.firebirdPassword);
         }
         catch (SQLException ex) {
         }
         conf = Configuration.getSharedConfiguration();
         DataDomain domain = conf2.getDomain();
         DataNode node1 = domain.getNode("MyDomainNode");
         DataNode node2 = domain.getNode("MyDomainNode2");
         node1.setDataSource(dataSource1);
         node2.setDataSource(dataSource2);
       }
     
    }
     
    Thank u in advance and greetings from Italy.
     
    Andrea



    This archive was generated by hypermail 2.0.0 : Fri Dec 02 2005 - 05:23:42 EST