EJB query language help!!

Hi all, I have been trying to run a ejb query on JBoss 4.0.5, using built in hypersonic db, For some strange reasons am able to fetch all objects from db without any where clause but if am using a where clause with an attribute name from the entitybean am unable to retrieve any results.
I get an org.hibernate.QueryException, could not resolve property : "property name"
My ejb query looks like this...
SELECT template FROM TemplateSelect template WHERE template.template_name='Template_One'
TemplateSelect is my entity bean class and I do have an attribute named template_name in my bean class.
could any one please suggest me what could be wrong and also direct me to a good tutorial on ejb query language as well as I am fairly new to hibernate and ejb3 !
tons of thanks in advance!
pravin

Hi Anuradha ,
I'm afraid the query language does not support retrieving the date portion (i.e. truncating the time) from a date field.
I propose you turn you named into a BETWEEN query taking two parameters one for the beginning of the day and another for the end of the day. Then your named query could look like:
SELECT max(o.req_id) FROM requests o WHERE o.requestdate BETWEEN :start AND :end
The following code creates two calendar instances for the current day, one for 00:00:00 and another for 23:59:59:
Calendar start = Calendar.getInstance();
start.set(Calendar.HOUR_OF_DAY, 0);
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);
start.set(Calendar.MILLISECOND, 0);
Calendar end = Calendar.getInstance();
end.set(Calendar.HOUR_OF_DAY, 23);
end.set(Calendar.MINUTE, 59);
end.set(Calendar.SECOND, 59);
end.set(Calendar.MILLISECOND, 999);
Here is some sample code that creates a query instance for a named query called findMaxRequestPerDay and passes the Date of the above Calendar instance as actual parameter values. It assumes the named query is called findMaxRequestPerDay and the req_id field is a long:
Query query = em.createNamedQuery("findMaxRequestPerDay");
query.setParameter("start", start.getTime());
query.setParameter("end", end.getTime());
Long max = (Long)query.getSingleResult();
I hope this helps.
Regards Michael

Similar Messages

  • Is EJB query language supports UNION

    Hi All,
    Can anyone suggest me is EJB query language supports UNION type of select queries
    if possible can any one suggest me how to convert below Sql query to Ejb ql
    Ex:
    select * from table1 where id='10'
    union all
    select * from table1 where id='20'

    The UNION clause specifies a combination of the output of two subqueries. The two queries must return the same number of elements and compatible types
    1.You cannot use dependent value objects with UNION.
    2.UNION ALL combines all results together in a single collection.
    3.UNION combines results but eliminates duplicates.
    4.If ORDER BY is used together with UNION, the ORDER BY
    must refer to selection expression using integer numbers.
    Example:
    This example returns a collection of all employee objects of type EmpBean and all manager objects of type ManagerBean where ManagerBean is a subtype of EmpBean.
    select e from EmpBean e union all select m from DeptBean d, in(d.mgr) mThis example shows a query that is not valid, because EmpBean and DeptBean are not compatible.
    select e from EmpBean e union all select d from DeptBean d
    Your Example:
    Select e from Table1Bean e where e.id=10
    union all
    Select e from Table1Bean e where e.id=10

  • EJB Query Language

    Hi All,
         I am using SAP Netweaver Developer Studio(2004)version.I want to know that EJB2.0 Query Language will
    support Joins,Internal select statement with in a select
    statement or not.Is it posssible or not.I have a requirement lilke this,I have to use joins.
    Thanks & Regards,
    Guru

    Guruvulu,
    In EJB QL you may operate on objects relations (both 0..1 and 0..n) in the same way as with joins in SQL. So the answer is yes.
    Read free <a href="http://www.theserverside.com/books/wiley/masteringEJB/downloads/MasteringEJB3rdEd.pdf">Mastering EJB</a> book -- it contains separate chapter on EJB QL.
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • EJB Query Language where condtion based on date

    Hi,
    I am using EJB3 query language. In the table I have a column called requestdate which is in date time format. I have created an entity class.
    I need to select few records using query language(named queries) based on this requestdate matching to the current date. I want to compare only based on Date value (truncating the time). Something like this
    select max(o.req_id) from requests o where o.requestdate = :currentdate
    currentdate is java.sql.Date value formatted to yyyymmdd only.
    How can I do this using query language?
    Please help to me get this done.
    thanka
    Anuradha

    Hi Anuradha ,
    I'm afraid the query language does not support retrieving the date portion (i.e. truncating the time) from a date field.
    I propose you turn you named into a BETWEEN query taking two parameters one for the beginning of the day and another for the end of the day. Then your named query could look like:
    SELECT max(o.req_id) FROM requests o WHERE o.requestdate BETWEEN :start AND :end
    The following code creates two calendar instances for the current day, one for 00:00:00 and another for 23:59:59:
    Calendar start = Calendar.getInstance();
    start.set(Calendar.HOUR_OF_DAY, 0);
    start.set(Calendar.MINUTE, 0);
    start.set(Calendar.SECOND, 0);
    start.set(Calendar.MILLISECOND, 0);
    Calendar end = Calendar.getInstance();
    end.set(Calendar.HOUR_OF_DAY, 23);
    end.set(Calendar.MINUTE, 59);
    end.set(Calendar.SECOND, 59);
    end.set(Calendar.MILLISECOND, 999);
    Here is some sample code that creates a query instance for a named query called findMaxRequestPerDay and passes the Date of the above Calendar instance as actual parameter values. It assumes the named query is called findMaxRequestPerDay and the req_id field is a long:
    Query query = em.createNamedQuery("findMaxRequestPerDay");
    query.setParameter("start", start.getTime());
    query.setParameter("end", end.getTime());
    Long max = (Long)query.getSingleResult();
    I hope this helps.
    Regards Michael

  • PLS HELP ! WLS 6.1 CMP ejb query ORDERBY clause

    Please Help,
    How to do OrderBY clause ASC and DESC in weblogic 6.1 CMP?
    Thanks

    Hi Deepak,
    First of all, thanks for answering.
    Do you mean I should place that query within "weblogic-query" tag in the weblogic-cmp-rdbms-jar.xml?
    I tried comment the query part in ejb-jar.xml with the ammended weblogic-cmp-rdbms-jar.xml.
    The ejb compiler fail to compile the ejb because it cannot find the coresponse
    Method.
    Can you state a simple example this case with descriptors?, the descriptor make
    me headache. Thanks
    Deepak Vohra <[email protected]> wrote:
    The WebLogic Query Language extension, ORDERBY, is a keyword that works
    with the Finder method to allow you to specify which CMP file you want
    to use for your selections.
    The following example shows the use of the extension, ORDERBY.
    SELECT A from A for Account.Bean
    ORDERBY A.id ASC | DESC
    ASC | DESC
    Specify whether the ordering sequence is ascending or descending. ASC
    is the default.
    Ray wrote:
    Please Help,
    How to do OrderBY clause ASC and DESC in weblogic 6.1 CMP?
    Thanks

  • Applying a query language to collections

    Hi, we handed in a project a while ago that was essentially to read in data from a .DAT file, store it in appropriate collections, then use a basic query language to filter through the stored data. I wasn't really happy with my querying though, as it was basically a huge succession of control statements. The queries were of the form "select OBJECTNAME where ATRIBUTE OPERATOR VALUE and ATRIBUTE OPERATOR VALUE", there could be as many sub clauses as desired (0... 200 whatever). For example "select elephant where height > 360 and weight <= 1000".
    We had a comment back that we should use a Query interface and a two subclasses to represent a simple query (e.g. height > 360) and then a conjunctive query (ie simplequery1 AND simplequery2 ). The Query interface would then have a match method. I'm struggling to get my head around how I do this, does anyone have a simple example or explaination that might help me out?
    Cheers.

    I've done something like this a couple times. Your need to get a better idea of what you want your query language to look like. For example, if you're given a list of elephants, the "select elephant" part is unnecessary (your query will just return a list of matching elephants). You should decide if you want it to handle things like (height > (weight / 2)), whether conditions can be nested "((a and b) or (c and d)) and (e or f)". Will you need to support the conditional operator (a ? b : c) or a unary operator (-)? How complex will your order of operations rules be?
    If you keep it simple (always two operands), you could go with something like this:
    public interface QueryOperator
      public boolean eval(Object leftParam, Object rightParam);
    public enum BasicOperators implements QueryOperator
    public class  QueryElement
      private QueryOperator operator;
      private Object leftParam;
      private Object rightParam;
    }

  • Query language for XML documents

    Which is a better (efficiency in terms of memory management) query language for interacting with XML documents.The query language shouls support 'insert', 'delete', 'update' and 'select' commands. How fast is database as compared to XML ( database being replaced by XML) when only 'insert' n 'select' commands are issued?

    Hi,
    I suggest you use the Sunopsis JDBC for XML driver that will let you perform all kind of SQL statements on your XML files. It is a type 4 driver so it's very use to use. You may have more information and download it here:
    http://www.sunopsis.com/corporate/us/products/jdbcforxml/
    Hope that will help
    Simo Fernandez

  • Object Query Language (OQL) Support ?

    I know Toplink has an "ExpressionBuilder" type querying
    But does Toplink support Object Query Language (OQL)
    Example :
    Something like this ?
    // perform query
    OQLQuery query = new OQLQuery(
    "select x from Person x where x.name = \"Doug Barry\"");
    Collection result = (Collection) query.execute();
    Iterator iter = result.iterator();
    Thanks
    Ratheesh

    Ratheesh,
    TopLink does not support OQL. We offer query support through the following 5 options:
    1. EJB QL - for both Entity Beans (CMP/BMP) and Java objects
    2. TopLink Expressions - Object based query API
    3. SQL calls
    4. Stored procedure calls
    5. Quey by example
    Doug

  • SAP Query Language max retrieve size 512 bytes?

    Hello,
    Does anyone know if there is a 512 byte limit on retrieves from a table when using SAP Query Language?  In other words the length of all the fields in the retrieve can't exceed 512 bytes?
    Thanks

    Hi,
    And also you need check this thread
    May this will help you out.

  • I need a clarification : Can I use EJBs instead of helper classes for better performance and less network traffic?

    My application was designed based on MVC Architecture. But I made some changes to HMV base on my requirements. Servlet invoke helper classes, helper class uses EJBs to communicate with the database. Jsps also uses EJBs to backtrack the results.
    I have two EJBs(Stateless), one Servlet, nearly 70 helperclasses, and nearly 800 jsps. Servlet acts as Controler and all database transactions done through EJBs only. Helper classes are having business logic. Based on the request relevant helper classed is invoked by the Servlet, and all database transactions are done through EJBs. Session scope is 'Page' only.
    Now I am planning to use EJBs(for business logic) instead on Helper Classes. But before going to do that I need some clarification regarding Network traffic and for better usage of Container resources.
    Please suggest me which method (is Helper classes or Using EJBs) is perferable
    1) to get better performance and.
    2) for less network traffic
    3) for better container resource utilization
    I thought if I use EJBs, then the network traffic will increase. Because every time it make a remote call to EJBs.
    Please give detailed explanation.
    thank you,
    sudheer

    <i>Please suggest me which method (is Helper classes or Using EJBs) is perferable :
    1) to get better performance</i>
    EJB's have quite a lot of overhead associated with them to support transactions and remoteability. A non-EJB helper class will almost always outperform an EJB. Often considerably. If you plan on making your 70 helper classes EJB's you should expect to see a dramatic decrease in maximum throughput.
    <i>2) for less network traffic</i>
    There should be no difference. Both architectures will probably make the exact same JDBC calls from the RDBMS's perspective. And since the EJB's and JSP's are co-located there won't be any other additional overhead there either. (You are co-locating your JSP's and EJB's, aren't you?)
    <i>3) for better container resource utilization</i>
    Again, the EJB version will consume a lot more container resources.

  • Multi-language Help in a multi-language web app

    Hello!
    I had posted this on the RH HTML forum but removed that and
    posted here for a wider audience...
    ***Please note: this question is not specific to RH but is
    applicable now that RH 7 is unicode enabled. If you have experience
    that does not relate to RH, please share anyway!
    Once I have developed WebHelp (for example) in multiple
    languages, how do I connect the help files to the web application
    that the help is about? How does the correct language output get
    displayed? For example, the application (that the help documents)
    changes its interface based on browser language. Can the
    appropriate help content be displayed based on browser language?
    How is multi-language help generally implemented for an end user?
    And, equally important, how does context-sensitive help
    (mapping) work with multiple languages?
    I have never been involved in a multi-language development
    effort and so I have no experience to relate this to. Any guidance
    will be greatly (and gratefully
    ) appreciated!
    Kathy

    That's how our developers do it, but I just want to throw in
    one other detail. The help output for each language has to be in a
    separate directory. So if you have 5 languages, you'll have 5
    directories. It's up to the developers to code the app so it
    detects the browser language, then looks in the appropriate help
    directory when the user clicks your help link or icon.
    --Ben

  • How to improve the performance of the attached query, Please help

    Hi,
    How to improve performance of the below query, Please help. also attached explain plan -
    SELECT Camp.Id,
    rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount,
    (SUM(rCam.Impressions) * 0.001 + SUM(rCam.Clickthrus)) AS GR,
    rCam.AccountKey as AccountKey
    FROM Campaign Camp, rCamSit rCam, CamBilling, Site xSite
    WHERE Camp.AccountKey = rCam.AccountKey
    AND Camp.AvCampaignKey = rCam.AvCampaignKey
    AND Camp.AccountKey = CamBilling.AccountKey
    AND Camp.CampaignKey = CamBilling.CampaignKey
    AND rCam.AccountKey = xSite.AccountKey
    AND rCam.AvSiteKey = xSite.AvSiteKey
    AND rCam.RmWhen BETWEEN to_date('01-01-2009', 'DD-MM-YYYY') and
    to_date('01-01-2011', 'DD-MM-YYYY')
    GROUP By rCam.AccountKey,
    Camp.Id,
    CamBilling.Cpm,
    CamBilling.Cpc,
    CamBilling.FlatRate,
    Camp.CampaignKey,
    Camp.AccountKey,
    CamBilling.billoncontractedamount
    Explain Plan :-
    Description                    Object_owner          Object_name     Cost     Cardinality     Bytes     
    SELECT STATEMENT, GOAL = ALL_ROWS                              14     1     13
    SORT AGGREGATE                                                  1     13
    VIEW                         GEMINI_REPORTING               14     1     13
    HASH GROUP BY                                        14     1     103
    NESTED LOOPS                                        13     1     103
    HASH JOIN                                             12     1     85
    TABLE ACCESS BY INDEX ROWID     GEMINI_REPORTING     RCAMSIT          2     4     100
    NESTED LOOPS                                        9     5     325
    HASH JOIN                                        7     1     40
    SORT UNIQUE                                        2     1     18
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          SITE          2     1     18
    INDEX RANGE SCAN          GEMINI_PRIMARY          SITE_I0          1     1     
    TABLE ACCESS FULL          GEMINI_PRIMARY          SITE          3     27     594
    INDEX RANGE SCAN          GEMINI_REPORTING     RCAMSIT_I     1     1     5     
    TABLE ACCESS FULL     GEMINI_PRIMARY     CAMPAIGN                    3     127     2540
    TABLE ACCESS BY INDEX ROWID     GEMINI_PRIMARY          CAMBILLING     1     1     18
    INDEX UNIQUE SCAN     GEMINI_PRIMARY     CAMBILLING_U1                    0     1

    Hello,
    This has really nothing to do with the Oracle Forms product.
    Please, send the SQL or/and PL/SQL questions in the corresponding forums.
    Francois

  • XPath Query Language Reference

    Aside from the three little examples given in the 11g Guide and the B2B Tech Note #011, is there a reference available for the XPath Query Language used by B2B? Is is possible to use complex XPath queries in the B2B Doc Definitions?

    I'm mainly just looking for the full capabilities of the queries.
    Specifically, at the moment, I'm looking for a way to match the value of a node to a group of values (like a sql 'in') as well as check the existence and value of other nodes within the same query.
    Do the documents I find for 'Preference XPath' pertain here?

  • Query language for CTXRULE MATCHES

    I am trying to build an alerting application when, on receipt of a new XML document, user's are alerted if the document matches one or more of the profiles that they have defined. I have created a CTXRULE index that does this but only with very simple profiles. For example ABOUT(soccer), which is the example in the Text documentation.
    Is it possible to create more complex queries, for example using WITHIN to only match within defined elements of the XML document. Is there a definition of the query language that can be used with MATCHES and are there any good example?
    Thanks
    Martin Haigh

    Omar,
    Thanks for the reply. I had actually found that document myself but I couldn't get the WITHIN clause to work and that document conflicted with the ORACLE documentation at:
    <a href="http://download-west.oracle.com/docs/cd/B10501_01/text.920/a96517/ind.htm#1010647>  Do you have any examples of using WITHIN?
    Thanks
    Martin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Query language for XML that is going to remove use of database

    Friends,
    I want to know whether my idea is feasible or not.
    I want to make a query language similar to SQL for XML which is going to remove the need for database for a large extent.
    Their will be queries for making table,extracting data,making foreign key all through XML and no database.
    I just want to know that is their any market value for such a project and will it be sellable,so that i can start working on it.

    There is no way to judge any future market for such a thing.
    As it is, XML is widely abused, having mutated from its original purpose, a markup language readable by both machine and human, to a general data interchange language. It winds up being extremely slow and convoluted, in some cases overwhelming the hardware when a simple and common error occurs, then having to catch up. A big part of this is the silly and redundant method of defining metadata, again and again and again and again.
    So what you want to do is create a database which will be highly formatted with redundant information, dynamically. This is silly, why does data need to be stored in a human readable format? It doesn't always even need to be presented in a human readable format! Why the heck would you need to read the bits of an mp4? Steganography?
    What you are proposing is the exact opposite of what is needed. What is needed is a way to describe metadata for many different kinds of data, in a manner that can be interpreted by both man and machine at appropriate times, extensible for various paradigms.
    What can be sold, on the other hand, is another question entirely, and not technical at all.
    First definition of database that pops up during a search: an organized body of related information
    Why would you want to get rid of that?

Maybe you are looking for

  • Issue setting up iview - Need help

    Hi, I'm setting up an iview to surface a SAP BW report through SAP NetWeaver 7.0 (2004s) I've tested the iview with the following value in the "BEx Web Application Query String" property of the iview and am able to view my BW report in the portal ivi

  • Pure Actionscript for Adobe Air 1.5.x - I want to know without mxml...

    Hello guys, I want to learn about advancad programming because i want to know for intelligent like you good workers... Question 1: How does my application create new config file and write config file? - Save currect language! like you life in US. I l

  • Syncing photos from iPad to iMac

    I have tried several times to sync my photos from iPad to my computer and I get to a point when the import just stops and it is stuck on the picture and it doesn't finish syncing. Every time I tried to sync, it seems that it creates a duplicate of th

  • HT3775 My Quicktime Player says that it can't play .mov files...

    has anyone else experienced this or do you have any suggestions to remedy the situation?

  • MAIL failure to load after Lion upgrade - can't migrate data

    I've posted information in a different forum, but I think that thread is dead so I wanted to post a fresh issue. Here's the older post: https://discussions.apple.com/message/16615578#16615578 Bascially, Mail won't migrate my data and it crashes befor