• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

EJB-QL help

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi - I am upgrading an EJB 1.0 application to EJB 2.0, and am having some difficulty getting my EJB-QL to compile for my additional finder methods. I'm using WSAD 5, and am getting an error: "TABLE_NAME does not have a field COLUMN_NAME". I know for a fact that it does have this column, but how do I let the compiler know this? Here is my query:
<ejb-ql>select object(up) from table_name as up where up.column_name = ?1 and up.other_column = ?2</ejb-ql>
Thanks for the help,
Jamie
[email protected]
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jamie, could you post the parts of your ejb-jar.xml and the vendor-specific deployment descriptor which relate to this particular entity bean?
 
J Waldinger
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure thing. It's a bit long, but here is the section from the ejb-jar.xml:
<entity id="ContainerManagedEntity_1061575772906">
<ejb-name>ProfilePromotionMap</ejb-name>
<home>com.bostoncoach.gtx.ProfilePromotionMapHome</home>
<remote>com.bostoncoach.gtx.ProfilePromotionMap</remote>
<ejb-class>com.bostoncoach.gtx.ProfilePromotionMapBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.bostoncoach.gtx.ProfilePromotionMapKey</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>CO_USER_PROMO</abstract-schema-name>
<cmp-field id="CMPAttribute_1061575892234">
<field-name>sequenceNo</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1061575892235">
<field-name>profileID</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1061575892236">
<field-name>memberCode</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1061575892237">
<field-name>promotionProgram</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1061575892238">
<field-name>lastUpdateKey</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1061575892239">
<field-name>promotionProgramMemberID</field-name>
</cmp-field>
<query>
<description>Converted from IBM version 1.1 extensions.</description>
<query-method>
<method-name>findPromotions</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>select object(up) from CO_USER_PROMO up where up.MEM_C=?1 AND up.USER_ID=?2</ejb-ql>
</query>
<query>
<description>Converted from IBM version 1.1 extensions.</description>
<query-method>
<method-name>findForUpdate</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
<method-param>char</method-param>
</method-params>
</query-method>
<ejb-ql>MEM_C=? AND USER_ID=? AND SEQ_N=?-1</ejb-ql>
</query>
<query>
<description>Converted from IBM version 1.1 extensions.</description>
<query-method>
<method-name>findPromotionsForUpdate</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>MEM_C=? AND USER_ID=? FOR UPDATE</ejb-ql>
</query>
</entity>
Not that these ejb-ql methods were auto-generated from 1.1 finder methods. The first one is the only one I have tried to fix so far - the second two still give vanilla syntax errors - I imagine because the don't have a select clause, etc.
Is the following what you mean by 'vendor-specific' files? The following came from ibm-ejb-jar-ext.xmi. I am not very familiar with this file.
<ejbExtensions xmi:type="ejbext:ContainerManagedEntityExtension" xmi:id="ContainerManagedEntityExtension_18">
<runAsSettings xmi:id="SecurityIdentity_28">
<methodElements xmi:id="MethodElement_72" name="*" type="Unspecified">
<enterpriseBean xmi:type="ejb:ContainerManagedEntity" href="META-INF/ejb-jar.xml#ContainerManagedEntity_1061575772906"/>
</methodElements>
<runAsMode xmi:type="ejbext:UseSystemIdentity" xmi:id="UseSystemIdentity_28"/>
</runAsSettings>
<enterpriseBean xmi:type="ejb:ContainerManagedEntity" href="META-INF/ejb-jar.xml#ContainerManagedEntity_1061575772906"/>
</ejbExtensions>
Thanks very much for your help.
Jamie
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try the following EJB-QL instead:

This is because your EJB-QL should use the field names listed in the ejb-jar.xml instead of the actual database column names. Let us know whether that worked or not.
 
J Waldinger
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lasse,
That worked just fine. (Or, at least, it compiles...)
Thanks very much for your help - I hadn't realized you were supposed to use the EJB field names in the query as opposed to the column names. It strikes me as odd, then, that you still use the table name in the 'from' clause...
Jamie
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


It strikes me as odd, then, that you still use the table name in the 'from' clause...


that's because the abstract schema name is same as the table name in your descriptor.

EJBQL can refer only to the cmp fields, cmr field sand the abstract schema name present in your descriptors.
 
J Waldinger
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help. I have but one remaining error in my new 2.0 compliant ejb-jar file. The error is:
"unknown EJB or ASN name: com.bostoncoach.gtx.AFReceiptRegistryKey"
Here is the query:
<query>
<description>Converted from IBM version 1.1 extensions.</description>
<query-method>
<method-name>findByReservationReferenceNumber</method-name>
<method-params>
<method-param>com.bostoncoach.gtx.AFReceiptRegistryKey</method-param>
</method-params>
</query-method>
<ejb-ql>select object(rr) from AFReceiptRegistry rr where rr.reservationReferenceNumber = ?1</ejb-ql>
</query>
I thought perhaps this was due to a change in the EJB 2.0 spec, however when I created a new query using WSAD's tools, using the same class as a method parameter, it created a query that looked identical to this one. Given that this class (AFReceiptRegistryKey) is located within this project's EJB module, why am I getting this error?
Thanks,
Jamie
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic