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 lyl <ly...@staff.cn99.com> on 2003/08/06 09:20:55 UTC
How to join tables?
Hi, there!
I have several table to join, but i cannot find the api. Can any one
tell me? In addition, I want to select a value like "max(id)" from a
table, i say the QueryBySQL, but i am wondering if there is another way
to accomplish this, any way i don't like to mix SQL string in the
program.
thinks.
--
lyl <ly...@staff.cn99.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Proxy / 1:1-Mapping
Posted by Joerg Lensing <in...@softcon-lensing.de>.
Problem solved! problem with classpath for rc4 - still rc3-jars were active
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: 1:1-Mapping
Posted by Rémi Bars <rb...@softeam.fr>.
i only use integer in my repository.xml, and i use int in my classes
----- Original Message -----
From: <de...@betterway.net>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, September 30, 2003 3:28 PM
Subject: Re: 1:1-Mapping
> Have you tried using int, instead of Integer?
>
> ----- Original Message -----
> From: "Rémi Bars" <rb...@softeam.fr>
> To: "OJB Users List" <oj...@db.apache.org>
> Sent: Tuesday, September 30, 2003 9:25 AM
> Subject: 1:1-Mapping
>
>
> > Hi all
> >
> > i m trying to do a 1:1 mapping on rc4 with the xml file at the end
> > when i try to store a Catalogue i get this error :
> >
> > Thanks for ur help
> >
> >
> > org.apache.ojb.broker.PersistenceBrokerException:
> > org.apache.ojb.broker.PersistenceBrokerException:
> > org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> > java.lang.Integer not found in OJB Repository
> >
> > at org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(Unknown
Source)
> >
> > at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
> >
> > at
> >
>
fr.ouestfrance.sip.cezan.framework.persistance.odmg.OJB_ODMG_PersistentManag
> > er.insert(OJB_ODMG_PersistentManager.java:126)
> >
> > at
> >
>
fr.ouestfrance.sip.cezan.framework.persistance.odmg.OJB_ODMG_CezanGestionnai
> > reDAO.create(OJB_ODMG_CezanGestionnaireDAO.java:55)
> >
> > at
> >
>
fr.ouestfrance.sip.cezan.serveur.catalogue.work.GestionnaireCatalogueServeur
> > Impl.main(GestionnaireCatalogueServeurImpl.java:165)
> >
> > Caused by: org.apache.ojb.broker.PersistenceBrokerException:
> > org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> > java.lang.Integer not found in OJB Repository
> >
> > at org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(Unknown
Source)
> >
> > ... 5 more
> >
> >
> > <class-descriptor class='ThemeServeurImpl' table='Theme'>
> > <field-descriptor
> > name="id"
> > column="id"
> > jdbc-type="INTEGER"
> > primarykey="true"
> > autoincrement="true"
> > />
> > <field-descriptor name='_Nom' column='_Nom'
> jdbc-type='VARCHAR'/>
> > </class-descriptor>
> > <class-descriptor class='CatalogueServeurImpl' table='Catalogue'>
> > <field-descriptor
> > name="id"
> > column="id"
> > jdbc-type="INTEGER"
> > primarykey="true"
> > autoincrement="true"
> > />
> > <field-descriptor name="_ThemeParentId" column="Theme_id"
> > jdbc-type="INTEGER"/>
> > <reference-descriptor
> > name="_ThemeParentId"
> > class-ref="ThemeServeurImpl"
> > auto-retrieve="true"
> > auto-update="true"
> > auto-delete="true"
> > >
> > <foreignkey field-ref="id" />
> > </reference-descriptor>
> > </class-descriptor>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: 1:1-Mapping
Posted by de...@betterway.net.
Have you tried using int, instead of Integer?
----- Original Message -----
From: "Rémi Bars" <rb...@softeam.fr>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Tuesday, September 30, 2003 9:25 AM
Subject: 1:1-Mapping
> Hi all
>
> i m trying to do a 1:1 mapping on rc4 with the xml file at the end
> when i try to store a Catalogue i get this error :
>
> Thanks for ur help
>
>
> org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> java.lang.Integer not found in OJB Repository
>
> at org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(Unknown Source)
>
> at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
>
> at
>
fr.ouestfrance.sip.cezan.framework.persistance.odmg.OJB_ODMG_PersistentManag
> er.insert(OJB_ODMG_PersistentManager.java:126)
>
> at
>
fr.ouestfrance.sip.cezan.framework.persistance.odmg.OJB_ODMG_CezanGestionnai
> reDAO.create(OJB_ODMG_CezanGestionnaireDAO.java:55)
>
> at
>
fr.ouestfrance.sip.cezan.serveur.catalogue.work.GestionnaireCatalogueServeur
> Impl.main(GestionnaireCatalogueServeurImpl.java:165)
>
> Caused by: org.apache.ojb.broker.PersistenceBrokerException:
> org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
> java.lang.Integer not found in OJB Repository
>
> at org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(Unknown Source)
>
> ... 5 more
>
>
> <class-descriptor class='ThemeServeurImpl' table='Theme'>
> <field-descriptor
> name="id"
> column="id"
> jdbc-type="INTEGER"
> primarykey="true"
> autoincrement="true"
> />
> <field-descriptor name='_Nom' column='_Nom'
jdbc-type='VARCHAR'/>
> </class-descriptor>
> <class-descriptor class='CatalogueServeurImpl' table='Catalogue'>
> <field-descriptor
> name="id"
> column="id"
> jdbc-type="INTEGER"
> primarykey="true"
> autoincrement="true"
> />
> <field-descriptor name="_ThemeParentId" column="Theme_id"
> jdbc-type="INTEGER"/>
> <reference-descriptor
> name="_ThemeParentId"
> class-ref="ThemeServeurImpl"
> auto-retrieve="true"
> auto-update="true"
> auto-delete="true"
> >
> <foreignkey field-ref="id" />
> </reference-descriptor>
> </class-descriptor>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
1:1-Mapping
Posted by Rémi Bars <rb...@softeam.fr>.
Hi all
i m trying to do a 1:1 mapping on rc4 with the xml file at the end
when i try to store a Catalogue i get this error :
Thanks for ur help
org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
java.lang.Integer not found in OJB Repository
at org.apache.ojb.odmg.TransactionImpl.assignReferenceFKs(Unknown Source)
at org.apache.ojb.odmg.TransactionImpl.lock(Unknown Source)
at
fr.ouestfrance.sip.cezan.framework.persistance.odmg.OJB_ODMG_PersistentManag
er.insert(OJB_ODMG_PersistentManager.java:126)
at
fr.ouestfrance.sip.cezan.framework.persistance.odmg.OJB_ODMG_CezanGestionnai
reDAO.create(OJB_ODMG_CezanGestionnaireDAO.java:55)
at
fr.ouestfrance.sip.cezan.serveur.catalogue.work.GestionnaireCatalogueServeur
Impl.main(GestionnaireCatalogueServeurImpl.java:165)
Caused by: org.apache.ojb.broker.PersistenceBrokerException:
org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException:
java.lang.Integer not found in OJB Repository
at org.apache.ojb.odmg.TransactionImpl.assertFkAssignment(Unknown Source)
... 5 more
<class-descriptor class='ThemeServeurImpl' table='Theme'>
<field-descriptor
name="id"
column="id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor name='_Nom' column='_Nom' jdbc-type='VARCHAR'/>
</class-descriptor>
<class-descriptor class='CatalogueServeurImpl' table='Catalogue'>
<field-descriptor
name="id"
column="id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>
<field-descriptor name="_ThemeParentId" column="Theme_id"
jdbc-type="INTEGER"/>
<reference-descriptor
name="_ThemeParentId"
class-ref="ThemeServeurImpl"
auto-retrieve="true"
auto-update="true"
auto-delete="true"
>
<foreignkey field-ref="id" />
</reference-descriptor>
</class-descriptor>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Proxy / 1:1-Mapping
Posted by Joerg Lensing <in...@softcon-lensing.de>.
Hi all,
up to now, I used "complete" object for references and all worked fine.
Now I try to use a proxy for a reference (version: rc4). The mapping is:
<class-descriptor
class="de.softcon.webcontrol.business.model.OrganisationPO"
table="tpartner">
<field-descriptor name="id" column="foid" jdbc-type="INTEGER"
primarykey="true" autoincrement="true"/>
<field-descriptor name="costUnitID" column="fcostunitid"
jdbc-type="INTEGER"/>
<field-descriptor name="mainBusiness" column="fbusiness"
jdbc-type="VARCHAR"/>
<reference-descriptor name="costUnit"
class-ref="de.softcon.webcontrol.business.model.CostUnitPO" proxy="true">
<foreignkey field-ref="costUnitID"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor
class="de.softcon.webcontrol.business.model.CostUnitPO" table="tcostunit">
<field-descriptor name="description" column="fdescription"
jdbc-type="VARCHAR"/>
<field-descriptor name="id" column="foid" jdbc-type="INTEGER"
primarykey="true" autoincrement="true"/>
</class-descriptor>
I get the following error-message:
[org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl]
ERROR: while set field:
object class[ de.softcon.webcontrol.business.model.OrganisationPO
target field: costUnit
target field type: interface de.softcon.webcontrol.business.model.CostUnitIF
object value class: $Proxy0
object value: de.softcon.webcontrol.business.model.CostUnitPO@e61a35----
id: 885477
lastModified: 2003-02-01 00:00:00.0
modifiedBy: joerg_init
created: 2003-02-01 00:00:00.0
createdBy: joerg_init
lockTime: 2003-02-01 00:00:00.0----
]
java.lang.IllegalArgumentException
at
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:519)
at
org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDefaultImpl.set(PersistentFieldDefaultImpl.java:147)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReference(PersistenceBrokerImpl.java:1047)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveReferences(PersistenceBrokerImpl.java:1025)
at
org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(RsIterator.java:446)
at
org.apache.ojb.broker.accesslayer.RsIterator.next(RsIterator.java:253)
at
org.apache.ojb.broker.accesslayer.ChainingIterator.next(ChainingIterator.java:357)
.......
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: How to join tables?
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi iyl,
joins are handled automatically based on relationship-definitions and
path-expressions
ie a PErson having 1:n Phones:
<class-descriptor
class="brj.ojb.Person"
table="tabPerson"
>
<field-descriptor id="1"
name="id"
....
<collection-descriptor
name="telefone"
orderby="nummer"
sort="DESC"
element-class-ref="brj.ojb.Telefon"
proxy="true"
refresh="false"
auto-retrieve="true"
auto-update="true"
auto-delete="true"
>
<inverse-foreignkey field-ref="idPerson"/>
</collection-descriptor>
<class-descriptor
class="brj.ojb.Telefon"
table="tabTelefon"
>
...
<reference-descriptor
name="inhaber"
class-ref="brj.ojb.Person"
>
<foreignkey field-ref="idPerson"/>
</reference-descriptor>
</class-descriptor>
the path expression 'telefone.nummer' will result in a join between
tabPerson and tabTelefon
crit = new Criteria();
crit.addLike("telefone.nummer", "031*");
crit.addOrderByAscending("name");
query = new QueryByCriteria(Person.class, crit);
hth
jakob
btw: query syntax is in the docs ;)
lyl wrote:
>Hi, there!
>
>I have several table to join, but i cannot find the api. Can any one
>tell me? In addition, I want to select a value like "max(id)" from a
>table, i say the QueryBySQL, but i am wondering if there is another way
>to accomplish this, any way i don't like to mix SQL string in the
>program.
>
>thinks.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org