Don't worry about it. It was just me... I had misspelled the XDoclet
attribute fk-column (I wrote pk-column), so an empty <column-name> tag was
generated in jbosscmp-jdbc.xml. It has nothing to do with EJBQL as I
thought.

This could be regarded as an XDoclet bug though, so I cc this message to the
XDoclet-user list. As fk-column seems to be required, the @jboss:relation
tag should report an error if it's missing, right?

Martin

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Alexey
> Loubyansky
> Sent: Thursday, June 05, 2003 10:48 AM
> To: Martin Vilcans
> Subject: Re: [JBoss-user] CMR+EJBQL finder generates invalid SQL
>
>
> Hello Martin,
>
> please, submit a bug report on it with all this info.
> If you could also provide a testcase that reproduces this problem that
> would be great.
>
> Thank you,
> alex
>
> Wednesday, June 04, 2003, 6:21:49 PM, Martin Vilcans wrote:
>
> MV> I'm trying to create an entity bean (Score) that has a CMR relation to
> MV> another bean (Celebrity), where one Celebrity can have many
> scores (1:M).
> MV> Also, the Score bean has a finder with the signature Collection
> MV> findByDay(int week, int day). JBoss' implementation of this
> method creates
> MV> invalid SQL, as you can see at the end of this message. The
> database driver
> MV> is mysql-connector-java-3.0.7-stable.
>
> MV> Here are some relevant parts from ejb-jar.xml (XDoclet generated):
>
> MV>       <entity >
> MV>          <ejb-name>Score</ejb-name>
> MV>          .
> MV>          .
> MV>          <reentrant>False</reentrant>
> MV>          <cmp-version>2.x</cmp-version>
> MV>          <abstract-schema-name>Score</abstract-schema-name>
> MV>          <cmp-field >
> MV>             <field-name>week</field-name>
> MV>          </cmp-field>
> MV>          <cmp-field >
> MV>             <field-name>day</field-name>
> MV>          </cmp-field>
> MV>          <cmp-field >
> MV>             <field-name>scoreType</field-name>
> MV>          </cmp-field>
> MV>          <cmp-field >
> MV>             <field-name>celebrityId</field-name>
> MV>          </cmp-field>
> MV>          <cmp-field >
> MV>             <field-name>occurrencies</field-name>
> MV>          </cmp-field>
>
> MV>          <query>
> MV>             <query-method>
> MV>                <method-name>findByDay</method-name>
> MV>                <method-params>
> MV>                   <method-param>int</method-param>
> MV>                   <method-param>int</method-param>
> MV>                </method-params>
> MV>             </query-method>
> MV>             <ejb-ql><![CDATA[SELECT OBJECT(s) FROM Score s
> WHERE s.week=?1
> AND s.day=?2]]>></ejb-ql>
> MV>          </query>
>
> MV>       </entity>
> MV> .
> MV> .
> MV> .
> MV> .
> MV>       <ejb-relation >
> MV>          <ejb-relation-name>celebrity-score</ejb-relation-name>
> MV>          <!-- unidirectional -->
> MV>          <ejb-relationship-role >
>
> MV>
> <ejb-relationship-role-name>one-celebrity-has-many-scores</ejb-rel
> ationship-
> role-name>>
> MV>             <multiplicity>Many</multiplicity>
> MV>             <relationship-role-source >
> MV>                <ejb-name>Score</ejb-name>
> MV>             </relationship-role-source>
> MV>             <cmr-field >
> MV>                <cmr-field-name>celebrity</cmr-field-name>
> MV>             </cmr-field>
> MV>          </ejb-relationship-role>
> MV>          <ejb-relationship-role >
>
> MV>
> <ejb-relationship-role-name>many-scores-belong-to-one-celebrity</e
> jb-relatio
> nship-role-name>>
> MV>             <multiplicity>One</multiplicity>
> MV>             <relationship-role-source >
> MV>                <ejb-name>Celebrity</ejb-name>
> MV>             </relationship-role-source>
> MV>          </ejb-relationship-role>
> MV>       </ejb-relation>
>
> MV> Here are the signatures of some relevant methods in ScoreBean:
>
> MV> /**
> MV>  * @param celebrityId The ID of the celebrity that received
> this score.
> MV>  */
> MV> public abstract void setCelebrityId(int celebrityId);
>
> MV> /**
> MV>  * @return The ID of the celebrity that received this score.
> MV>  * @ejb:pk-field
> MV>  * @ejb:persistent-field
> MV>  */
> MV> public abstract int getCelebrityId();
>
> MV> /**
> MV>  * Sets the celebrity.
> MV>  * @param celebrity The celebrity that received this score.
> MV>  */
> MV> public abstract void setCelebrity(Celebrity celebrity);
>
> MV> /**
> MV>  * Gets the celebrity.
> MV>  *
> MV>  * @return The celebrity that received this score.
> MV>  * @ejb:interface-method
> MV>  * @ejb:relation
> MV>  *   name="celebrity-score"
> MV>  *   role-name="one-celebrity-has-many-scores"
> MV>  *   target-ejb="Celebrity"
> MV>  *   target-role-name="many-scores-belong-to-one-celebrity"
> MV>  *   target-multiple="yes"
> MV>  * @jboss:relation
> MV>  *   pk-column="celebrityId"
> MV>  *   related-pk-field="id"
> MV>  */
> MV> public abstract Celebrity getCelebrity();
>
>
> MV> Here's an extract from the PK class:
>
> MV> public class ScorePK
> MV>    extends java.lang.Object
> MV>    implements java.io.Serializable
> MV> {
> MV>    .
> MV>    .
> MV>    public int week;
> MV>    public int day;
> MV>    public java.lang.String scoreType;
> MV>    public int celebrityId;
> MV>    .
> MV>    .
> MV> }
>
> MV> Here's the code that fails (from a session bean):
>
> MV> Collection scores = scoreHome.findByDay(week, day);
>
> MV> ...which results in the following error in findByDay(int,int).
> MV> Note the comma before "FROM score" in the generated SQL.
>
> MV> 2003-06-04 15:32:05,859 DEBUG
> MV> [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Score]
> Executing SQL:
> MV> SELECT week, day, scoreType, celebrityId,occurrencies,  FROM
> score WHERE
> MV> (week=? AND day=? AND scoreType=? AND celebrityId=?) OR
> (week=? AND day=?
> MV> AND scoreType=? AND celebrityId=?) OR (week=? AND day=? AND
> scoreType=? AND
> MV> celebrityId=?) OR (week=? AND day=? AND scoreType=? AND
> celebrityId=?) OR
> MV> (week=? AND day=? AND scoreType=? AND celebrityId=?)
> MV> 2003-06-04 15:32:05,890 ERROR [org.jboss.ejb.plugins.LogInterceptor]
> MV> TransactionRolledbackException, causedBy:
> MV> java.sql.SQLException: Syntax error or access violation,  message from
> MV> server: "You have an error in your SQL syntax.  Check the manual that
> MV> corresponds to your MySQL server version for the right syntax
> to use near
> MV> 'FROM score WHERE (week=1 AND day=1 AND scoreType='article' AND "
> MV>         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1626)
> MV>         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:886)
> MV> .
> MV> .
>
> MV> This is clearly a bug, but it could some weirdness of mine
> that provokes it.
> MV> I'm new to CMP 2, so it's certainly a possibility. Any ideas?
>
> MV> If I remove the CMR relation findByDay() works fine.
>
>
> MV> Martin Vilcans
> MV> Developer, Jadestone Group AB
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
> thread debugger on the planet. Designed with thread debugging features
> you've never dreamed of, try TotalView 6 free at www.etnus.com.
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to