Partial queries with CMP beans

Hi,
I have a custom finder method called findBySurname which takes in a string. I've set up the partial query to read: surname=$1 (where surname is the cmp field mapped to the table column). I've checked the orion-ejb-jar.xml file and the query has been inserted. However, when I run the sample client, I get a resultset that contains all the records in the table! I've got similar finder methods on 3 CMP beans and they all do the same thing. Is this a bug in the Release Candidate 2 version of Jdeveloper (which I'm using) or am I missing something?
Thanks in advance,
Gillian

Known Issues along with the bug # are documented in the release notes of the product.
You can see the release notes from Help menu of the product.
raghu
JDev Team

Similar Messages

  • Handling BLOBs with CMP Beans

    Hi,
    is there a detailed example how to handle Blob's with CMP Beans?
    I'm trying to store some images in a database (Oracle 9i) using CMP Beans and Oracle iAS 9.03 and jdk 1.4.
    Thanks in advance
    Jens

    We are currently developing a How-To on this and will put this on OTN.
    1) Code snippet from Bean Class:
    public abstract byte[] getPicture();
    public abstract void setPicture(byte[] newPicture);
    public Long ejbCreate(Long empno, byte[] newPicture)
    setEmpno(empno);
    setPicture(newPicture);
    return empno;
    public void ejbPostCreate(Long empno, byte[] newPicture)
    2) Mapping in the orion-ejb-jar.xml:
    <entity-deployment name="EmployeePicture" data-source="jdbc/OracleDS" table="EMPPIC">
    <primkey-mapping>
    <cmp-field-mapping name="empno" persistence-name="EMPNO" persistence-type="NUMBER(8)"/>
    </primkey-mapping>
    <cmp-field-mapping name="empno" persistence-name="EMPNO" persistence-type="NUMBER(8)"/>
    <cmp-field-mapping name="picture" persistence-name="PICTURE" persistence-type="BLOB(4000)"/>
    </entity-deployment>
    3) Create the client to create the bean:
    Long empNo =(Long) Long.valueOf(request.getParameter("EmpNo"));
    String fileName =request.getParameter("ImageFileName");
    InputStream is = new BufferedInputStream(new FileInputStream(fileName));
    int len;
    // Initialize byte array
    byte byteValue[] = new byte[2048000];
    len = is.read(byteValue);
    EmployeePictureLocal employeePicture = empHome.create(empNo , byteValue);
    out.println("Picture of Emp#:"+empNo +" successfully Loaded into DB <br> <br>");
    4) Code snippet to view the image :
    Long empNo =(Long) Long.valueOf(request.getParameter("EmpNo"));
    out.println("Picture of Emp#"+empNo);
    EmployeePictureLocal emp = empHome.findByPrimaryKey(empNo);
    response.setContentType("image/jpeg");
    OutputStream os = null;
    os = response.getOutputStream() ;
    byte[] pic = emp.getPicture();
         os.write(pic);
    os.close();
    os = null;
    Let me know if this helps
    thanks
    Debu

  • Junk Characters while persisting data with CMP beans

    Hi
    when i am entering some data and saving the data to the data base using CMP beans ,its converting the data to junk characters like ��@y some times .Do you have any idea why its happening ?pls respond asap

    whats the data type you are using ? whats the App. server, the database ?

  • Problem with CMP bean and MySQL: please help me!!!

    Hi,
    I am using J2EE Sun server 1.3 and Mysql 4.0 database with its MySQL Connector/J 3.0.
    The driver connection to the database is fine since "Generate Default SQL" in deploytool gives "SQL generation complete".
    However, I can't have a simple row with one text field called test being created in my mysql table called test.
    Of course , the mysql server is started and the test table set for use.
    Here is my code (I try to access my database from a servlet using a CMP Entity bean):
    try{
    Context initial = new InitialContext();
    Object objref = initial.lookup(EntityHome.JNDI_NAME);
    EntityHome home = (EntityHome)PortableRemoteObject.narrow(objref,EntityHome.class);     
    Entity test= home.create("zob");               
    /*EntityHome home = (EntityHome)PortableRemoteObject.narrow(objref,EntityHome.class);     
    catch (Exception ex){                                                                out.println("exception message : " + ex.getMessage()+"</body></html>");}
    I get the following exception message :
    RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: nested exception is: java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '"EntityCMPTable" WHERE "test" = 'zob'' at line 1"; nested exception is: java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '"EntityCMPTable" WHERE "test" = 'zob'' at line 1"
    I would be very grateful for help since I have a close deadline for this!!!!!!!!
    Thank you very much in advance dear java experts!!!!!!!
                                       

    Hallo
    I have the same problem and the same configuration.
    Do you have a solution for this problem ??
    Thanks
    Georg

  • Problem with CMP BEAN ON SUN JAVA APPLICATION SERVER 1.3.1

    I am trying to deploy an entity bean with container managed persistence on sun java app. server 1.3.1. When I go for Deploy, the error 'SQL code not generated for following beans' is comming, when verified with verifier tool, the error shown is 'transaction attributes are not specified' , What should be the problem ?

    Which appserver are you using exactly? the J2EE 1.3.1 RI, SJAS 7.0, SJSAS 7.1....etc
    You need to make sure for that you have specified the correct deployment attributes for your CMP methods. You can pull the ear/jar into deploytool and review it there

  • Custom queries in CMP beans?

    Hi everyone,
    I need to keep my beans in a tree-like structure...
    Therefore I need to associate each bean with a path, such as "root.child.child". I would like to implement this method:
    public Collection findByParent(String parent)
          throws FinderException, RemoteException;using this query:
    SELECT primkey FROM {table} WHERE LOCATE(?, path) >= 0;
    How could I make the EJB container send use this query? I use Orion, so I guess it should be possible to enter this query into orion-ejb-jar.xml, but I'm not sure how. I do NOT want to make the bean BMP!
    I would also like to implement a search method. How can I do that?
    Thanks in advance,
    Nille

    You can use EJBQL to execute the query, if you are using ejb2.0. In your ejb-jar.xml you will need to add the query you want to execute something similar to:
    <query>
    <query-method>
    <method-name>findByParent</method-name>
    <method-params>
    <method-param>String</method-param>
    </method-params>
    </query-method>
    <ejb-ql>SELECT OBJECT(b) FROM YourBean b WHERE b.path LIKE '?1%'</ejb-ql>
    </query>
    This tag goes after the <primkey-field> inside your beans <entity> tag.
    You also need to add the method signiture to your home interface.
    public Collection findByParent(String parent) throws FinderException, RemoteException;
    And this method should return a Collection of Bean instances.
    Hope this helps
    Jeremy

  • Using wildcards in custom find methods with CMP beans

    Hi,
    I'd like to create a custom find method called findByName which accepts a string. I'd typically want to use the string in a '%<name>%' scenario, where the user needn't type in the whole name. Does anybody know what the partial query should look like? I'm not sure how to concatenate the '%' symbol to the string taken in.
    Thanks in advance
    Gillian

    Gillian-
    Bind variables are of the form $1, $2, etc., so try using a query stmt like this:
    select * from YOURTABLE where name like '%$1%'
    Regards,
    -Jon

  • Database lookup fails with CMP bean and J2EE1.4

    What else could I have missed?
    Running my client, I am getting the following error in the
    J2EE server:
    RaceControllerBean ejbCreate
    RaceControllerBean leaving
    RaceControllerBean createRace
    RaceControllerBean makeConnection
    javax.naming.NameNotFoundException: No object bound to name java:comp/env/jdbc/Cloudscape
    at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:657)
    at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:94)
    at javax.naming.InitialContext.lookup(InitialContext.java:347)
    at com.mnm.run.ejb.race.RaceControllerBean.makeConnection(Unknown Source)
    The J2EE server shows this printout upon starting up:
    Binding DataSource, name = jdbc/Cloudscape, url = jdbc:cloudscape:rmi:CloudscapeDB;create=true
    Again, what could be the problem? Thanks for any help.
    Andreas

    you might need to add it as a resource for your bean in your ejb-jar.xml file, as follows
    <enterprise-beans>
    <entity>
    <ejb-name>RaceControllerBean</ejb-name>
    <resource-ref>
    <res-ref-name>jdbc/Cloudscape</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </entity>

  • Problem finding data in an Oracle Database using CMP beans

    I am having a problem retrieving data from an Oracle database that has a date as
    part of the key. This data was loaded into my database via a batch process writing
    in java using java.sql.Date to store the date information. When calling the findByPrimaryKey
    method of a CMP Entity Bean I continued to get the FinderException. I know this
    data is in my database because I can view the data via SQLPlus and Microsoft Access.
    Has anyone ever experience problems with CMP beans accessing data from an Oracle
    database that had a date as part if the key or with accessing data in the database
    that insert via another method outside of your CMP bean. I desperately need some
    answers.

    Hi Dave,
    You should probably post this type of question in the CMP or JDBC section
    for best results. Chances are that the date is suffering from a rounding
    problem (it could be a date/time in the database with a different time zone)
    or is not the date that you think it is (wrong century or millenium). I've
    seen both. You need to write a quick piece of code that loads in those
    values as both Java timestamps and dates and makes sure that they are what
    you think they are.
    Peace,
    Cameron Purdy
    Tangosol Inc.
    Tangosol Coherence: Clustered Coherent Cache for J2EE
    Information at http://www.tangosol.com/
    "Dave White" <[email protected]> wrote in message
    news:3c1a4ac3$[email protected]..
    >
    I am having a problem retrieving data from an Oracle database that has adate as
    part of the key. This data was loaded into my database via a batchprocess writing
    in java using java.sql.Date to store the date information. When callingthe findByPrimaryKey
    method of a CMP Entity Bean I continued to get the FinderException. Iknow this
    data is in my database because I can view the data via SQLPlus andMicrosoft Access.
    Has anyone ever experience problems with CMP beans accessing data from anOracle
    database that had a date as part if the key or with accessing data in thedatabase
    that insert via another method outside of your CMP bean. I desperatelyneed some
    answers.

  • CMP Bean's  Field Mapping with oracle unicode Datatypes

    Hi,
    I have CMP which mapps to RDBMS table and table has some Unicode datatype such as NVARCHAR NCAR
    now i was woundering how OC4J/ oracle EJB container handles queries with Unicode datatypes.
    What i have to do in order to properly develope and deploy CMP bean which has fields mapped onto the data based UNICODE field.?
    Regards
    atif

    Based on the sun-cmp-mapping file descriptor
    <schema>Rol</schema>
    It is expected a file called Rol.schema is packaged with the ejb.jar. Did you perform capture-schema after you created your table?

  • Exception - Deploying CMP bean with Postgres DB

    Hi,
    When I deploy a CMP bean in Weblogic6.1 configured with Postgres Database it throws the following exception.
    <Oct 22, 2002 5:55:10 PM IST> <Error> <J2EE> <Error deploying application EjbTes
    t:
    Unable to deploy EJB: EjbTest.jar from EjbTest.jar:
    Exception: 'java.lang.NullPointerException' while trying to invoke: setB
    eanParamsForCreate at line 25
    at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:302)
    at weblogic.ejb20.deployer.Deployer.runEJBC(Deployer.java:296)
    at weblogic.ejb20.deployer.Deployer.compileEJB(Deployer.java:684)
    at weblogic.ejb20.deployer.Deployer.deploy(Deployer.java:851)
    <Oct 22, 2002 5:55:10 PM IST> <Error> <Management> <Error deploying application
    .\config\siptech\applications\EjbTest.jar: java.lang.reflect.UndeclaredThrowable
    Exception>
    Thankx,
    Jagan

    Hi. This isn't a jdbc question, so you'll have better luck posting this to the ejb group.
    Joe
    Jagan wrote:
    Hi,
    When I deploy a CMP bean in Weblogic6.1 configured with Postgres Database it throws the following exception.
    <Oct 22, 2002 5:55:10 PM IST> <Error> <J2EE> <Error deploying application EjbTes
    t:
    Unable to deploy EJB: EjbTest.jar from EjbTest.jar:
    Exception: 'java.lang.NullPointerException' while trying to invoke: setB
    eanParamsForCreate at line 25
    at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:302)
    at weblogic.ejb20.deployer.Deployer.runEJBC(Deployer.java:296)
    at weblogic.ejb20.deployer.Deployer.compileEJB(Deployer.java:684)
    at weblogic.ejb20.deployer.Deployer.deploy(Deployer.java:851)
    <Oct 22, 2002 5:55:10 PM IST> <Error> <Management> <Error deploying application
    .\config\siptech\applications\EjbTest.jar: java.lang.reflect.UndeclaredThrowable
    Exception>
    Thankx,
    Jagan

  • Custom finders in CMP dealing with BMP Beans as parameters

    Hi all,
    I need to create a custome finder method in a CMP Bean which has a parameter of type EJBLocalHome which is a BMP bean that has been already built. The problem is, I can't understand how to write the EJB-QL part of the finder. I will give some examples of my situation :
    CMP Finder definition :
    findByCustomer(CustomerLocal customer);
    The CMP bean which I want the finder to be implemented has a CMP field for the Customer's primary key which is of type Integer. But, I need to pass a CustomerLocal object to the finder. How can I write a EJB-QL to this situation ?
    Is there any known patterns for CMP-BMP relationships...?
    Thanks.
    Indy.

    Hi,
    Your first point is, I think, is out of the question because, if you call a business method, then the bean will be loaded. That will lose the sole purpose of finders.
    Second Point : There may be situations or projects that have to deal with CMP as well as BMP Beans together in a single project for reasons like the BMP beans coming from an already existing development. So, I can't really agree on your point saying that our design is questionable. We had to do it because, we had no other alternatives like changing all the BMP's into CMP's..
    So, still my question seems to be unanswered....!!!!!!
    Thanks anyway,
    Indy.

  • Problem with joining tables in cmp bean

    This is for an informix database. when i specify to join tables in CMP beans i get a sql error.. this is what the SQL join statement looks like when the server spits it out:
    SELECT t0.id, t0.name, t0.available, t0.available_date FROM drs_product t0, outer drs_category t1 ON t0.style=t1.style WHERE t0.available = 'T'
    it puts the "ON" string into the join?? this gives me a SQL error, it's supposed to be like this:
    SELECT t0.id, t0.name, t0.available, t0.available_date FROM drs_product t0, outer join drs_category t1 WHERE t0.style=t1.style AND t0.available = 'T'
    how can i fix this

    nevermind..i figured it out again.. in the INFORMIX DYNAMIC SERVER.properties file replace the left join attribute with this:
    LEFT_JOIN= left join
    make sure there is a space before the "l" in left and a space after the "n" in join, otherwise it will be a sql error:
    the previously LEFT_JOIN=, outer statement is clearly wrong for this database.

  • Open jdbc connections with CMP entity beans

    Hi,
    Seem to always have open connections (generally about half those that have been opened) when using CMP beans. How can i make sure these get closed when my app is finished with them ??
    Thanx
    Rosie

    Hi,
    Seem to always have open connections (generally about half those that have been opened) when using CMP beans. How can i make sure these get closed when my app is finished with them ??
    Thanx
    Rosie

  • Did elationship fields in entity bean with CMP same as foreign key in table

    did elationship fields in entity bean with CMP same as foreign key in table database.so we don't have to make some foreign key column in table database.
    did Container handle that both.
    I need some answer
    thank's

    Suppose you have Group and user entity. Relation is 1-m. One group many users. When you create user, you dont need to send group id, All you need is create user and add it in collection (cmr-field) in group(user belongs to). Container will add its group id in user entity as well as in db.

Maybe you are looking for

  • How can I print the top and bottom halves of 11x17 PDF on 8.5x11?

    I have a multi-page 11x17 PDF of quiz cards designed to be printed double-sided so that a question appears on one side and the answer on the other side. (Page 1 has the questions; page 2 has the answers.)  My printer is 8.5x11 so I would like to prin

  • Internal Error when Exporting to PDF

    Hello all, I have created a report in SSRS 2008. My report was running fine until I inserted an extra row. Once I would insert this row,(no matter where I insert it) whenever I try to view the print layout or export to a PDF I get the following error

  • Shopping For Ram: What to Look For?

    I'm looking at NewEgg for ddr2 67mhz ram for my MBP (mid 08) and I see a "cas latency" of either 4 or 5 (mostly 5's). What should I look for when getting ram? Is there much of a difference between 4 or 5? Any other "features" I should look for? Thank

  • Why I can't I import mbx into Mail?

    I am trying to transfer a colleague's e-mails from her old PC (running Windows Mail under Vista) to Apple Mail 6.6 on her MacBook Pro (running OS8.5). There are a lot of nested folders of email within her existing mail programme. Using a free utility

  • GL Account balances in F.08

    Dear Friends, We are working on 4.7v. Using T.code F.08 - Gl Account balances, I entered Chart of Accounts, Company Code, Fiscal year Business area Reportng period There is a huge differences in the totals of debit and credit amount and total credit