Yes, prefetching is the way to refresh relationships during the query. 'setupPrefetch' method is a bit heavy handed, but should result in a refresh. BTW, there's a better way to detect relationships than reflection on the method sigs - access Cayenne metadata available from EntityResolver:

EntityResolver resolver = context.getEntityResolver();
ObjEntity entity = resolver.lookupObjEntity(queryClass);

Andrus



On Jul 14, 2009, at 8:41 PM, Emanuele Maiarelli wrote:

Seems like i solved by problems of relationships update, using this static method

   public static void setupPrefetch(SelectQuery q, Class queryClass) {
       Method[] mts=queryClass.getMethods();
       for (int i=0;i<mts.length;i++)
       {
           String metho=mts[i].getName();
           if (metho.startsWith("get"))
           {

String purename=metho.substring(3,4).toLowerCase() +metho.substring(4); if (purename.endsWith("Array") || purename.startsWith("to"))
               {
                   q.addPrefetch(purename);
                   System.out.println("PREFTECH ADDED:"+purename);
               }
           }
       }
   }
So actually seems that i can avoid XMPP and peer 2 perr notifications.

Thanks for the support,




________________________________
Da: Emanuele Maiarelli <[email protected]>
A: [email protected]
Inviato: Martedì 14 luglio 2009, 16:39:10
Oggetto: Cayenne 2.0.4 ROP


Hello,

I'm working on an java swing application, using ROP (configuration is: Tomcat 6, Cayenne 2.0.4 with mysql).

Since now everything worked perfectly, the swing application ( and all javabeans, that i created) works as expected.

When i started plugging more that one client to the ORM, i start having some problems with caching, more precisely

   considering the following entity:
<obj-entity name="GcUtenti" className="entities.GcUtenti" clientClassName="Client.GcUtenti" dbEntityName="GC_UTENTI"> <obj-attribute name="gcConsulten" type="java.lang.Boolean" db- attribute-path="GC_CONSULTEN"/> <obj-attribute name="gcCostoRisorsa" type="java.lang.Double" db-attribute-path="GC_COSTO_RISORSA"/> <obj-attribute name="gcEmail" type="java.lang.String" db- attribute-path="GC_EMAIL"/> <obj-attribute name="gcFax" type="java.lang.String" db- attribute-path="GC_FAX"/> <obj-attribute name="gcFornadmin" type="java.lang.Boolean" db- attribute-path="GC_FORNADMIN"/> <obj-attribute name="gcIsadmin" type="java.lang.Boolean" db- attribute-path="GC_ISADMIN"/> <obj-attribute name="gcMob" type="java.lang.String" db- attribute-path="GC_MOB"/> <obj-attribute name="gcNome" type="java.lang.String" db- attribute-path="GC_NOME"/> <obj-attribute name="gcPassword" type="java.lang.String" db- attribute-path="GC_PASSWORD"/> <obj-attribute name="gcTel" type="java.lang.String" db- attribute-path="GC_TEL"/> <obj-attribute name="gcUsername" type="java.lang.String" db- attribute-path="GC_USERNAME"/>
   </obj-entity>

with the follwing relationships
<db-relationship name="commesseAssegnateEst" source="GC_UTENTI" target="COMMESSE" toMany="true">
       <db-attribute-pair source="GC_PK" target="GCCOM_RES_EST_FK"/>
   </db-relationship>
<db-relationship name="commesseReposabileDi" source="GC_UTENTI" target="COMMESSE" toMany="true">
       <db-attribute-pair source="GC_PK" target="GCCOM_RES_INT_FK"/>
   </db-relationship>
<db-relationship name="gcOreAccettate" source="GC_UTENTI" target="GC_ORE" toMany="true">
       <db-attribute-pair source="GC_PK" target="GCO_ACC_USER_FK"/>
   </db-relationship>
<db-relationship name="gcOreLavorate" source="GC_UTENTI" target="GC_ORE" toMany="true">
       <db-attribute-pair source="GC_PK" target="GCO_RISORSA_FK"/>
   </db-relationship>
<db-relationship name="gcOreVerificateEst" source="GC_UTENTI" target="GC_ORE" toMany="true">
       <db-attribute-pair source="GC_PK" target="GCO_VER_USER_FK"/>
   </db-relationship>
<db-relationship name="toGcForn" source="GC_UTENTI" target="GC_FORN" toMany="false">
       <db-attribute-pair source="GC_FORN_FK" target="GCF_PK"/>
   </db-relationship>
<db-relationship name="toScaglioni" source="GC_UTENTI" target="SCAGLIONI" toMany="false">
       <db-attribute-pair source="GC_SCA_FK" target="SCA_PK"/>
   </db-relationship>
<db-relationship name="toTipOper" source="GC_UTENTI" target="TIP_OPER" toMany="false">
       <db-attribute-pair source="GC_TIPOP_FK" target="TIO_PK"/>
   </db-relationship>


if a client alter and commpit one relation, for example "toGcForn", the other client isn't unware of that change, by otherway changing gcNome the other clients get aware.

Currently im not using any kind of Shared_session, its that dued by this fact?

Btw i tried to configure XMPP for managing shadred_session. I saw that ther are other options like JGroups, but there no kind of documentation about usign them with Cayenne.

I configured openfire 3.6.4 and i added on both java client and to webapplication XMPP clients (smack-2.2.1.jar and smackx-2.2.1.jar), and configured the XMPP servlet on the web.xml:
<init-param>
<param-name>cayenne.RemoteService.EventBridge.factory</param- name> <param-value>org.apache.cayenne.event.XMPPBridgeFactory</param- value>
  </init-param>
  <init-param>
     <param-name>cayenne.XMPPBridge.xmppHost</param-name>
     <param-value>127.0.0.1</param-value>
  </init-param>
  <init-param>
     <param-name>cayenne.XMPPBridge.xmppPort</param-name>
     <param-value>5222</param-value>
  </init-param>
  <init-param>
     <param-name>cayenne.XMPPBridge.xmppChatService</param-name>
     <param-value>conference</param-value>
  </init-param>

After doing that cayenne starts throwing exceptions on server side

org.apache.cayenne.CayenneRuntimeException: [v.2.0.4 October 8 2007] Error starting EventBridge org.apache.cayenne.event.xmppbri...@f6438d at org .apache .cayenne .remote.ClientChannel.setupRemoteChannelListener(ClientChannel.java: 228) at org.apache.cayenne.remote.ClientChannel.<init>(ClientChannel.java:79) at org.apache.cayenne.remote.ClientChannel.<init>(ClientChannel.java:69) at org.apache.cayenne.remote.ClientChannel.<init>(ClientChannel.java:65)
       at System.Instance.Login(Instance.java:53)
       .....................................
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java: 122) Caused by: org.apache.cayenne.CayenneRuntimeException: [v.2.0.4 October 8 2007] Error connecting to XMPP ServerXMPPError connecting to 127.0.0.1:5222. at org.apache.cayenne.event.XMPPBridge.startupExternal(XMPPBridge.java: 180) at org.apache.cayenne.event.EventBridge.startup(EventBridge.java:275) at org .apache .cayenne .remote.ClientChannel.setupRemoteChannelListener(ClientChannel.java: 225)
       ... 38 more


Looking at the error its seems to be caused by the XMPP server not working, but i checked and it works. Looking with tcpdump i didn't see any incoming packet while Cayenne tries to connect to it.

Im doing something wrong?

Maybe some tomcat security feature blocking it?

Another question, to enable shared sessions via XMPP, something other that what i configured must to be done? I mean nothing else (than the parameters in web.xml) has to be specified to clients?


Thanks in advice,

Emanuele



Reply via email to