gilles dodinet wrote:
> hi oleg,
> i'd like to see the log too!! but i cant unfortunately find it. :(
Call
jdo.setLogWriter( Logger.getSystemLogger() );
Where Logger is from org.exolab.castor.util package.
Please, send me the log.
Oleg
> anyhow here are my mapping files.
> note when i do : "select c from estore.Commande c" i dont get any Commande
> : NullPointerException caused by the fact that the produit that is bundled
> in LigneDeCommande is not loaded from db : could it be the same prob? (more
> exactly if i catch the exception in the method that throw it, in class
> LigneDeCommande, i then can get all the Commandes (but Produits associated
> with em via the usse of the association class LigneDeCommande are null).
> thx very much for ur time.
> <!-- database.xml -->
> <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor JDO Configuration DTD Version
> 1.0//EN" "http://castor.exolab.org/jdo-conf.dtd">
> <database name="castor" engine="mysql">
> <driver class-name="org.gjt.mm.mysql.Driver"
> url="jdbc:mysql://leger-paqueret/castor">
> <param name="user" value="rhill" />
> <param name="password" value="rhill" />
> </driver>
> <mapping href="mapping.xml" />
> </database>
> <!-- mapping.xml -->
> <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
> "http://castor.exolab.org/mapping.dtd">
> <mapping>
> <key-generator name="HIGH/LOW" alias="keygen">
> <param name="table" value="key_table"/>
> <param name="key-column" value="table_name"/>
> <param name="value-column" value="id"/>
> </key-generator>
> <include href="client.xml"/>
> <include href="produit.xml"/>
> <include href="commande.xml"/>
> </mapping>
> <!-- client.xml -->
> <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
> "http://castor.exolab.org/mapping.dtd">
> <mapping>
> <!-- CLIENT MAPPING DEF -->
> <class name="estore.Client" identity="id" key-generator="keygen"
access="db-locked">>
> <cache-type type="count-limited" capacity="10000" />
> <description>Client Definition</description>
> <map-to table="client" xml="client" />
> <field name="id" type="integer" >
> <sql name="id"/>
> <!--<sql name="id" type="integer"/>
> <xml node="attribute"/>-->
> </field>
> <field name="nom" type="string">
> <sql name="nom" type="varchar" dirty="check" />
> <xml node="text" />
> </field>
> <field name="age" type="integer" >
> <sql name="age" type="integer"/>
> <xml node="element"/>
> </field>
> <!-- client-to-cmd relationship -->
> <field name="commandes" type="estore.Commande" required="false"
collection="vector">>
> <sql many-key="client_id"/>
> <xml name="commandes" node="element" />
> </field>
> <!-- end client-to-cmd -->
> </class>
> <!-- END CLIENT MAPPING DEF -->
> </mapping>
> <!-- produit.xml -->
> <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
> "http://castor.exolab.org/mapping.dtd">
> <mapping>
> <!-- _ABSTRACT_ PRODUIT MAPPING DEF -->
> <class name="estore.Produit" identity="id" key-generator="keygen"
access="db-locked">>
> <cache-type type="count-limited" capacity="10000" />
> <description>Abstract Produit Definition</description>
> <map-to table="produit" xml="produit" />
> <field name="id" type="integer">
> <sql name="id" type="integer" />
> <xml name="id" node="attribute"/>
> </field>
> <field name="description" type="string">
> <sql name="description" type="varchar" />
> <xml name="description" node="element" />
> </field>
> <field name="prix" type="double">
> <sql name="prix" type="double" />
> <xml name="prix" node="element" />
> </field>
> <!-- many-to-many produitpromotionnel-to-produit relationship def -->
> <field name="parents" type="estore.ProduitPromotionnel"
> required="false" collection="vector">
> <!--sql name="promo_id" many-table="promo_prod" many-key="produit_id"
/-->>
> <sql name="promo_id" many-key="produit_id" many-table="promo_prod"/>
> <xml name="parents" node="element" />
> </field>
> <!-- end many-to-many produitpromotionnel-to-produit relationship def
-->>
> <!-- one-to-many prd-to-ldc -->
> <field name="ldc" type="estore.LigneDeCommande" required="false"
collection="vector">>
> <sql many-key="prd_id"/>
> <xml name="ldc" node="element" />
> </field>
> <!-- end one-to-many ldc-to-prd -->
> </class>
> <!-- END PRODUIT MAPPING DEF -->
> <!-- BASICPRODUIT MAPPING DEF -->
> <class name="estore.BasicProduit"
> identity="id"
> extends="estore.Produit"
> access="db-locked">
> <cache-type type="count-limited" capacity="10000" />
> <field name="id" type="integer">
> <sql name="id" type="integer" />
> <xml name="id" node="attribute"/>
> </field>
> <map-to table="basic_produit" xml="basicProduit" />
> <field name="marque" type="string">
> <sql name="marque" type="varchar" />
> <xml name="marque" node="element" />
> </field>
> </class>
> <!-- END BASICPRODUIT MAPPING DEF -->
> <!-- PRODUITPROMOTIONNEL MAPPING DEF -->
> <class name="estore.ProduitPromotionnel"
> identity="id"
> extends="estore.Produit"
> access="db-locked">
> <cache-type type="count-limited" capacity="10000" />
> <map-to table="produit_promotionnel" xml="produitPromotionnel" />
> <field name="id" type="integer">
> <sql name="id" type="integer" />
> <xml name="id" node="attribute"/>
> </field>
> <field name="finPromo" type="java.util.Date">
> <sql name="date_fin" type="date" />
> <xml name="dateFin" node="element" />
> </field>
> <!-- many-to-many produitpromotionnel-to-produit relationship def -->
> <field name="embeddedProduits" type="estore.Produit"
> required="true" collection="vector">
> <!--sql name="produit_id" many_table="promo_prod"
> many-key="promo_id"/-->
> <sql name="produit_id" many-key="promo_id" many-table="promo_prod"/>
> <xml name="embeddedProduits" node="element" />
> </field>
> <!-- end many-to-many produitpromotionnel-to-produit relationship def
-->>
> </class>
> <!-- END PRODUITPROMOTIONNEL MAPPING DEF -->
> </mapping>
> <!-- commande.xml -->
> <!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
> "http://castor.exolab.org/mapping.dtd">
> <mapping>
> <!-- COMMANDE MAPPING DEFINITION -->
> <class name="estore.Commande" identity="id"
> key-generator="keygen" access="db-locked" >
> <cache-type type="count-limited" capacity="10000" />
> <map-to table="commande" xml="Commande" />
> <field name="id" type="integer">
> <sql name="id" type="integer" />
> <xml name="id" node="attribute"/>
> </field>
> <field name="total" type="double">
> <sql name="total" type="double" />
> <xml name="total" node="element" />
> </field>
> <field name="client" type="estore.Client">
> <sql name="client_id" />
> <xml name="client" node="element" />
> </field>
> <!-- one-to-many commande-to-lignedecommande relationship def -->
> <field name="lignesDeCommandeList" type="estore.LigneDeCommande"
> required="false" collection="vector">
> <sql many-key="cmd_id"/>
> <xml name="lignesDeCommande" node="element" />
> </field>
> <!-- end one-to-many commande-to-lignedecommande relationship def -->
> </class>
> <!-- END COMMANDE MAPPING DEFINITION -->
> <!-- LIGNEDECOMMANDE MAPPING DEF -->
> <class name="estore.LigneDeCommande" identity="id" access="db-locked"
> key-generator="keygen" depends="estore.Commande" >
> <cache-type type="count-limited" capacity="10000" />
> <map-to table="ligne_de_commande" xml="LigneDeCommande" />
> <field name="id" type="integer">
> <sql name="id" type="integer" />
> <xml name="id" node="attribute"/>
> </field>
> <field name="quantite" type="integer">
> <sql name="quantite" type="integer" />
> <xml name="quantite" node="element" />
> </field>
> <field name="total" type="double">
> <sql name="total" type="double" />
> <xml name="total" node="element" />
> </field>
> <!-- one-to-many commande-to-lignedecommande relationship def -->
> <field name="cmd" type="estore.Commande">
> <sql name="cmd_id"/>
> <xml name="cmdId" node="element"/>
> </field>
> <!-- end one-to-many commande-to-lignedecommande relationship def -->
> <!-- one-to-many prd-to-ldc relationship def -->
> <field name="prd" type="estore.Produit">
> <sql name="prd_id" />
> <xml name="prdId" node="element"/>
> </field>
> <!-- end one-to-many prd-to-ldc relationship def -->
> </class>
> <!-- END LIGNEDECOMMANDE MAPPING DEF -->
> </mapping>
>>From: Oleg Nitz <[EMAIL PROTECTED]>
>>Reply-To: [EMAIL PROTECTED]
>>To: [EMAIL PROTECTED]
>>Subject: Re: [castor-dev] Simple OQL ... ?
>>Date: Mon, 6 Aug 2001 12:15:13 +0300
>>
>>Hi Gilles,
>>
>>First, I'd like to see the Castor log where the full SQL statements
>>are seen.
>>Second, I'd like to see your mapping.xml
>>
>>Oleg
>>
>>gilles dodinet wrote:
>> > hi oleg,
>>
>> > thanks for your help, it works better now : no probs when loading
>>clients
>> > ("select c from Client c") ; but i got another exception when trying to
>>get
>> > the products ("select c from Produit c"). i can't retrieve the exact sql
>> > error ("PersistenceException nested error : [..]"). here's the
>>StackTrace :
>>
>> > java.sql.SQLException: Syntax error or access violation: You have an
>>error
>> > in your SQL syntax near 'null promo_prod ON
>> > produit_promotionnel.id=promo_prod.promo_id,produit WHERE pro' at line 1
>> > at org.gjt.mm.mysql.MysqlIO.sendCommand(MysqlIO.java:497)
>> > at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(MysqlIO.java:550)
>> > at org.gjt.mm.mysql.Connection.execSQL(Connection.java:885)
>> > at
>> >
>>org.gjt.mm.mysql.PreparedStatement.executeQuery(PreparedStatement.java:288)
>> > at
>>org.exolab.castor.jdo.engine.SQLEngine.load(SQLEngine.java:1008)
>> > at
>>org.exolab.castor.persist.ClassMolder.load(ClassMolder.java:646)
>> > at
>>org.exolab.castor.persist.LockEngine.load(LockEngine.java:361)
>> > at
>> >
>>org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:545)
>> > at
>> >
>>org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:479)
>> > at
>>org.exolab.castor.persist.ClassMolder.load(ClassMolder.java:742)
>> > at
>>org.exolab.castor.persist.LockEngine.load(LockEngine.java:361)
>> > at
>> >
>>org.exolab.castor.persist.TransactionContext.load(TransactionContext.java:545)
>> > at
>>org.exolab.castor.persist.QueryResults.fetch(QueryResults.java:229)
>> > at
>> >
>>org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImpl.java:573)
>> > at
>> >
>>org.exolab.castor.jdo.engine.OQLQueryImpl$OQLEnumeration.hasMore(OQLQueryImpl.java:556)
>> > at estore.EstoreMain.oqlQueryTest(EstoreMain.java:24)
>> > at estore.EstoreMain.goGoGo(EstoreMain.java:214)other ex..
>> > org.exolab.castor.jdo.TransactionAbortedException: Nested error:
>> > org.exolab.castor.jdo.PersistenceException: Object, estore.Produit/321,
>> > isn't loaded in the persistence storage!
>> > at estore.EstoreMain.main(EstoreMain.java:193)
>> > org.exolab.castor.jdo.PersistenceException: Object, estore.Produit/321,
>> > isn't loaded in the persistence storage!
>> > at
>>org.exolab.castor.persist.ClassMolder.preStore(ClassMolder.java:1106)
>> > at
>>org.exolab.castor.persist.LockEngine.preStore(LockEngine.java:710)
>> > at
>> >
>>org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java:1146)
>> > at
>>org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:498)
>> > at estore.EstoreMain.oqlQueryTest(EstoreMain.java:48)
>> > at estore.EstoreMain.goGoGo(EstoreMain.java:214)
>> > at estore.EstoreMain.main(EstoreMain.java:193
>>
>> > thx.
>>
>> > --
>> > gilles
>>
>> >>From: Oleg Nitz <[EMAIL PROTECTED]>
>> >>Reply-To: [EMAIL PROTECTED]
>> >>To: [EMAIL PROTECTED]
>> >>Subject: Re: [castor-dev] Simple OQL ... ?
>> >>Date: Sat, 4 Aug 2001 00:29:40 +0300
>> >>
>> >>Hi Gilles,
>> >>
>> >>I guess you use "generic" driver, which is set in database.xml
>> >>
>> >><database name="..." engine="generic" >
>> >>
>> >>Should be
>> >>
>> >><database name="..." engine="mysql" >
>> >>
>> >>MySQL driver doesn't generate "{oj" at all.
>> >>
>> >>Oleg
>> >>
>> >>On Wednesday 01 August 2001 10:43, gilles dodinet wrote:
>> >> > hi..
>> >> >
>> >> > m always in trouble with generation of bad sql queries... i've posted
>> >>this
>> >> > mess several days ago but got no answer.. could someone gimme a
>>clue..
>> >> > thanks.. below the previous post (no change - same error :()
>> >> >
>> >> > (i use mysql 3.23)
>> >> >
>> >> > Castor generates this sql query below (resulting of oql query "select
>>p
>> >> > from estore.Produit p") :
>> >> >
>> >> > SELECT
>> >> >
>> >>produit.id,produit.description,produit.prix,promo_prod.promo_id,ligne_de_co
>> >> >mmande.id FROM
>> >> > {oj produit LEFT OUTER JOIN promo_prod ON
>> >> > produit.id=promo_prod.produit_id
>> >> > LEFT OUTER JOIN ligne_de_commande ON
>> >> > produit.id=ligne_de_commande.prd_id};
>> >> >
>> >> > that throws an SqlException. it think it would have generated this
>>one
>> >> > rather that don't produce sql error :
>> >> >
>> >> > SELECT
>> >> >
>> >>produit.id,produit.description,produit.prix,promo_prod.promo_id,ligne_de_co
>> >> >mmande.id FROM { oj
>> >> > {oj produit LEFT OUTER JOIN promo_prod ON
>> >> > produit.id=promo_prod.produit_id }
>> >> > LEFT OUTER JOIN ligne_de_commande ON
>> >> > produit.id=ligne_de_commande.prd_id};
>> >> >
>> >> > does this problem come from a mapping error or is this a bug in
>>castor??
>> >> > (below portions of mapping files)
>> >> >
>> >> > -------------------- MAPPING -------------
>> >> > in produit.xml (class Produit and inherited classes) :
>> >> >
>> >> > <field name="ldc" type="estore.LigneDeCommande" required="false"
>> >> > collection="vector">
>> >> > <sql many-key="prd_id"/>
>> >> > </field>
>> >> >
>> >> > in commande.xml (class Commande and LigneDeCommande ) :
>> >> >
>> >> > <field name="prd" type="estore.Produit">
>> >> > <sql name="prd_id" />
>> >> > </field>
>> >> > -----------------------------END MAPPING ---------------------
>> >> >
>> >> > thx for your replies.
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > _________________________________________________________________
>> >> > T�l�chargez MSN Explorer gratuitement � l'adresse
>> >> > http://explorer.msn.fr/intl.asp
>> >> >
>> >> > -----------------------------------------------------------
>> >> > If you wish to unsubscribe from this mailing, send mail to
>> >> > [EMAIL PROTECTED] with a subject of:
>> >> > unsubscribe castor-dev
>> >>
>> >>-----------------------------------------------------------
>> >>If you wish to unsubscribe from this mailing, send mail to
>> >>[EMAIL PROTECTED] with a subject of:
>> >> unsubscribe castor-dev
>> >>
>>
>>
>> > _________________________________________________________________
>> > T�l�chargez MSN Explorer gratuitement � l'adresse
>> > http://explorer.msn.fr/intl.asp
>>
>> > -----------------------------------------------------------
>> > If you wish to unsubscribe from this mailing, send mail to
>> > [EMAIL PROTECTED] with a subject of:
>> > unsubscribe castor-dev
>>
>>-----------------------------------------------------------
>>If you wish to unsubscribe from this mailing, send mail to
>>[EMAIL PROTECTED] with a subject of:
>> unsubscribe castor-dev
>>
> _________________________________________________________________
> T�l�chargez MSN Explorer gratuitement � l'adresse
> http://explorer.msn.fr/intl.asp
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev