1 Reply Latest reply on Feb 23, 2005 12:22 PM by Frank Liu

    Dependent Value Classes in jboss-ql

    Frank Liu Newbie

      One of my EJB requires two columns as the primary key. So I created a custom class with the two fields and use DVC to populate it as two columns in the database table. Anyway my finders require comparison to one of the field in the DVC class, so what is the syntax for that in jboss-ql?

      <dependent-value-classes>
       <dependent-value-class>
       <description>BidKey</description>
       <class>AuctionWeb.Bids.BidKey</class>
       <property>
       <property-name>orderId</property-name>
       <column-name>OrderId</column-name>
       </property>
       <property>
       <property-name>companyId</property-name>
       <column-name>CompanyId</column-name>
       </property>
       </dependent-value-class>
      </dependent-value-classes>
      
      <entity>
       <ejb-name>BidEJB</ejb-name>
       <table-name>Bid</table-name>
       <cmp-field>
       <field-name>bidKey</field-name>
       <property>
       <property-name>orderId</property-name>
       <column-name>OrderId</column-name>
       </property>
       <property>
       <property-name>companyId</property-name>
       <column-name>CompanyId</column-name>
       </property>
       <not-null/>
       </cmp-field>
       <cmp-field>
       <field-name>price</field-name>
       <column-name>Price</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>bidTime</field-name>
       <column-name>BidTime</column-name>
       </cmp-field>
       <cmp-field>
       <field-name>comments</field-name>
       <column-name>Comments</column-name>
       </cmp-field>
       <query>
       <query-method>
       <method-name>findByCompany</method-name>
       <method-params>
       <method-param>java.lang.Integer</method-param>
       </method-params>
       </query-method>
       <jboss-ql>
       <![CDATA[
       SELECT OBJECT(bd)
       FROM Bid bd
       WHERE bd.bidKey.companyId = ?1
       ]]>
       </jboss-ql>
       </query>
      
       <query>
       <query-method>
       <method-name>findByOrder</method-name>
       <method-params>
       <method-param>java.lang.Integer</method-param>
       </method-params>
       </query-method>
       <jboss-ql>
       <![CDATA[
       SELECT OBJECT(bd)
       FROM Bid bd
       WHERE bd.bidKey.orderId = ?1
       ]]>
       </jboss-ql>
       </query>
      </entity>
      
      


        • 1. Re: Dependent Value Classes as CMR?
          Frank Liu Newbie

          Okay I found another problem inserting into table with the EJB that has DVC as it's primary key. The DVC field is broken into two different columns in the database these columns are also used for CMR fields. JBoss seem to work just fine if the CMR columns are also CMP columns. But if CMR column is one of the property of a CMP column that is a DVC, JBoss doesn't seem to recognize this and will duplicate the column table name on insert. That is one set of column names for the CMP field then another set for the CMR field even though these columns are the same. If the CMP field is not a DVC, jboss correctly recognize this and will not duplicate the column name on insert.