You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by jo...@email.de on 2004/01/23 09:59:41 UTC

using proxy class in a jtree

Hello evrybody,
I have a problem with my OJB implementation. I have the following  metadata
mapping with the corresponding classmodel.
  <class-descriptor
      class="basis.Model"
      table="models"
      identity-type="datastore">
      <field-descriptor
         name="id"
         column="id"
         jdbc-type="BIGINT"
         primarykey="true"
         autoincrement="true"       
      />         
       <reference-descriptor
         name="modelItem"
         class-ref="basis.ModelItem"
         auto-retrieve="true"
         auto-update="true"
         auto-delete="true"
       >
         <foreignkey field-ref="modelItemId"/>
      </reference-descriptor>
   </class-descriptor>

  <class-descriptor
      class="basis.ModelI18N"
      table="models_i18n"
      identity-type="datastore">

      <field-descriptor
         name="id"
         column="id"
         jdbc-type="BIGINT"
         primarykey="true"
         autoincrement="true"
      />
      <field-descriptor
         name="ownerId"        
         column="model_id"
         jdbc-type="BIGINT"
      />
      <field-descriptor
         name="nationId"
         primarykey="true"
         column="nation_id"
         jdbc-type="BIGINT"
      />       
      <reference-descriptor
         name="owner"
         class-ref="basis.Model"
         auto-retrieve="true"
         auto-update="true"
      >
         <foreignkey field-ref="ownerId"/>
      </reference-descriptor>       
      <reference-descriptor
         name="nationality"
         class-ref="basis.Nationality"
         auto-retrieve="true"
      >
         <foreignkey field-ref="nationId"/>
      </reference-descriptor>       
   </class-descriptor>

   <class-descriptor
      class="basis.ModelItem"
      proxy="dynamic"
      table="modelitems"
      identity-type="datastore">
      <field-descriptor
         name="id"
         column="id"
         jdbc-type="BIGINT"
         primarykey="true"
         autoincrement="true"
      />
     <field-descriptor
         name="modelId"
         column="model_id"
         jdbc-type="BIGINT"
      />
      <field-descriptor
         name="itemHierarchy"
         column="item_hierarchy"
         jdbc-type="BIGINT"
      />     
      <collection-descriptor
         name="modelItemsI18N"
         element-class-ref="basis.ModelItemI18N"      
         orderby="id"
         sort="asc"
         auto-retrieve="true"
         auto-update="true"
         auto-delete="true"   
      >
         <inverse-foreignkey field-ref="ownerId"/>
      </collection-descriptor>
      <reference-descriptor
         name="parent"
         class-ref="basis.ModelItem"
         auto-retrieve="true"
         auto-update="true"    
      >
         <foreignkey field-ref="itemHierarchy"/>
      </reference-descriptor>    
       <reference-descriptor
         name="model"
         class-ref="basis.Model"
         auto-retrieve="true"
         auto-update="true"              
      >
         <foreignkey field-ref="modelId"/>
      </reference-descriptor>     
      <collection-descriptor
         name="children"
         element-class-ref="basis.ModelItem"     
         orderby="id"
         sort="asc"
         auto-retrieve="true"
         auto-update="true"
         auto-delete="true"   
      >
         <inverse-foreignkey field-ref="itemHierarchy"/>
      </collection-descriptor>     
   </class-descriptor>
  <class-descriptor
      class="basis.ModelItemI18N"
      proxy="dynamic"
      table="modelitems_i18n"
      identity-type="datastore">

      <field-descriptor
         name="id"
         column="id"
         jdbc-type="BIGINT"
         primarykey="true"
         autoincrement="true"        
      />
      <field-descriptor
         name="nationId"
         column="nation_id"
         jdbc-type="BIGINT"
      />
      <field-descriptor
         name="header"
         column="header"
         jdbc-type="VARCHAR"
      />
      <field-descriptor
         name="author"
         column="author"
         jdbc-type="VARCHAR"
      /> 
      <field-descriptor
         name="ownerId"        
         column="item_id"
         jdbc-type="BIGINT"
      />        
      <field-descriptor
         name="changedAt"
         column="changed_at"
         jdbc-type="DATE"
      />
      <field-descriptor
         name="textId"
         column="text_id"
         jdbc-type="BIGINT"
      />
      <field-descriptor
         name="processId"
         column="process_id"
         jdbc-type="BIGINT"
      />
     <reference-descriptor
         name="nationality"
         class-ref="basis.Nationality"
         auto-retrieve="true"
      >
         <foreignkey field-ref="nationId"/>
      </reference-descriptor>          
     <reference-descriptor
         name="item"
         class-ref="basis.ModelItem"
         auto-retrieve="true"    
      >
         <foreignkey field-ref="ownerId"/>
      </reference-descriptor>          
   </class-descriptor>


My 'modelItems' have a hierarchical structure. Each modelitem knows his
parent and holds a collection of  its children.
Because I don not want to read all modelitems at one time, I have
implemented this class as a proxy-class(see datamapping). This means,
the ojb implementation should only fill the respective modelitems when
I hold a reference of it.
It works fine in the JUnitTest I have written. I  display this hierarchy
in a jtree, using the DefaultMutableTreeNode which contains the
modelitems as userObjects. When I additionally try to expand the tree,
the ojb implementation is not able to resolve the proxyObjects to
real-objects. Therefore it is not possible to display the
objecthierarchy in a jtree.

Thanks for helping me 

Jörn Ziemke

 

The error message is :

Used ConnectionManager instance could not obtain a connection: Could not borrow connection from pool - org.apache.ojb.broker.metadata.JdbcConnectionDescriptor: org.apache.ojb.broker.metadata.JdbcConnectionDescriptor@1360e2[

jcd-alias=oracle

default-connection=true

dbms=Oracle

jdbc-level=1.0

driver=oracle.jdbc.driver.OracleDriver

protocol=jdbc

sub-protocol=oracle

db-alias=thin:@apl.hoppe.de:1526:devB

user=jziemke

password=*****

eager-release=false

ConnectionPoolDescriptor={whenExhaustedAction=0, validationQuery=select count(*) from models, maxIdle=-1, maxActive=1, maxWait=5000, removeAbandoned=false, numTestsPerEvictionRun=10, testWhileIdle=false, minEvictableIdleTimeMillis=600000, testOnReturn=false, logAbandoned=false, removeAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1, testOnBorrow=true}

batchMode=false

useAutoCommit=AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE

ignoreAutoCommitExceptions=false

sequenceDescriptor=org.apache.ojb.broker.metadata.SequenceDescriptor@175422[

sequenceManagerClass=class h3.gen.H3SequenceManager

Properties={}

]

]

[org.apache.ojb.broker.accesslayer.IndirectionHandler] ERROR: Method invoking failed for method *getModelItemI18NByNationality* on object null

Used ConnectionManager instance could not obtain a connection: Could not borrow connection from pool - org.apache.ojb.broker.metadata.JdbcConnectionDescriptor: org.apache.ojb.broker.metadata.JdbcConnectionDescriptor@1360e2[

jcd-alias=oracle

default-connection=true

dbms=Oracle

jdbc-level=1.0

driver=oracle.jdbc.driver.OracleDriver

protocol=jdbc

sub-protocol=oracle

db-alias=thin:@apl.hoppe.de:1526:devB

user=jziemke

password=*****

eager-release=false

ConnectionPoolDescriptor={whenExhaustedAction=0, validationQuery=select count(*) from models, maxIdle=-1, maxActive=1, maxWait=5000, removeAbandoned=false, numTestsPerEvictionRun=10, testWhileIdle=false, minEvictableIdleTimeMillis=600000, testOnReturn=false, logAbandoned=false, removeAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1, testOnBorrow=true}

batchMode=false

useAutoCommit=AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE

ignoreAutoCommitExceptions=false

sequenceDescriptor=org.apache.ojb.broker.metadata.SequenceDescriptor@175422[

sequenceManagerClass=class h3.gen.H3SequenceManager

Properties={}

]

]

[org.apache.ojb.broker.accesslayer.IndirectionHandler] ERROR: Method invoking failed for method *getModelItemI18NByNationality* on object unmaterialized proxy for h3.shadow.ModelItem{780730107476194}

null


 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org