JPA named query should return only first result

Hello,
I'm quite new to JPA.
How can I return only the first result of a query? This must happen in the database, not by getSingleResult() from the EntityManager because the table has appr. 15 mio entries.
Does the JP QL provide this? like the LIMIT keyword in MySQL?
thanks from germany
Dirk

I moved this question to: Forum Home » Java Enterprise & Remote Computing » Enterprise JavaBeans
Donat

Similar Messages

  • Jpa native query returns only first character of a field

    Hi,
    I've a JPA native query that returns two fields from my oracle database. The first field is a CHAR(2) field with two char values in it, like 'OZ' etc.
    The problem is, as soon as the query is executed it returns only first character of field1. If the actual value of field1 is like 'OZ' then it returns only 'Z'.
    Query nativeQueryForProfileInfo = getManager().createNativeQuery(queryToRun);
    List list = nativeQueryForProfileInfo.getResultList();
    Please help,
    thanks

    There could be several explanations here and it's difficult to say without having more details, possibilities are
    There is something wrong with your display logic.
    There is something wrong with your mapping.

  • URGENT HELP:I want that the query should return in the same way

    I have a query
    select id from tableid where id in(350,241,251)
    This returns me in
    241,251,350
    I want that the query should return in the same way as specified in "in" clause.
    ie output should be in 350,241,251.
    I would really appreciate if anyone can help.

    You can achieve what you want like this:
    select id from tableid where id in (350,241,251)
    order by decode(id,350,1,241,2,251,3)in this example the decode explicitly defines the order you want to retrieve the records in.

  • SQL- Query that return only one record

    Hello,
    is it possible to execute a pure SQL-Query which returns only one row although multiple rows are found.
    It is no problem in PL/SQL, but I have no idea if the same is also possible in SQL.
    thanks in advance
    Michael

    Why not? There are 4 records in this table, but only selected one.
    SQL> with t
      2  as
      3  (
      4     select '#%$@#$@$@##$' Addr from dual
      5     union all
      6     select '18 Jalan Scott' from dual
      7     union all
      8     select '18 Lemana St' from dual
      9     union all
    10     select '32-penstation' from dual
    11     union all
    12     select '99999999999' from dual
    13  )
    14  select addr
    15    from t
    16   where rownum =1
    17  /
    ADDR
    #%$@#$@$@##$
    SQL>Cheers
    Sarma.

  • 2 queries should return the same result (but they dont...)

    hello
    i have a following query:
    select col1,extract(year from datum) yr, COUNT(*)
    from tableA@dblink where
    DATUM between '1-jan-1985' and '31-dec-2012'
    and col2 > 100 and col2 not in ('999999')
    and TRIM(TO_CHAR(col1)) in ('0','1')
    group by col1,extract(year from DATUM);the above query returns the count: 143 982 for year 1991
    however when i put the filter directly into this year the query returns a different number: 143 917
    select col1,extract(year from datum) yr, COUNT(*)
    from tableA@dblink  where
    DATUM between '1-jan-1991' and '31-dec-1991'
    and col2 > 100 and col2 not in ('999999')
    and TRIM(TO_CHAR(col1)) in ('0','1')
    group by col1,extract(year from DATUM);please can you help me understand why is this happening and why these 2 counts are different?
    id appreciate any tips
    thanks very much
    rgds

    UserMB wrote:
    please can you help me understand why is this happening and why these 2 counts are different?
    id appreciate any tipsThis is tricky. All others of cause are right. You must compare date columns with date values.
    If you don't explicitly compare as a date value, then it might happen that a string comparison is made.
    And if that happens both of your counts would return a wrong result. For example all dates that start with
    '4' are not counted. Like '4-jan-1991'. The string '4-jan-1991' is greater then the string '31-dec-1991'. Therefore it would not be included in the count.
    I don't think this happened. But the danger is there.
    However I have a problem seeing, what the difference between your two counts can be.
    The two important parts are the date between filter and the group by condition.
    DATUM between '1-jan-1985' and '31-dec-2012'
    DATUM between '1-jan-1991' and '31-dec-1991'
    group by col1,extract(year from DATUM);The second option returns less results than the first option. Some rows must be missing because of this different filter condition.
    If this would be a text comparison then there shouldn't be a difference. Only if it is a date comparison then this could be explained.
    Here is an example:
    Dates like 31-dec-1991 17:53:14 are included in the first count+group, but not included in the second count.
    Why? Because the string '31-dec-1991' is converted into a date. This date is 31-dec-1991 00:00:00 (midnight). Everything from this day, that is not exactly on midnight is greater than this value and therefore not included in your second query.
    So as others already pointed out you need to either truncate the date or to compare it a little differently.
    select col1,extract(year from datum) yr, COUNT(*)
    from tableA@dblink 
    where DATUM >= to_date('01-01-1991','dd-mm-yyyy')
    and  DATUM < to_date('01-01-1992','dd-mm-yyyy')
    and col2 > 100 and col2 not in ('999999')
    and TRIM(TO_CHAR(col1)) in ('0','1')
    group by col1,extract(year from DATUM);This should give the same result as your first query.
    Note that I changed the month from a month name to a number. This makes it independent from national language settings. E.g. DEZ = German, DEC = American
    Edited by: Sven W. on Oct 9, 2012 2:04 PM

  • XMLTABLE returns only first row

    I have follwoing XML inserted into the column named as TEXT in the table MASTERTB.
    *<?xml version="1.0" encoding="utf-8" ?>*
    *<Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">*
    *<Rowset>*
    *<Columns>*
    *<Column Description="Material Number" MaxRange="1" MinRange="0" Name="MATERIAL" SQLDataType="1" SourceColumn="MATERIAL"/>*
    *<Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>*
    *</Columns>*
    *<Row>*
    *<MATERIAL>1000000144</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>2000000008</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>2000000009</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>2000000016</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *<Row>*
    *<MATERIAL>3000000036</MATERIAL>*
    *<TANK>T1000</TANK>*
    *</Row>*
    *</Rowset>*
    *</Rowsets>*
    Now, when my requirement is to get all the Material values so when I run follwoing query in Oracle,
    SELECT RW.MATERIAL
    FROM MASTERTB TM,
    XMLTable('//Row' PASSING TM.TEXT
    COLUMNS  "MATERIAL"    CHAR(30) PATH 'MATERIAL') AS RW
    it return only 1000000144 (First MATERIAL). How can I read all the MATERIAL? Also, how can I read the entire XML in Text format if I want to check what has been inserted?
    ANy help will be appreciated !
    Edited by: 967327 on Oct 27, 2012 12:28 AM

    >
    <Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
    <Rowset>
    </Rowset>
    >
    so where is </Rowsets> ?
    your query works for me
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    SQL>
    SQL> with MASTERTB as
      2  (select
      3  xmltype('<?xml version="1.0" encoding="utf-8" ?>
      4  <Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
      5  <Rowset>
      6  <Columns>
      7  <Column Description="Material Number" MaxRange="1" MinRange="0" Name="MATERIAL" SQLDataType="1" SourceColumn="MATERIAL"/>
      8  <Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>
      9  </Columns>
    10  <Row>
    11  <MATERIAL>1000000144</MATERIAL>
    12  <TANK>T1000</TANK>
    13  </Row>
    14  <Row>
    15  <MATERIAL>2000000008</MATERIAL>
    16  <TANK>T1000</TANK>
    17  </Row>
    18  <Row>
    19  <MATERIAL>2000000009</MATERIAL>
    20  <TANK>T1000</TANK>
    21  </Row>
    22  <Row>
    23  <MATERIAL>2000000016</MATERIAL>
    24  <TANK>T1000</TANK>
    25  </Row>
    26  <Row>
    27  <MATERIAL>3000000036</MATERIAL>
    28  <TANK>T1000</TANK>
    29  </Row>
    30  </Rowset></Rowsets>') TEXT from dual)
    31  SELECT RW.MATERIAL
    32  FROM MASTERTB TM,
    33  XMLTable('//Row' PASSING TM.TEXT
    34  COLUMNS "MATERIAL" CHAR(30) PATH 'MATERIAL') AS RW
    35  /
    MATERIAL
    1000000144
    2000000008
    2000000009
    2000000016
    3000000036
    SQL>
    SQL> select * from v$version where rownum=1;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    SQL>
    SQL> with MASTERTB as
      2  (select
      3  xmltype('<?xml version="1.0" encoding="utf-8" ?>
      4  <Rowsets DateCreated="2010-11-30T11:12:10" EndDate="2010-06-05T16:52:23" StartDate="2010-06-05T16:52:23" Version="12.0.10 Build(18)">
      5  <Rowset>
      6  <Columns>
      7  <Column Description="Material Number" MaxRange="1" MinRange="0" Name="MATERIAL" SQLDataType="1" SourceColumn="MATERIAL"/>
      8  <Column Description="" MaxRange="1" MinRange="0" Name="TANK" SQLDataType="1" SourceColumn="TANK"/>
      9  </Columns>
    10  <Row>
    11  <MATERIAL>1000000144</MATERIAL>
    12  <TANK>T1000</TANK>
    13  </Row>
    14  <Row>
    15  <MATERIAL>2000000008</MATERIAL>
    16  <TANK>T1000</TANK>
    17  </Row>
    18  <Row>
    19  <MATERIAL>2000000009</MATERIAL>
    20  <TANK>T1000</TANK>
    21  </Row>
    22  <Row>
    23  <MATERIAL>2000000016</MATERIAL>
    24  <TANK>T1000</TANK>
    25  </Row>
    26  <Row>
    27  <MATERIAL>3000000036</MATERIAL>
    28  <TANK>T1000</TANK>
    29  </Row>
    30  </Rowset></Rowsets>') TEXT from dual)
    31  SELECT RW.MATERIAL
    32  FROM MASTERTB TM,
    33  XMLTable('//Row' PASSING TM.TEXT
    34  COLUMNS "MATERIAL" CHAR(30) PATH 'MATERIAL') AS RW
    35  /
    MATERIAL
    1000000144
    2000000008
    2000000009
    2000000016
    3000000036
    SQL> try
    31  SELECT RW.MATERIAL
    32  FROM MASTERTB TM,
    33  XMLTable('Rowsets/Rowset/Row' PASSING TM.TEXT
    34  COLUMNS "MATERIAL" varchar2(30) PATH 'MATERIAL') AS RW
    35  /
    MATERIAL
    1000000144
    2000000008
    2000000009
    2000000016
    3000000036
    SQL>

  • Oracle 11g:Query to return only 1 to 1 relationship & random selection

    Hi
    I have a complex query to modify but I have below the sample tables and data with only very few fields(only affected fields).
    Query based on 2 tables b_test and s_test.
    Pls see below.
    create table b_test(building_id number not null,invalid varchar2(1));
    create table s_test(sub_building_id number not null,building_id number ,invalid varchar2(1),sequence_no number);
    insert into b_test values (1000,'N');
    insert into b_test values(2000,'N');
    insert into b_test values(3000,'N');
    commit;
    insert into s_test values(1,1000,'N',90);
    insert into s_test values(2,1000,'N',91);
    insert into s_test values(3,1000,'N',92);
    insert into s_test values(4,1000,'Y',93);
    insert into s_test values(5,NULL,'N',NULL);
    insert into s_test values(1,2000,'N',94);
    insert into s_test values(2,2000,'N',95);
    insert into s_test values(3,2000,'N',96);
    insert into s_test values(4,2000,'N',97);
    insert into s_test values(5,2000,'N',98);
    insert into s_test values(6,NULL,'N',NULL);
    insert into s_test values(10,3000,'N',99);
    insert into s_test values(11,3000,'N',100);
    commit;The query below returns all rows required:(also see results:)
    select b.building_id,b.invalid,s.sub_building_id,s.sequence_no from b_test b,
    (select * from s_test where invalid='N') s
    where b.building_id = s.building_id(+)
    and b.invalid='N'
    Results:
    BUILDING_ID INVALID      SUB_BUILDING_ID     SEQUENCE_NO
    1000              N     1                     90
    1000             N     2                     91
    1000             N     3                     92
    2000             N     1                     94
    2000             N     2                     95
    2000             N     3                     96
    2000             N     4                     97
    2000             N     5                     98
    3000             N     10                      99
    3000             N     11                     100Now there are 2 requirements:
    1)How can the above query be changed so that 1:1 relationship if sub_building_id is returned?i.e For 1 building_id, only show 1 sub_building(This could be a random selection)
    (Pls help with query)
    The results would be like
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000               N     1                      90
    2000               N     1                      94
    3000               N     11                     1002)How can the same SEQUENCE_NO be shown for all sub_buildings for the same building? (Pls help with query)
    The results will be:
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000             N     1                       90
    1000             N     2                       90
    1000             N     3                       90
    2000             N     1                       94
    2000              N     2                       94
    2000             N     3                       94
    2000             N     4                       94
    2000             N     5                       94
    3000             N     10                       99
    3000             N     11                       99Many thanks!
    Edited by: Krithi on 08-Nov-2012 08:48
    Edited by: Krithi on 08-Nov-2012 08:55

    Krithi wrote:
    Hi
    I have a complex query to modify but I have below the sample tables and data with only very few fields(only affected fields).
    Query based on 2 tables b_test and s_test.
    Pls see below.
    create table b_test(building_id number not null,invalid varchar2(1));
    Thanks for posting the CREATE TABLE and INSERT statements, and your existing query; that's very helpful.
    The query below returns all rows required:(also see results:)
    select b.building_id,b.invalid,s.sub_building_id,s.sequence_no from b_test b,
    (select * from s_test where invalid='N') s
    where b.building_id = s.building_id(+)
    and b.invalid='N'
    Results:
    BUILDING_ID INVALID      SUB_BUILDING_ID     SEQUENCE_NO
    1000              N     1                     90
    1000             N     2                     91
    1000             N     3                     92
    2000             N     1                     94
    2000             N     2                     95
    2000             N     3                     96
    2000             N     4                     97
    2000             N     5                     98
    3000             N     10                      99
    3000             N     11                     100
    When I run your query, I get NULL for sequence_no on the last 2 rows, where building_id=3000. The numbers 99 and 100 don't seem to occur in either table. Did you post the worng sample data and/or results?
    >
    Now there are 2 requirements:
    1)How can the above query be changed so that 1:1 relationship if sub_building_id is returned?i.e For 1 building_id, only show 1 sub_building(This could be a random selection)
    (Pls help with query) Here's one way:
    WITH       got_r_num  AS
         SELECT  sub_building_id
         ,     building_id
         ,     sequence_no
         ,     ROW_NUMBER () OVER ( PARTITION BY  building_id
                                   ORDER BY          sequence_no
                           )         AS r_num
         FROM    s_test
         WHERE     invalid     = 'N'
    SELECT    b.building_id
    ,       b.invalid
    ,       r.sub_building_id
    ,       r.sequence_no
    FROM             b_test     b
    LEFT OUTER JOIN      got_r_num  r  ON  r.building_id  = b.building_id
    WHERE     NVL ( r.r_num
               , 1
               )          = 1
    ORDER BY  b.building_id
    ;This is called a Top-N Query , because we're picking N items (N = 1 in this case) from the top of an ordered list. What makes one item the "top", and another one "lower"? That's determined by the analytic ORDER BY clause, in this case
    ORDER BY      sequence_noThat means the row with the lowest sequence_no (for each building_id) will get r_num=1. If you want a random row from that building_id to be chosen as #1, then you can change the analytic ORDER BY clause to
    ORDER BY      dbms_random.valueYou can ORDER BY anything you like, even a constant, but you must have an analytic ORDER BY clause. ROW_NUMBER requires an analytic ORDER BY clause.
    The results would be like
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000               N     1                      90
    2000               N     1                      94
    3000               N     11                     100
    Again, I don't see where the 100 comes from. The results I get are:
    BUILDING_ID I SUB_BUILDING_ID SEQUENCE_NO
           1000 N               1          90
           2000 N               1          94
           3000 N              11
    2)How can the same SEQUENCE_NO be shown for all sub_buildings for the same building? (Pls help with query)
    SELECT    b.building_id
    ,       b.invalid
    ,       s.sub_building_id
    ,       MIN (s.sequence_no) OVER ( PARTITION BY  s.building_id)
                            AS seq_no
    FROM             b_test  b
    LEFT OUTER JOIN      s_test  s  ON  s.building_id  = b.building_id
                                AND s.invalid      = 'N'
    The results will be:
    BUILDING_ID INVALID     SUB_BUILDING_ID     SEQUENCE_NO
    1000             N     1                       90
    1000             N     2                       90
    1000             N     3                       90
    2000             N     1                       94
    2000              N     2                       94
    2000             N     3                       94
    2000             N     4                       94
    2000             N     5                       94
    3000             N     10                       99
    3000             N     11                       99
    Again, I don't see where you get sequence_no = 99. The results I get are:
    BUILDING_ID I SUB_BUILDING_ID     SEQ_NO
           1000 N               1         90
           1000 N               2         90
           1000 N               3         90
           2000 N               1         94
           2000 N               2         94
           2000 N               5         94
           2000 N               3         94
           2000 N               4         94
           3000 N              10
           3000 N              11Edited by: Frank Kulash on Nov 8, 2012 12:12 PM
    Added explanation and results
    Edited by: Frank Kulash on Nov 8, 2012 12:28 PM
    It looks like you cahnged your sample data from
    insert into s_test values(10,3000,'N',NULL);
    insert into s_test values(11,3000,'N',NULL);to
    insert into s_test values(10,3000,'N',99);
    insert into s_test values(11,3000,'N',100);The queries I posted are niow getting 99, like you requested.

  • Query not returning rows in 'result' tab due to invalid date field (bug?)

    It seems that in the results display, if there is a date field with out of bounds data then the query is stopped and only the results up to that record are displayed. When running the same query as a script, all of records are returned. The offending date in the table was '-10100-00-00 0-1:0-1:0-1.0'. Don't ask how it got there... I really have no idea.
    Has anyone else noticed this? Could it relate to the NLS format? Would it be possible to just display this value as null in the 'results' tab instead? Or wrap any invalid data as such and return nothing in the field but still show the record?

    Hello,
    It seems that you had resolved the issue which caused by premission.
    You can post the solution in a new reply and mark it as answer.
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • How to get all records using Invoke-webrequest?/Why Invoke-webrequest returns only first 2000 Records?

    invoke-webrequest content returning only 2000 records though it has around 4000 records in web api.
    The same url if I give in excel oData Data feed I am getting all the records.
    See the below script
    Script:
    $QueryResult= (Invoke-WebRequest -Uri $ODataURI -UseDefaultCredentials)
    [xml]$xmlResult=$QueryResult.content
    foreach($obj in $xmlResult.feed.entry.content.properties)
    $Name=$obj.Name;
    $IsAvail=$obj.isAvail.'#text';
    $PGroup=$obj.PGroup
    I am exporting the above result as a CSV file and my CSV file contains only 2000 records. 
    But,  $xmlResult.feed.Count --> it Shows 4000 Records.
    The same Odata url if I give in excel oData Data feed I am getting all the 4000 records.
    So Please help me how can I get all the records using power shell.
    Thanks
    A Pathfinder..
    JoSwa
    If a post answers your question, please click &quot;Mark As Answer&quot; on that post and &quot;Mark as Helpful&quot;
    Best Online Journal

    Hi Jo Swa(K.P.Elayaraja)-MCP,
    Would you please also post code which is used to export the records?
    In addition, to use the cmdlet invoke-RestMethod to work on ODate feeds, please refer to this article:
    Interacting with TechEd NA 2012 Schedule using PowerShell v3
    I hope this helps.

  • Query to pick only first value/day

    I have a table with Account, Complaint and Date columns. Each Account can log multiple complaints each day.
    Now i need a query to pick only the first complaint in a day from each account. If the same account logged in a complaint next day or any day after i want to show that as well.
    Help me with your ideas. Thanks in advance for your help.

    Maybe
    with
    first_complaints as
    (select account,
            date
       from (select account,
                    date,
                    row_number() over (partition by account order by date) rn
               from a_table
      where rn = 1
    select account,
           complaint,
           date
      from a_table t
    where account in (select account
                         from first_complaints
       and date >= (select date
                      from first_complaints
                     where account = t.account
    Regards
    Etbin
    Message was edited by: Etbin
    rereading: If the same account logged in a complaint next day or any day after i want to show that as well.
    The query above is just select * from a_table
    Now:
    if you want to show just the first complaints in a day for any following date, John answered that already (it's just the first_complaints of mine)
    if you want to show all the complaints in any following date, you have to exclude all the complaints logged the first day except the first one
    select account,
           complaint,
           date
      from (select account,
                   complaint,
                   date,
                   row_number() over (partition by account order by date) rn
              from a_table
           ) t
    where date != (select min(date)
                      from a_table
                     where account = t.account
       or rn = 1

  • JDeveloper, JPA named query String parameter with length of 1

    Hi,
    I use JDeveloper 11.1.1.2.0. and have the following table:
    CREATE SEQUENCE COUNTRY_SEQ;
    CREATE TABLE COUNTRY (
    COUNTRY_ID NUMBER NOT NULL,
    COUNTRY_NAME VARCHAR2(40),
    COUNTRY_CODE CHAR(2) NOT NULL,
    CONSTRAINT COUNTRY_ID_PK PRIMARY KEY (COUNTRY_ID)
    INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Belgium', 'B');
    INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Netherlands', 'NL');
    COMMIT;
    I made a JPA Entity with two queries:
    @NamedQueries({
    @NamedQuery(name = "Country.findAll", query = "select o from Country o"),
    @NamedQuery(name = "Country.findByCountryCode", query = "select o from Country o where o.countryCode = 'B' or o.countryCode ='NL'")
    The first works fine, gives back both B and NL. But the second gives back only NL. I have no clue why.
    If I change 'B' to 'BE' both in the DB and the code, it works. If I change to 'b', it doesn't. So it seems that the problem comes with 1 char long Strings.
    Is it an EclipseLink bug?
    I use Oracle Database 11g Enterprise Edition Release 11.1.0.7.0. But
    SELECT COUNTRY_ID, COUNTRY_NAME, COUNTRY_CODE FROM COUNTRY WHERE COUNTRY_CODE = 'B' OR COUNTRY_CODE = 'NL';
    works in SQL*Plus.
    Thx, Donat

    Hi,
    That's true, it uses value bindings while the values are hard coded. I use the default EclipseLink embedded into JDeveloper 11.1.1.2, with the default settings. The JPA bean runs in the default embedded WebLogic of JDeveloper. This might be a default setting of EclipseLink to use bindings for hard coded values.
    Here is a fragment of Country.java:
    @Entity
    @NamedQueries({
    //@NamedQuery(name = "Country.findAll", query = "select o from Country o")
    @NamedQuery(name = "Country.findAll", query = "select o from Country o where o.countryCode ='B' or o.countryCode ='NL'")
    public class Country implements Serializable {
    @Id
    @Column(name="COUNTRY_ID", nullable = false)
    private Long countryId;
    @Column(name="COUNTRY_CODE", nullable = false)
    private String countryCode;
    @Column(name="COUNTRY_NAME", length = 40)
    private String countryName;
    And I have a JavaServiceFacade.java:
    public class JavaServiceFacade {
    private EntityManagerFactory emf = Persistence.createEntityManagerFactory("EjbModel-1-Outside");
    public JavaServiceFacade() {
    public static void main(String [] args) {
    final JavaServiceFacade javaServiceFacade = new JavaServiceFacade();
    List<Country> countries;
    countries = javaServiceFacade.getCountryFindAll();
    for (Country country : countries) {
    System.out.println(country.getCountryCode());
    private EntityManager getEntityManager() {
    return emf.createEntityManager();
    /** <code>select o from Country o</code> */
    public List<Country> getCountryFindAll() {
    return getEntityManager().createNamedQuery("Country.findAll").getResultList();
    BR, Donat

  • JPA named query String parameter with length of 1

    Hi,
    I use JDeveloper 11.1.1.2.0. and have the following table:
    CREATE SEQUENCE COUNTRY_SEQ;
    CREATE TABLE COUNTRY (
    COUNTRY_ID NUMBER NOT NULL,
    COUNTRY_NAME VARCHAR2(40),
    COUNTRY_CODE CHAR(2) NOT NULL,
    CONSTRAINT COUNTRY_ID_PK PRIMARY KEY (COUNTRY_ID)
    INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Belgium', 'B');
    INSERT INTO COUNTRY VALUES (COUNTRY_SEQ.NEXTVAL, 'Netherlands', 'NL');
    COMMIT;
    I made a JPA Entity with two queries:
    @NamedQueries({
    @NamedQuery(name = "Country.findAll", query = "select o from Country o"),
    @NamedQuery(name = "Country.findByCountryCode", query = "select o from Country o where o.countryCode = 'B' or o.countryCode ='NL'")
    The first works fine, gives back both B and NL. But the second gives back only NL. I have no clue why.
    If I change 'B' to 'BE' both in the DB and the code, it works. If I change to 'b', it doesn't. So it seems that the problem comes with 1 char long Strings.
    Is it an EclipseLink bug?
    I use Oracle Database 11g Enterprise Edition Release 11.1.0.7.0. But
    SELECT COUNTRY_ID, COUNTRY_NAME, COUNTRY_CODE FROM COUNTRY WHERE COUNTRY_CODE = 'B' OR COUNTRY_CODE = 'NL';
    works in SQL*Plus.
    Thx, Donat

    I moved this question to: Forum Home » Java Enterprise & Remote Computing » Enterprise JavaBeans
    Donat

  • My prefered(default) search engine, but searches in FF4 return only Yahoo results. How do I fix this?

    I installed FF4 this morning, and while I expected addon problems, I did not expect this. All searches return Yahoo results, even though my default SE is google. The google icon still shows in my search bar...I'm confused.

    Thank you, thank you, thank you, the-edmeister, thank you! I am in your debt, sir!

  • Apple TV search from "Movies" returns only music results after 6.0 upgrade

    6.0 (6646.65) upgrade appeared to complete sucessfully. Apple TV is 3rd generation Rev A.
    Any suggestions, remedies appreciated.  Thanks much.

    For everyone's information, I tried the following :
    (1) Tried to use another Apple account on the Apple TV box, unfortumately it had outdated information related to credit card information on the second account.  I tried restoring and trying the account but it still showed the old credit card information, which suggests that the software is not updating information on iTunes store account information.
    (2) I did ANOTHER restore of the software (third attempt).  I again restored the software to the Apple TV box, entered the original iTunes account information and then attempted to rent a movie.  This time...again via the intial attempt to rent, I was requested to enter the three or four digit code to my credit card.  I entered it and it immediately went back to the recent screen which requests the special code....an infiite loop request for information - never submits the information.
    (3) I accessed iTunes via my iPad through my home network - same as the Apple TV connection, went to movies, located the movie I attempted to rent through Apple TV and successfully rented the movie on my iPad.
    In my view, based on all of the steps I have taken in this communication thread, this is a software issue. .....anyone who can prove me wrong I am earntestly eager to hear from them.

  • Simple Query with subquery returns the 'wrong' result

    DB version: 11.2
    We created about 27 schemas in the last 4 days. The below query confirms that.
    SQL > select username, created from dba_users where created > sysdate-4;
    USERNAME                       CREATED
    MANHSMPTOM_DEV_01              12 Jul 2012 11:55:16
    PRSM01_OAT_IAU                 13 Jul 2012 01:51:03
    F_SW                           11 Jul 2012 17:52:42
    FUN_CDD_HK_SIT                 09 Jul 2012 15:33:57
    CEMSCOMPTOM_UAT_01             12 Jul 2012 11:43:45
    STORM02_OAT_IAU                13 Jul 2012 02:06:29
    27 rows selected.  -------------> Truncated outputFrom DBA_TS_QUOTAS.max_bytes column , we can determine the space quota allocated for a user/schema
    SQL > desc dba_ts_quotas
    Name                                      Null?    Type
    TABLESPACE_NAME                           NOT NULL VARCHAR2(30)
    USERNAME                                  NOT NULL VARCHAR2(30)
    BYTES                                              NUMBER
    MAX_BYTES                                          NUMBER
    BLOCKS                                             NUMBER
    MAX_BLOCKS                                         NUMBER
    DROPPED                                            VARCHAR2(3)So, I wanted to see the allocated space for the users created in the last 4 days. The below query should return only 27 records because the subquery returns only 27 records. Instead it returned 66 records !
    select username, tablespace_name, max_bytes/1024/1024 quotaInMB
    from dba_ts_quotas
    where username in (select username from dba_users where created > sysdate-4);Any idea why ? I know it is not a bug with oracle. Its just I haven't been eating fish lately.

    Hi,
    J.Kiechle wrote:
    So, I wanted to see the allocated space for the users created in the last 4 days.DBA_TS_QUOTAS doesn't give the allocated space but rather the maximum allowed for a given user.
    J.Kiechle wrote:
    The below query should return only 27 records because the subquery returns only 27 records. Instead it returned 66 records !What if your user John has Quotas on 3 tablespace TBS1, TBS2 and TBS3 ?
    You cannot expect the outer query to only retrieve at most 27 rows just because the inner query returns 27 rows.
    For allocated space by tablespace for recently created users, you'd better query dba_segments. something like :select owner, tablespace_name, trunc(sum(bytes)/1024/1024) alloc_mb
    from dba_segments
    where owner in (select username from dba_users where created > sysdate - 4)
    group by owner, tablespace_name
    order by owner, tablespace_name;

Maybe you are looking for

  • How to cancel Office 2010 message

    I have a notebook and desktop computer and I use Windows Microsoft Office 2007, running Word, Excel, Publisher, Access etc, on both notebook and desktop computers with Norton 360  antivirus, both have used this system for the last 4 years.  Both comp

  • Is there a way to sync iPhoto with Shutterly?

    Or do I have to do each event individually?

  • OA Extension for opportunity create page - Multi Entity Extension

    Hello, i'm trying to achieve a multi Entity Extension. We are storing additional attributes in a custom table for opportunities. i'm trying to extend the existing Opportunity Create Page to create an other record in custom table. Here is what i've do

  • Database schema generation from an XML schema

    From XDK FAQ: Question: Given a DTD, will XML SQL Utility generate the database schema? Answer: No. Due to a number of shortcomings of the DTD, this >functionality is not available. Once the W3C XML Schema >recommendation is finalized this functional

  • How to get string from a stringBuider reference

    Please see attached image. How do I take the values from stringbuilder reference,into LabVIEW string? (The DLL is C# and is proven) Pls. help. Attachments: HowToMap_LV_String2StringBuilderReference.zip ‏43 KB