Finder method to retrieve CMR field?

Hello all!
I have two entity EJBs - one named "Property" and another named "Merchandise".
Property has a one-to-many relationship to Merchandise, and Merchandise is a CMR
field (named "merchandise") in Property. Now I would like to write a finder method
for Property to retrieve the CMR field (Merchandise references). The finder method
is called "findDVD()". The ejb-ql is below:
SELECT DISTINCT OBJECT(merch) FROM Property AS p, IN(p.merchandise) AS merch
WHERE merch.starsMasterTitleId = ?1
AND merch.productTypeCode = 'VIDEO'
AND merch.format = 'DVD'
AND merch.active = 'Y'
AND merch.approved = 'Y'
AND merch.purchaseable = 'Y'
However, I can't seem to get this method to work. Weblogic's EJBC keeps complaining
that the returned collection MUST be of the method owner type - in other words,
I can't return Merchandise references, only Property references.
What am I doing wrong? Is this a limitation in CMR that I didn't know about? Please
help!
I am using WLS 6.1 with SP 1.
Thanks so much!
-B

If you are using ejb2.0 you can do this using a home method and select
method instead of a finder. Finders are limited to returning objects of the
type of ejb they belong to while select methods are not. Select methods
cannot be invoked directly by the clients so you need a home method to wrap
them.
-- Anand
"Brian Wang" <[email protected]> wrote in message
news:3ca3678d$[email protected]..
>
>
Hello all!
I have two entity EJBs - one named "Property" and another named"Merchandise".
Property has a one-to-many relationship to Merchandise, and Merchandise isa CMR
field (named "merchandise") in Property. Now I would like to write afinder method
for Property to retrieve the CMR field (Merchandise references). Thefinder method
is called "findDVD()". The ejb-ql is below:
SELECT DISTINCT OBJECT(merch) FROM Property AS p, IN(p.merchandise) ASmerch
WHERE merch.starsMasterTitleId = ?1
AND merch.productTypeCode = 'VIDEO'
AND merch.format = 'DVD'
AND merch.active = 'Y'
AND merch.approved = 'Y'
AND merch.purchaseable = 'Y'
However, I can't seem to get this method to work. Weblogic's EJBC keepscomplaining
that the returned collection MUST be of the method owner type - in otherwords,
I can't return Merchandise references, only Property references.
What am I doing wrong? Is this a limitation in CMR that I didn't knowabout? Please
help!
I am using WLS 6.1 with SP 1.
Thanks so much!
-B

Similar Messages

  • IN expression in finder method

    is it possible to define a CMP bean to include a custom finder method to retrieve records that satisfy an IN expression, like in:
    SELECT * FROM CUSTOMERS WHERE IDCUST IN( $1 )
    If so? How should I code the finder method in orion-ejb-jar.xml?
    I am using EJB 1.1 under OC4J 9.0.2.1 and JDev 9.0.2
    Thanks,
    Fedro

    You have a solution replacing LIKE with LOCATE function
    LOCATE return the current position into string of ocurrence or substring
    For
    locate('AN','BANDERA')
    Return 1
    Example:
    ...where (?1, e.description) > 0
    Good luck!!

  • EJB Finder View Links and CMR

    Hi,
    Can someone please give me some input on the following warning in the JDeveloper online help!
    "Warning: You cannot create an EJB finder view link that expresses the same relationship as a CMR."
    I'm new to EJB, BC4J and JDeveloper. I created container managed entity beans with local interfaces only to represent my data and relationships. No problems with the mapping so far.
    To test the beans I used Session Facades with remote interfaces and build a sample test client.
    Now I thought I could create EJB Entity Facades, EJB Finder View Objects, EJB Finder View Links and EJB Application Modules to make use of the BC4J framework in order to speed up programming clients (JSP and JClient).
    So I've started studying the JDeveloper online help (which seems to be very useful) and found the above mentioned warning.
    Well, better a warning than nothing at all, but some more explanations would have been even better.
    Is there no need to use view links with CMR?
    How to achieve the same functionality (synchronizing two view objects in a master-detail-relationship) with CMR?
    Do you know any examples? I couldn't find any examples using EJB entity facades in the "sample code" area on OTN.
    Any comments about other (better) architectures are also welcome. Would it be better to use BMP entity beans in conjunction with BC4J?
    Many thanks for your help!
    Regards,
    Eric

    Steven,
    thank you for your reply and suggestions - I'll count on that. If I find time I'll read this book. It seems to be very interesting.
    For educational purposes I'd like to look at both persistence implementation strategies. I agree that it looks definitly easier to use entity objects. Certainly it's also performancewise a better choice.
    Anyhow, could you give me some useful tips for cmp entity beans and finder view objects?
    Is there something which works completely different if I use BC4J on top of it?
    How to implement a master-detail relationship in JClient (Swing) for example?
    What about writing an ejbfinder which doesn't return all, but all data where the foreign key is equal to a parameter passed to the finder method and use this as the source for a detail view object. This could be the primary key of the selected master. Well, I don't know whether this is doable. But that's what comes to my mind spontaneously.
    Would this be a solution? I'm still thinking about the aforementioned warning in the online help regarding view links.
    I guess the problem is that the foreign key is not part of the entity bean as it's not a cmp-field. Instead you have accessor methods to retrieve a related object or a collection of objects.
    I'm sure my questions are not too complicated to answer. It's only hard for a beginner to get an overview.
    I'm quite confident that I'll manage this if I give my best and get some help from knowledgeable people like you Steven.
    Regards,
    Eric

  • EJB-QL with self referencing cmr-field in path identifier fails

    I have a simple application . Only one bean and one relationship. The relationship is a (0..1)-(0..1) for the same bean (self referencing).
    I have a finder method defined with ejb-ql that tries to access the field of one of the cmr fields of the relationship.
    class1Bean is the abstract schema for my bean, and subclass1 is the cmr-field name.
    SELECT OBJECT(obj) FROM class1Bean obj WHERE obj.subclass1.id LIKE ?1
    Here is the error message when trying to deploy:
    Bean: Class1
    Method: java.util.Collection findBySubclass1(java.lang.String)
    EJBQL: SELECT OBJECT(obj) FROM class1Bean obj WHERE obj.subclass1.id LIKE ?1
    Error: JDO75100: Fatal internal error: JDO75341: Missing field meta data for field 'subclass1' of 'Class1'
    This same code deploys fine on JBoss 4.0, and should be legal ejb-ql. Is this a known issue with Sun JSAS?

    Sounds like a problem with the bean metadata. Please check the entity mapping defined in sun-cmp-mappings.xml. Also make sure field sublass1 is defined as CMR everywhere.
    -- markus.

  • Deployment problem with finder method

    I have a problem deploying an application that was working prior to my adding a finder method to one of the entity beans. Here is the Descriptor from the EJB Module that i created (which appears to be ok):
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <display-name>RFXModule</display-name>
    <enterprise-beans>
    <session>
    <display-name>RFXManager</display-name>
    <ejb-name>RFXManager</ejb-name>
    <home>au.com.alphawest.trader.rfx.business.management.RFXManagerHome</home>
    <remote>au.com.alphawest.trader.rfx.business.management.RFXManagerRemote</remote>
    <ejb-class>au.com.alphawest.trader.rfx.business.management.RFXManagerBean</ejb-class>
    <session-type>Stateful</session-type>
    <transaction-type>Container</transaction-type>
    <ejb-local-ref>
    <ejb-ref-name>ejb/rfx/RFXDocument</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>au.com.alphawest.trader.rfx.business.data.RFXDocumentLocalHome</local-home>
    <local>au.com.alphawest.trader.rfx.business.data.RFXDocumentLocal</local>
    <ejb-link>RFXDocument</ejb-link>
    </ejb-local-ref>
    </session>
    <entity>
    <display-name>RFXAttachment</display-name>
    <ejb-name>RFXAttachment</ejb-name>
    <local-home>au.com.alphawest.trader.rfx.business.data.RFXAttachmentLocalHome</local-home>
    <local>au.com.alphawest.trader.rfx.business.data.RFXAttachmentLocal</local>
    <ejb-class>au.com.alphawest.trader.rfx.business.data.RFXDocumentAttachment</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.String</prim-key-class>
    <reentrant>False</reentrant>
    <abstract-schema-name>RFXAttachment</abstract-schema-name>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>type</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>attachmentContents</field-name>
    </cmp-field>
    <primkey-field>name</primkey-field>
    </entity>
    <entity>
    <display-name>RFXDocument</display-name>
    <ejb-name>RFXDocument</ejb-name>
    <local-home>au.com.alphawest.trader.rfx.business.data.RFXDocumentLocalHome</local-home>
    <local>au.com.alphawest.trader.rfx.business.data.RFXDocumentLocal</local>
    <ejb-class>au.com.alphawest.trader.rfx.business.data.RFXDocumentBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>au.com.alphawest.trader.rfx.business.data.RFXDocumentPK</prim-key-class>
    <reentrant>False</reentrant>
    <abstract-schema-name>RFXDocument</abstract-schema-name>
    <cmp-field>
    <field-name>documentGUID</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>creationDate</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>creatorGUID</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>description</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>dueDate</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>emailAddress</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>faxNo</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>locked</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>notes</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>organisationName</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>ownerGUID</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>requestId</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>subject</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>telephoneNo</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>unitGUID</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>buyer</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>organisationGUID</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>sourceId</field-name>
    </cmp-field>
    <ejb-local-ref>
    <ejb-ref-name>ejb/rfx/RFXDocumentAttachment</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>au.com.alphawest.trader.rfx.business.data.RFXAttachmentLocalHome</local-home>
    <local>au.com.alphawest.trader.rfx.business.data.RFXAttachmentLocal</local>
    <ejb-link>RFXAttachment</ejb-link>
    </ejb-local-ref>
    <ejb-local-ref>
    <description>A line item attached to this document</description>
    <ejb-ref-name>ejb/rfx/RFXLineItem</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>au.com.alphawest.trader.rfx.business.data.RFXLineItemLocalHome</local-home>
    <local>au.com.alphawest.trader.rfx.business.data.RFXLineItemLocal</local>
    <ejb-link>RFXLineItemBean</ejb-link>
    </ejb-local-ref>
    <query>
    <description>Find the rfx documents related to the given supplier through it's line items</description>
    <query-method>
    <method-name>findBySupplierId</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </query-method>
    <ejb-ql>SELECT OBJECT(d) FROM RFXDocument AS d, IN(d.lineItems) l WHERE l.supplierGuid = 'DummySupplierGuid'</ejb-ql>
    </query>
    </entity>
    <entity>
    <display-name>RFXLineItem</display-name>
    <ejb-name>RFXLineItem</ejb-name>
    <local-home>au.com.alphawest.trader.rfx.business.data.RFXLineItemLocalHome</local-home>
    <local>au.com.alphawest.trader.rfx.business.data.RFXLineItemLocal</local>
    <ejb-class>au.com.alphawest.trader.rfx.business.data.RFXLineItemBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.math.BigDecimal</prim-key-class>
    <reentrant>False</reentrant>
    <abstract-schema-name>RFXLineItem</abstract-schema-name>
    <cmp-field>
    <field-name>itemId</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>rfxGuid</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>contractCode</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>supplierGuid</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>productCode</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>description</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>quantity</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>units</field-name>
    </cmp-field>
    <primkey-field>itemId</primkey-field>
    </entity>
    </enterprise-beans>
    <relationships>
    <ejb-relation>
    <ejb-relation-name>RFXDocument-RFXAttachment</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>RFXDocument</ejb-relationship-role-name>
    <multiplicity>One</multiplicity>
    <relationship-role-source>
    <ejb-name>RFXDocument</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>attachments</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>RFXAttachment</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <cascade-delete/>
    <relationship-role-source>
    <ejb-name>RFXAttachment</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    </ejb-relation>
    <ejb-relation>
    <ejb-relation-name>RFXDocument-RFXLineItem</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>RFXDocument</ejb-relationship-role-name>
    <multiplicity>One</multiplicity>
    <relationship-role-source>
    <ejb-name>RFXDocument</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>lineItems</cmr-field-name>
    <cmr-field-type>java.util.Set</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>RFXLineItem</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <cascade-delete/>
    <relationship-role-source>
    <ejb-name>RFXLineItem</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>
    <assembly-descriptor>
    <container-transaction>
    <description>This value was set as a default by Sun ONE Studio.</description>
    <method>
    <ejb-name>RFXAttachment</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <description>This value was set as a default by Sun ONE Studio.</description>
    <method>
    <ejb-name>RFXDocument</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <description>This value was set as a default by Sun ONE Studio.</description>
    <method>
    <ejb-name>RFXLineItem</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <description>This value was set as a default by Sun ONE Studio.</description>
    <method>
    <ejb-name>RFXManager</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    I get the following error message when i try to run the EJB Module through the Sun One Verifier Tool:
    Error: ** Error trying to process file: java.lang.RuntimeException: No method found for XML query element: Ambiguous or invalid <query-method>
    java.lang.RuntimeException: No method found for XML query element: Ambiguous or invalid <query-method>
    at com.sun.enterprise.deployment.xml.EjbNode.parseQueries(EjbNode.java:700)
    at com.sun.enterprise.deployment.xml.EjbNode.completeLoadingDescriptor(EjbNode.java:671)
    at com.sun.enterprise.deployment.xml.EjbBundleNode.completeLoadingDescriptor(EjbBundleNode.java:524)
    at com.iplanet.ias.deployment.EjbBundleXmlReader.load(EjbBundleXmlReader.java:249)
    at com.iplanet.ias.deployment.EjbBundleXmlReader.loadStdAloneModule(EjbBundleXmlReader.java:162)
    at com.sun.enterprise.tools.verifier.Verifier.openEjbJar(Verifier.java:2421)
    at com.sun.enterprise.tools.verifier.Verifier.loadEjbJar(Verifier.java:1318)
    at com.sun.enterprise.tools.verifier.Verifier.loadJar(Verifier.java:866)
    at com.sun.enterprise.tools.verifier.gui.MainPanel.run(MainPanel.java:187)
    at java.lang.Thread.run(Thread.java:536)
    Look in file "RFXModule.jar_verified.xml" for detailed results on test assertions.
    Any help would be greatly appreciated.
    Mark Hesketh

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    The title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    Some private information, such as your name, may appear in the log. Anonymize before posting.

  • IllegalStateException for cmr-fields due to diff txns

    Hi,
    I am using cmp entity beans on WebLogic Server 7. Assume bean 'A' to bean 'B' is
    1:M
    I get the following exception while trying to create bean B -
    <Exception in MyClass.createB(): javax.ejb.EJBException: EJB Exception:: java.lang.IllegalStateException:
    Attempted to access the collection valued cmr-field, 'b', for bean, 'A', in a transaction
    that is different than the transaction in which the collection was materialized.
    All access to the collection must be performed during the transaction in which the
    collection was initially retrieved.
    I upgraded from 6.1 sp2 to 7 and got this exception. I never got it in wls 6.1 sp2.
    Since my beans are cmp, the container handles all transactions and I have specified
    <trans-attribute>Required</trans-attribute> in ejb-jar.xml.
    How can I ensure that the container uses the same txn for accessing all cmr fields?
    I will appreciate if anyone can point me in the right direction.
    Thanks!

    I figured out the problem. The caller that calls methods on the entity bean interfaces
    has to wrap the calls inside a transaction.
    "Roy Lu" <[email protected]> wrote:
    >
    I am getting the exact same exception. Is this a bug or am I missing
    something?
    Thanks.
    "A D" <[email protected]> wrote:
    Hi,
    I am using cmp entity beans on WebLogic Server 7. Assume bean 'A' to
    bean 'B' is
    1:M
    I get the following exception while trying to create bean B -
    <Exception in MyClass.createB(): javax.ejb.EJBException: EJB Exception::
    java.lang.IllegalStateException:
    Attempted to access the collection valued cmr-field, 'b', for bean,'A',
    in a transaction
    that is different than the transaction in which the collection was materialized.
    All access to the collection must be performed during the transaction
    in which the
    collection was initially retrieved.
    I upgraded from 6.1 sp2 to 7 and got this exception. I never got itin
    wls 6.1 sp2.
    Since my beans are cmp, the container handles all transactions and I
    have specified
    <trans-attribute>Required</trans-attribute> in ejb-jar.xml.
    How can I ensure that the container uses the same txn for accessingall
    cmr fields?
    I will appreciate if anyone can point me in the right direction.
    Thanks!

  • Probloem with cmr field

    Hi friends i am doing one small project using weblogic,ejb and mysql
    When i try to retirive values from the table using CMR i am getting the error of
    bolderrorAttempt to serialize a collection that implements a cmr-field. Collections managed by the CMP RDBMS persistence manager may not be passed directly to a remote client.*bold*
    My EJBQL is
    bold
    **@ejb.finder
    * query="SELECT OBJECT(a) FROM NeworderSCHEMA as a WHERE a.po_no = ?1"
    * signature="java.util.Collection findByPo_noCMR(java.lang.String po_no)" bold
    My Session Bean who is calling this is NeworderBean
    bold
    public java.util.Collection getAllPendingOrdersnew()
                   throws javax.naming.NamingException, javax.ejb.FinderException {
              java.util.Collection pendorders = new java.util.ArrayList(); //to return all pending orders to web-client
              java.util.ArrayList pendorder = null; //to put one pending order attributes to collection of pendorders
              NeworderLocalHome home = NeworderUtil.getLocalHome();
              NeworderLocal localObject = null;
              java.util.Collection c = home.findByPo_noCMR("91");
              //loop to take one pendingorderLocal at a time and populate pedningorders collection
              for(java.util.Iterator i = c.iterator(); i.hasNext(); ){
                   //populating the arraylist with customer attributes
                   localObject = (NeworderLocal) i.next();
                   pendorder = new java.util.ArrayList();
                   pendorder.add(localObject.getPrimaryKey()); //index 0 -- stores the po_no
                   pendorder.add(localObject.getPo_date()); //index 1 -- stores the po_date
                   pendorder.add(localObject.getPo_status());//index 2 -- stores the po_status
                   pendorder.add(localObject.getPo_suppcode()); //index 3 -- stores the supplier code
                   pendorder.add(localObject.getUserid());//index 4 -- stores the user id
                   pendorder.add(localObject.getTimestamp());//index 5 -- stores the created date
                   pendorder.add(localObject.getItems());//for order detail table
                   //one customer data is filled. so, add this to customers arraylist
                   pendorders.add(pendorder);
              //return the collection of all customers
              return pendorders;
         }*bold*
    Please help me

    When i give with out @ejb-interface i am getting error of
    Exception:weblogic.management.ApplicationException: Prepare failed. Task Id = 29
         Module: New_OrderEJB.jar     Error: [EJB:011024]The XML parser encountered an error in your deployment descriptor. Please ensure that your deployment descriptor corresponds to the format in the DTD. The error was:
    Error parsing file 'META-INF/ejb-jar.xml' at line: 247 column: 26. XML document structures must start and end within the same entity..
    ejb-jar.xml file content is
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar id="ejb-jar_1">
    <description><![CDATA[New_OrderEJB generated by eclipse wtp xdoclet extension.]]></description>
    <display-name>New_OrderEJB</display-name>
    <enterprise-beans>
    <!-- Session Beans -->
    <session id="Session_Head">
    <description><![CDATA[An EJB named Head]]></description>
    <display-name>Head</display-name>
    <ejb-name>Head</ejb-name>
    <home>order.headsess.HeadHome</home>
    <remote>order.headsess.Head</remote>
    <local-home>order.headsess.HeadLocalHome</local-home>
    <local>order.headsess.HeadLocal</local>
    <ejb-class>order.headsess.HeadSession</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    <!--
    To add session beans that you have deployment descriptor info for, add
    a file to your XDoclet merge directory called session-beans.xml that contains
    the <session></session> markup for those beans.
    -->
    <!-- Entity Beans -->
    <entity id="ContainerManagedEntity_Neworder">
    <description><![CDATA[<!-- begin-xdoclet-definition -->]]></description>
    <ejb-name>Neworder</ejb-name>
    <home>order.headentity.NeworderHome</home>
    <remote>order.headentity.Neworder</remote>
    <local-home>order.headentity.NeworderLocalHome</local-home>
    <local>order.headentity.NeworderLocal</local>
    <ejb-class>order.headentity.NeworderCMP</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.String</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>NeworderSCHEMA</abstract-schema-name>
    <cmp-field id="CMPAttribute_1">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field po_no Returns the po_no]]></description>
    <field-name>po_no</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_2">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field po_date Returns the po_date]]></description>
    <field-name>po_date</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_3">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field po_suppcode Returns the po_suppcode]]></description>
    <field-name>po_suppcode</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_4">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field po_reference_no Returns the po_reference_no]]></description>
    <field-name>po_reference_no</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_5">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field userid Returns the userid]]></description>
    <field-name>userid</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_6">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field timestamp Returns the timestamp]]></description>
    <field-name>timestamp</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_7">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field approved_by Returns the approved_by]]></description>
    <field-name>approved_by</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_8">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field po_status Returns the po_status]]></description>
    <field-name>po_status</field-name>
    </cmp-field>
    <primkey-field>po_no</primkey-field>
    <query>
    <query-method>
    <method-name>findAll</method-name>
    <method-params>
    </method-params>
    </query-method>
    <ejb-ql><![CDATA[SELECT OBJECT(a) FROM NeworderSCHEMA as a]]></ejb-ql>
    </query>
    <query>
    <query-method>
    <method-name>findByStatus</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </query-method>
    <ejb-ql><![CDATA[SELECT OBJECT(a) FROM NeworderSCHEMA as a WHERE a.po_status = ?1]]></ejb-ql>
    </query>
    <query>
    <query-method>
    <method-name>findByPo_no</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </query-method>
    <ejb-ql><![CDATA[SELECT OBJECT(a) FROM NeworderSCHEMA as a WHERE a.po_no = ?1]]></ejb-ql>
    </query>
    <query>
    <query-method>
    <method-name>findByPo_noCMR</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </query-method>
    <ejb-ql><![CDATA[SELECT OBJECT(a) FROM NeworderSCHEMA as a WHERE a.po_no = ?1]]></ejb-ql>
    </query>
         <!-- Write a file named ejb-finders-NeworderBean.xml if you want to define extra finders. -->
    </entity>
    <entity id="ContainerManagedEntity_OrderDetail">
    <description><![CDATA[<!-- begin-xdoclet-definition -->]]></description>
    <ejb-name>OrderDetail</ejb-name>
    <home>order.detailentity.OrderDetailHome</home>
    <remote>order.detailentity.OrderDetail</remote>
    <local-home>order.detailentity.OrderDetailLocalHome</local-home>
    <local>order.detailentity.OrderDetailLocal</local>
    <ejb-class>order.detailentity.OrderDetailCMP</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Integer</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>OrderDetailSCHEMA</abstract-schema-name>
    <cmp-field id="CMPAttribute_9">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field serial_no Returns the serial_no]]></description>
    <field-name>serial_no</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_10">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field po_no Returns the po_no]]></description>
    <field-name>po_no</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_11">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field model_code Returns the model_code]]></description>
    <field-name>model_code</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_12">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field color_code Returns the color_code]]></description>
    <field-name>color_code</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_13">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field order_qty Returns the order_qty]]></description>
    <field-name>order_qty</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_14">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field prod_yr Returns the prod_yr]]></description>
    <field-name>prod_yr</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_15">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field prod_mth Returns the prod_mth]]></description>
    <field-name>prod_mth</field-name>
    </cmp-field>
    <cmp-field id="CMPAttribute_16">
    <description><![CDATA[<!-- begin-user-doc --> CMP Field recd_qty Returns the recd_qty]]></description>
    <field-name>recd_qty</field-name>
    </cmp-field>
    <primkey-field>serial_no</primkey-field>
    <query>
    <query-method>
    <method-name>findAll</method-name>
    <method-params>
    </method-params>
    </query-method>
    <ejb-ql><![CDATA[SELECT OBJECT(a) FROM OrderDetailSCHEMA as a]]></ejb-ql>
    </query>
         <!-- Write a file named ejb-finders-OrderDetailBean.xml if you want to define extra finders. -->
    </entity>
    <!--
    To add entity beans that you have deployment descriptor info for, add
    a file to your XDoclet merge directory called entity-beans.xml that contains
    the <entity></entity> markup for those beans.
    -->
    <!-- Message Driven Beans -->
    <!--
    To add message driven beans that you have deployment descriptor info for, add
    a file to your XDoclet merge directory called message-driven-beans.xml that contains
    the <message-driven></message-driven> markup for those beans.
    -->
    </enterprise-beans>
    <!-- Relationships -->
    <relationships id="Relationships_1">
    <ejb-relation id="EJBRelation_1">
    <ejb-relation-name>Neworder</ejb-relation-name>
    <ejb-relationship-role id="EJBRelationshipRole_1">
    <ejb-relationship-role-name>Order-contains-Items</ejb-relationship-role-name>
    <multiplicity>One</multiplicity>
    <relationship-role-source id="RoleSource_1">
    <ejb-name>Neworder</ejb-name>
    </relationship-role-source>
    <cmr-field id="CMRField_1">
    <cmr-field-name>items</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role id="EJBRelationshipRole_2">
    <ejb-relationship-role-name>item-contained-in-order</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <cascade-delete/>
    <relationship-role-source id="RoleSource_2">
    <ejb-name>OrderDetail</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    </ejb-relation>
    <ejb-relation id="EJBRelation_2">
    <ejb-relation-name>Order-Items</ejb-relation-name>
    <ejb-relationship-role id="EJBRelationshipRole_3">
    <ejb-relationship-role-name>Order-has-Items</ejb-relationship-role-name>
    <multiplicity>One</multiplicity>
    <relationship-role-source id="RoleSource_3">
    <ejb-name>Neworder</ejb-name>
    </relationship-role-source>
    <cmr-field id="CMRField_2">
    <cmr-field-name>itemValue</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role id="EJBRelationshipRole_4">
    <multiplicity>Many</multiplicity>
    <relationship-role-source id="RoleSource_4">
    <ejb-name>
    once again thank you

  • How to retrieve all fields from Entiy Bean

    Is there a simpler way to retrieve all fields from the entity bean than calling each individual get method?
    I need to retrieve the entire record not the contents of the entire table.
    Though, I may eventually need to do that also.
    I have 56 fields on this table. It does not make sense to code a get statement for every field.
    If you can direct me to sample code that would be good.
    Also, are there any good examples out there of how to create an entity bean or session bean using a local interface?
    Thanks,
    Jim

    I think you are confusing an EJB with a DAO.
    If you want to access the database why not just use JDBC?

  • CMP Entity Bean with ejb-ql finder methods and INFORMIX database

    Hi,
    I have some CMP Entity Beans with finder methods defined in ejb-ql. In my ejb-jar, within <entity> definitions I have something like:
        <entity>
          <abstract-schema-name>BeanName</abstract-schema-name>
          <cmp-field><field-name>fieldOne</field-name></cmp-field>
          <cmp-field><field-name>fieldTwo</field-name></cmp-field>
          <query>
            <query-method>
              <method-name>findAll</method-name>
              <method-params></method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM BeanName o</ejb-ql>
          </query>
        <entity>
    And in persistent.xml:
    <db-properties>
         <data-source-name>datasource_name</data-source-name>
    </db-properties>
    <entity-bean>
         <ejb-name>BeanName</ejb-name>
         <table-name>table_name</table-name>
         <field-map key-type="NoKey">
         <field-name>fieldOne</field-name>
         <column><column-name>column_one</column-name></column>
          </field-map>
         <field-map key-type="NoKey">
         <field-name>fieldTwo</field-name>
         <column><column-name>column_two</column-name></column>
          </field-map>
          <finder-descriptor>
              <method-name>findAll</method-name>
              <method-params/>
         </finder-descriptor>
    Once deployed, on server side, I can found a java source file (with corresponding compiled class file) in path:
    j2ee/cluster/server0/apps/companyName/MyEARApp/EJBContainer/temp/temp38837373733/route/to/package/
    with names:
    BeanName0_0pm.java
    BeanName0_0PM.class
    and the generated java file contains this code:
      public java.util.Enumeration ejbFindAll() throws javax.ejb.FinderException, javax.ejb.EJBException  {
        TransactionContext tc = pm.getTransactionContext();
        Connection conn = null;
        PreparedStatement pSt = null;
        ResultSet ejb_rs = null;
        int status = javax.transaction.xa.XAResource.TMSUCCESS;
        try {
          conn = pm.getConnectionForFindMethod();
          pSt = conn.prepareStatement("SELECT \"O\".\"COLUMN_ONE\",\"O\".\"COLUMN_TWO\", FROM \"TABLE_NAME\" \"O\"");
          ejb_rs = pSt.executeQuery();
    I'm trying to call this method but it throws a SQLException when preparing the statement.
    It seems that Informix does not like this SQL syntax because of upper case names, doble quotes on table alias, or something else.
    When editing persistent.xml in netweaver, I can define the element <datasource-vendor> as ORACLE, SAPDB, MS_SQL_SERVER, DB2_UDB_AS400 or DB2_UDB_OS390 but INFORMIX is not an accepted value.
    Is there any way to define how this SQL query is build?
    Thanks in advance.

    The return type of the finder method defined in the remote home interface is either the entity bean's remote interface or a collection of objects implementing the entity bean's remote interface. The return type of the finder method defined in the local home interface is either the entity bean's local interface or a collection of objects implementing the entity bean's local interface

  • How to retrieve the Field Name of a Table

    Hi guys,
    I'm trying to retrieve the field name of a table in java, but i don't know how to do it. Could somebody help me?Let say i have a table name Itemmaster, then
    i want to retrieve its field and display to dos prompt.
    Example :
    Item No.
    Description
    Quantity
    It is possible to retrieve the fields?
    What could be the possible command in java using packages Java.sql.*?
    Thanks in advanced...
    Best regards,
    Dharry

    The ResultSet class, which is how query results are returned in JDBC, has methods to get at the metadata for the table queried, including column names:
    ResultSet resultSet=statement.executeQuery("select * from table");
    resultSetMetadata=resultSet.getMetaData();
    resultSetMetadata.getColumnLabel(column+1);

  • Binary Data Type in finder methods for CMP beans

    How to write an equivalent ejb-ql query in ejb-jar.xml for a finder method accepting
    a byte array as a parameter. The finder method is for a cmp-field mapped to a
    database field with binary data type

    Using CMP 2.x, your custom finder and select methods are implemented by the container based on the EJB QL query you provide in the ejb-jar.xml. In CMP 1.1, there was no portable way to express the semantics of the query, so most vendors had a vendor-specific syntax for describing the query.
    See chapter 27 of the J2EE 1.4 Tutorial for some examples of using EJB QL :
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
    --ken
    Kenneth Saks
    J2EE SDK Team
    SUN Microsystems

  • Retrieve Filter Field from af:Query Component

    I'm using an af:query component on my form and have pre-definied ViewCriterias that load the page. Each ViewCriteria contains one field that is used across all of my search criterias....I need to be able to retrieve this field in my backing bean and get the value of it. I need to know what the user is searching on for this one particular field (i.e. which will always be available in the af:query. I have the queryListener pointing to a method in my backing bean...does someone have some sample code on how to access the fields used in the query and then access the value of one in particular?
    public void headerQueryListener(QueryEvent queryEvent) {
    CommonHelperFunctions.resolveMethodExpression("#{bindings.AllChangeOrdersQuery1.processQuery}",
    null, new Class[] {QueryEvent.class}, new Object[] {queryEvent});
    // What can I add here to retrieve a filter field and then retrieve it's value??
    The queryListener on my af:query component then calls this headerQueryListener in my backing bean.
    Thanks.

    I have tried the following code just messing around:
    QueryModel varQueryModel = getQueryHeader().getModel();
    List<AttributeDescriptor> attributeDescriptors = varQueryModel.getAttributes();
    AttributeDescriptor ad = attributeDescriptors.get(3);
    The attributeDescriptors has the information that I need. I can see the elements in my query and I can see that element 3 is the one I want, but it doesn't have the an _attrDef name but it does have an mAttrName and the mValues[0] mValue has the value that I'm looking for, but I'm having trouble figuring out how to access this information and retrieve what i actually need.  I'm very new to Java and ADF so sorry if this is a basic Java question, but if anyone could point me to an example or some sample code, I really appreciate it.
    Thanks in Advance.

  • Find table for a structure field

    Hi,
    I need to find table for field Q0743-OFFR1. I tried using tcode SE15, but was not able to find any table where the field is used.
    Is there any other method of finding a table for a structure field.
    Any pointers in this regard would be helpful.
    Thanks,
    Saher

    Hi,
    when u open the structure , u will find the tab " Component " in that you
    will find "Data Element" column which hold the data element of the structure
    component , now double click on the respective "Data Element " and that will
    open up the Data Element Page in which u will find a "Where Used List" icon
    , click on that, this will now display you the list, select the TABLE LIST
    Check box and execute, which will subsequently display you all the the table
    names which has "specified" data element's component as field
    Hope this will Help you.
    Regards,
    Kiran

  • Ejb-ql in finder method

    Hi all,
    I have a table which has no primary key then I made the complex primary key by 2 fields which are foriegn keys(Primary key in other tables or entity beans) , the problem is that whenever I write a finder method ,I face with an error telling these 2 fields are not cmp field .
    could you please guide me .In addition I need a finder method which gets 2 parameters (the 2 foriegn keys) then return the the raw.
    Not having known so much about reletionship in EJB ,please give me a sample code
    Cheers
    Pooyan

    What do you expect us to tell without even a small description of your problem (a stack trace or error message would have been helpful). Anyway, read here... you should find some sample code too.
    http://www.theserverside.com/books/masteringEJB/index.jsp

  • Finder-method in orion-ejb-jar.xml

    Hi,
    Is there a way to let jdeveloper 9.0.3 preview to automatically generate finder-method descriptors for us? When I was developing a cmp-based entity bean, although I defined the ejb-ql in ejb-jar.xml, JDeveloper still just generated the first orion-ejb-jar.xml shown below. In the first orion-ejb-jar.xml, there is no definition for any finder-method. I have to manually add my own definition to it, which is shown in the second orion-ejb-jar.xml. I know that the oc4j container will generate the finder-method after deployment, but in some situation it generated incorrect finder-method descriptors. One of such situation is the between query like "between ?1 and ?2". Anyway, if JDeveloper can generate the finder-method during development, then we can know whether the descriptor is correct or not before deployment, and we can make modifications before deploying it to oc4j server.
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" " " target="_new">http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd"> <orion-ejb-jar>
    <enterprise-beans>
    <entity-deployment name="BooksBean" data-source="jdbc/bookDS" table="BOOKS">
    <primkey-mapping>
    <cmp-field-mapping>
    <fields>
    <cmp-field-mapping name="isbn" persistence-name="ISBN" persistence-type="NUMBER(10)"/>
    </fields>
    </cmp-field-mapping>
    </primkey-mapping>
    <cmp-field-mapping name="isbn" persistence-name="ISBN" persistence-type="NUMBER(10)"/>
    <cmp-field-mapping name="title" persistence-name="TITLE" persistence-type="VARCHAR2(50)"/>
    <cmp-field-mapping name="author" persistence-name="AUTHOR" persistence-type="VARCHAR2(50)"/>
    <cmp-field-mapping name="price" persistence-name="PRICE" persistence-type="NUMBER(6,2)"/>
    </entity-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping name="&lt;default-ejb-caller-role>" impliesAll="true"/>
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" " " target="_new">http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd"> <orion-ejb-jar>
    <enterprise-beans>
    <entity-deployment name="BooksBean" data-source="jdbc/bookDS" table="BOOKS">
    <primkey-mapping>
    <cmp-field-mapping name="isbn" persistence-name="ISBN" persistence-type="NUMBER(10)"/>
    </primkey-mapping>
    <cmp-field-mapping name="isbn" persistence-name="ISBN" persistence-type="NUMBER(10)"/>
    <cmp-field-mapping name="title" persistence-name="TITLE" persistence-type="VARCHAR2(50)"/>
    <cmp-field-mapping name="author" persistence-name="AUTHOR" persistence-type="VARCHAR2(50)"/>
    <cmp-field-mapping name="price" persistence-name="PRICE" persistence-type="NUMBER(6,2)"/>
    <finder-method query="select * from books where $author like $1">
    <method>
    <ejb-name>BooksBean</ejb-name>
    <method-name>findByAuthor</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </method>
    </finder-method>
    <finder-method query="select * from books where $title like $1">
    <method>
    <ejb-name>BooksBean</ejb-name>
    <method-name>findByTitle</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </method>
    </finder-method>
    <finder-method query="$price between $1 and $2">
    <method>
    <ejb-name>BooksBean</ejb-name>
    <method-name>findByPriceRange</method-name>
    <method-params>
    <method-param>double</method-param>
    <method-param>double</method-param>
    </method-params>
    </method>
    </finder-method>
    </entity-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping impliesAll="true" name="&lt;default-ejb-caller-role>"/>
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>
    Any one has any idea?
    Thanks,
    Jingzhi

    Jingzhi -- If you define the correct EJB-QL you should get the correct SQL generated for the finder. If that's not happening can you verify it against the OC4J v903 production release and see if it is still happening. I don't know if this helps with the JDeveloper problem specifically but if you don't need to create your own finders then that I hope should help.
    Thanks -- Jeff

Maybe you are looking for