[jboss-user] Left-join read-ahead not used though defined
Tamara Cattivelli
Tamara.Cattivelli at mobilcom.de
Mon Jun 9 09:49:31 EDT 2008
Hello everybody,
I have two cmp-ejbs A and B, that have a one-to-many CMR-relation.
Starting from an instance of A i want to pre-load the related B-objects.
I try to optimize this by adding <left-join> tags to jbosscmp-jdbc.xml.
I am using Oracle 9i and jboss-4.0.4.GA.
The left-join query is submitted on the JBOSS console but after that all
data is loaded as if I had not defined an eager-load-group-tag with
left-join for my finder.
I paste a shortened view of my EntityBeans:
/********************************************************************
* Offer Proposal Entity Bean.
*
* <p>This entity bean represents an offer proposal object in the
database.</p>
*
* @author cattitma
*
* @ejb.bean
* name = "OfferProposalEntityBean"
* display-name = "OfferProposalEntityBean"
* generate = "true"
* local-jndi-name = "local/OfferProposalEntityBean"
* view-type = "local"
* type = "CMP"
* transaction-type = "Container"
* reentrant = "false"
* cmp-version = "2.x"
* schema = "OfferProposalEntityBean"
* primkey-field = "iD"
* @ejb.interface
* local-pattern = "OfferProposalEntityBeanLocal"
* @ejb.home
* local-pattern = "OfferProposalEntityBeanLocalHome"
* @ejb.finder
* signature =
"de.mobilcom.offer.repository.proposal.OfferProposalEntityBeanLocal
findOfferProposalByContractIDAndOfferType(java.lang.String
domainShortcut, int contractNo, java.lang.Integer offerType)"
* query = "SELECT OBJECT(a) FROM OfferProposalEntityBean AS a
WHERE a.domain = ?1 AND a.contractNo = ?2 AND a.offerTypeEntity.iD = ?3"
* @jboss.query
* signature =
"de.mobilcom.offer.repository.proposal.OfferProposalEntityBeanLocal
findOfferProposalByContractIDAndOfferType(java.lang.String
domainShortcut, int contractNo, java.lang.Integer offerType)"
* @ejb.util
* generate = "false"
*
* @jboss.persistence
* datasource = "java:/OfferInformation"
* datasource-mapping = "Oracle9i"
* table-name = "OFFER_PROPOSAL"
* @jboss.clustered
* cluster = "false"
* @jboss.read-only
* read-only = "true"
*
*/
public abstract class OfferProposalEntityBean implements EntityBean {
//~ Static fields/initializers
------------------------------------------------------------------------
---------------------
/** Serial version UID. */
private static final long serialVersionUID = 1L;
/***************************************
* Returns offer proposal id.
*
* @return Returns offer proposal id.
*
* @ejb.persistence
* @ejb.transaction
* type = "Required"
* @ejb.interface-method
* view-type = "local"
*
* @jboss.column-name
* name = "ID"
*/
public abstract Integer getID();
/***************************************
* Sets offer proposal id
*
* @param rID the id of the offer proposal object
*
* @ejb.pk-field
* @ejb.persistence
* @ejb.transaction
* type = "Required"
*/
public abstract void setID(Integer rID);
/***************************************
* Gets the offer type object of an offer proposal object.
*
* @return the offer type object of an offer proposal object
*
* @ejb.transaction
* type = "Required"
* @ejb.interface-method
* view-type = "local"
* @ejb.relation
* name = "OfferProposalOfferTypeRelation"
* role-name = "OfferProposal-has-OfferType"
* target-ejb = "OfferTypeEntityBean"
* target-role-name = "OfferType-belongs-to-OfferProposal"
* target-multiple = "no"
* @jboss.relation
* fk-column = "OFFER_TYPE_ID"
* related-pk-field = "iD"
*
*/
public abstract OfferTypeEntityBeanLocal getOfferTypeEntity();
/***************************************
* Sets the offer type object of an offer proposal object.
*
* @param rOfferTypeEntity the offer type object of an offer
proposal object
*
* @ejb.persistence
* @ejb.transaction
* type = "Required"
*/
public abstract void setOfferTypeEntity(OfferTypeEntityBeanLocal
rOfferTypeEntity);
}
and I defined a load group for the finder within tag for entity bean:
<query>
<query-method>
<method-name>findOfferProposalByContractIDAndOfferType</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>int</method-param>
<method-param>java.lang.Integer</method-param>
</method-params>
</query-method>
<jboss-ql><![CDATA[SELECT OBJECT(a) FROM
OfferProposalEntityBean AS a WHERE a.domain = ?1 AND a.contractNo = ?2
AND a.offerTypeEntity.iD = ? 3]]></jboss-ql>
<read-ahead>
<strategy>on-find</strategy>
<eager-load-group>*</eager-load-group>
<left-join cmr-field="offerTypeEntity"
eager-load-group="*"/>
</read-ahead>
</query>
OfferTypeEntity itself is:
/********************************************************************
* Offer Type Entity Bean.
*
* <p>This entity bean represents an offer type object in the
database.</p>
*
* @author cattitma
*
* @ejb.bean
* name = "OfferTypeEntityBean"
* display-name = "OfferTypeEntityBean"
* generate = "true"
* local-jndi-name = "local/OfferTypeEntityBean"
* view-type = "local"
* type = "CMP"
* transaction-type = "Container"
* reentrant = "false"
* cmp-version = "2.x"
* schema = "OfferTypeEntityBean"
* primkey-field = "iD"
* @ejb.interface
* local-pattern = "OfferTypeEntityBeanLocal"
* @ejb.home
* local-pattern = "OfferTypeEntityBeanLocalHome"
* @ejb.finder
* signature = "java.lang.Integer findIDByShortcut(java.lang.String
shortcut)"
* query = "SELECT OBJECT(a) FROM OfferTypeEntityBean AS a WHERE
a.shortcut = ?1"
* @ejb.util
* generate = "false"
* @jboss.persistence
* datasource = "java:/OfferInformation"
* datasource-mapping = "Oracle9i"
* table-name = "OFFER_TYPE"
* @jboss.clustered
* cluster = "false"
* @jboss.read-only
* read-only = "true"
*/
public abstract class OfferTypeEntityBean implements EntityBean {
//~ Static fields/initializers
------------------------------------------------------------------------
---------------------
/** Serial version UID. */
private static final long serialVersionUID = 1L;
/***************************************
* Returns offer type id.
*
* @return Returns offer type id.
*
* @ejb.persistence
* @ejb.transaction
* type = "Required"
* @ejb.interface-method
* view-type = "local"
*
* @jboss.column-name
* name = "ID"
*/
public abstract Integer getID();
/***************************************
* Sets offer type id
*
* @param rID the id of the offer type object
*
* @ejb.pk-field
* @ejb.persistence
* @ejb.transaction
* type = "Required"
*/
public abstract void setID(Integer rID);
/***************************************
* Sets the shortcut for the offer type id.
* @param offerTypeShortcut shortcut for the offer type id
*
* @ejb.persistence
* @ejb.transaction
* type = "Required"
*/
public abstract void setShortcut(String offerTypeShortcut);
/***************************************
* Gets the shortcut for the offer type id.
* @return shortcut of the offer type id
*
* @ejb.persistence
* @ejb.transaction
* type = "Required"
* @ejb.interface-method
* view-type = "local"
*
* @jboss.column-name
* name = "SHORTCUT"
*/
public abstract String getShortcut();
}
In the ServiceBean I resolve the shortcut to an ID by using
findIDByShortcut.
Then I put the ID to the finder of the OfferProposalEntityBean.
OfferProposalEntityBean in the database table OFFER_PROPOSAL has the
fields
ID
...
OFFER_TYPE_ID
and OfferTypeEntityBean has the database fields:
OFFER_TYPE
ID
SHORTCUT
Can anybody help please?
Greetz, Tamara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20080609/b04184f9/attachment.html
More information about the jboss-user
mailing list