How to return a set of all objects

hi,
i have a simple POJO called Items, for example. In my POJO all I have is two fields, the id and the price of the item which comprise to be two fields in the corresponding table in the database. then i have the getters and setters for these two fields.
i want to have a getItems() method which would essentially return a set of all items. i'm not sure as to how to do this, should there be a loop in the getItems() method which would go through the rows in the table and keep on adding the rows to the set until there are no more rows?
what's the correct way to do this? any ideas, suggestions will be helpful. thanks!!

What do you mean "return a set of all items"? You mean all the entries of this type in the DB? Then run query "select * from whatever_that_table_is", iterate over the result set, and and one object to a List for each row. Of course, this is not generally a good approach, as it's quite possible for the number of rows in the DB to exceed what you can hold in memory at one time.
What part are you having trouble with?

Similar Messages

  • How to return a set of data  by using webservice ?

    Hi.
    I am finding how to return a set of data by using java webservice that serves clients written by others such as VB. Net. Please help me !
    Thanks in advance.

    Check the how to on Accessing Oracle9iAS Java Web Service from a .NET Client
    http://otn.oracle.com/sample_code/tech/java/codesnippet/webservices/index.html
    Chandar

  • How to return a set of vlaues.

    Hello All,
    I need to return a set of vlaues from a table.The values will be used by other application.
    For example I need all the department names to be retuned . How can we do this. can we return more than one value in a function.
    Please let me know the syntax for this.
    Kind Regards,
    Kumar.

    I will show you two ways.
    1. Using a Table type.
    SQL> create or replace type my_dname_type as table of varchar2(14)
      2  /
    Type created.
    SQL> create or replace function my_dname_fn return my_dname_type
      2  as
      3     ldname my_dname_type;
      4  begin
      5     select dname bulk collect into ldname from hx_dept;
      6     return ldname;
      7  end;
      8  /
    Function created.
    SQL> select * from table(my_dname_fn())
      2  /
    COLUMN_VALUE
    ACCOUNTING
    RESEARCH
    SALES
    OPERATIONS2. using a ref cursor
    SQL> drop type my_dname_type
      2  /
    Type dropped.
    SQL> drop function my_dname_fn
      2  /
    Function dropped.
    SQL> create or replace function my_dname_fn return sys_refcursor
      2  as
      3     ldname sys_refcursor;
      4  begin
      5     open ldname for 'select dname from hx_dept';
      6     return ldname;
      7  end;
      8  /
    Function created.
    SQL> var ldname refcursor
    SQL> exec :ldname := my_dname_fn;
    PL/SQL procedure successfully completed.
    SQL> print :ldname
    DNAME
    ACCOUNTING
    RESEARCH
    SALES
    OPERATIONSto know more about this read oracle document.
    Thanks,
    Karthick.

  • 9I: How can get the names of all objects in a package header? [RESOLVED]

    Is there a way to get the names fo all objects (function, procedures) from package header
    select * from user_objects only gives the the header name, I need the object in the header.
    John
    Message was edited by:
    johnminkjan

    Here is an example with dbms_output package!
    SQL> select owner, object_name,procedure_name from all_procedures
      2  where  object_name='DBMS_OUTPUT';
    OWNER                          OBJECT_NAME                    PROCEDURE_NAME
    SYS                            DBMS_OUTPUT                    GET_LINES
    SYS                            DBMS_OUTPUT                    GET_LINE
    SYS                            DBMS_OUTPUT                    NEW_LINE
    SYS                            DBMS_OUTPUT                    PUT_LINE
    SYS                            DBMS_OUTPUT                    PUT_LINE
    SYS                            DBMS_OUTPUT                    PUT
    SYS                            DBMS_OUTPUT                    PUT
    SYS                            DBMS_OUTPUT                    DISABLE
    SYS                            DBMS_OUTPUT                    ENABLE
    9 rows selected.
    "or"
    SQL> desc dbms_output

  • How can I export schema with all objects and few tables without data

    Hi all
    Verion 10g EE.
    I have to export schema with all objects but i need to ingnore some of the table data.
    There are 4 table those have huge data, we need not to export those tables data but structure should export.
    Thanks,
    Nr

    You can do this with a single command.  Run your export as normal and add query parameters for the 4 tables that you don't want any rows:
    expdp ...  query=schema1.table1:"where rownum = 0" query=schema2.table2:"where rownum = 0" ...
    It is best to put the query parameters in a parameter file so you don't have to worry about escaping any OS special characters.
    Dean

  • How to return a javascript window.open object

    Hi all,
    I am calling a javascript function to create a window using the External Interface from flex. The function call works and I get a popup window, but I want to return the window.open object that I just created so that I reuse the same window again. I do not want to keep an array of window objects on the javascript side and pass an index back and forth. There will be multiple popup windows that needs to be written to.Right now the return value from the External Interface call is undefined.
    Thanks for any help here.
    Jerry

    Hmmm sound like somthing has gon wrong
    if it dont even work local you may have don somthing wrong when instaling the action ??
    is the action corectly placed in (GoLive Application Folder) / Modules / JScripts / Actions / ???
    What version of GL are you using ??
    Nate's FAQ on golive action:
    http://www.mindpalette.com/actions/faq.php#Anchor-47857
    "3. Why don't my third-party actions work in GoLive CS2?
    Because of a bug in GoLive CS2, the JavaScript code from some third-party actions is not automatically added to GoLive's external script library when first used (usually GeneratedItems/CSScriptLib.js at the top level of your GoLive site). To fix, open your GoLive site window and right click on the GeneratedItems/CSScriptLib.js file and choose Update > Flatten Script Library from the contextual menu.
    This will force GoLive to update the script library to include all used action code. Re-upload the file to your server and the action should be working again. You may need to clear your browser cache to force the new file to load if you've recently visited the page"
    Mayby others have had problem with his action to Try see his forum:
    http://www.mindpalette.com/forum/index.php
    you may also try this:
    1 Open the action as if its a normal document
    2 make a small change
    3 save
    4 change back /remove the change
    5 save
    6 restart golive

  • How to use data sets with smart objects?

    Hi,
    I have a psd of some mock-up boxes, and I want to apply different text to multiple versions. The solution here: http://helpx.adobe.com/photoshop/using/creating-data-driven-graphics.html is good, but doesn't seem to work with smart objects?
    The file that I have has the box label as a smart object (which opens as a psb). How could I apply a data set to that, and have it pump out multiple jpegs?
    If I apply the data set to the psb layers, then go back to the main image, I cannot export the whole complete picture anymore.
    Thanks!

    What database and connection type are you using? Are you connecting the report directly to the database, or trying to assign the datasource to object data?
    It sounds like you might be trying to use a linked list, collection or other C# construct to pass your data in. This currently isn't supported by the Crystal Reports SDK. You can use a DataSet or a DataTable, and possibly also an IDataReader depending on which version of Crystal Reports you're referencing in your project. Of course you can also connect directly to the database, even if the database isn't on the same machine as the application.
    The way to show master records with detail information is through the use of subreports and linked subreport parameters. Linked subreports take their parameter value from a record in the main report, so that only the data appropriate to that master record is displayed. The guys over in the [report design|SAP Crystal Reports; forum can help you out with this if you have questions on the specifics.

  • How to programati​cally set front panel objects (buttons) to enable, disabled, and disabled and gray

    I'm writing a program that when I am iterating through a loop, I want to have some buttons disabled and grayed. Once the loop is done, I want those buttons to now be enabled.
    But I have no clue how to programatically do this
    (aka enable and disable while the program is running, NOT before the program starts)
    Any help would be appreciated

    Create a property node, & select the 'Disabled' property.  Set it to 0 for enabled, 1 for disabled, & 2 for disabled & grayed.
    Paul Cardinale

  • How to change properties dinamically to all objects that are in a JPanel

    Hi experts!
    I have this code:
    JPanel pnlDataTxt;
    pnlDataTxt.add(new JTextField());
    But I want to change the properties of that JTextField after it has been added to the JPanel.
    How can I do that??

    Hi experts!
    I have this code:
    JPanel pnlDataTxt;
    pnlDataTxt.add(new JTextField());
    But I want to change the properties of that JTextField
    after it has been added to the JPanel.
    How can I do that??You have to create a handle to an instance of an object like:
    JTextField testField = new JTextField();
    JPanel pnlDataTxt;
    pnlDataTxt.add(testField);Now you can change the properties of "testField".

  • How to return or rollback the transport object in PRD?

    Hi Experts,
    I transported a revised program to PRD. But I decided to return it to my previous code. How would I do that in PRD?
    I'm not a real basis. PLease guide me.
    Points for the helpful ideas. Thanks!

    Hi,
    You have to move a separate transport with the version of the program you wanted from development to production. You cant change it in prod itself.
    Thanks
    Aneesh.

  • Changing the Owner of all Objects in Instance ?

    How to Change the Owner of all Objects in Instance, like for example the Procedure: sp_changedbowner in an MS-SQL-Database, who changed the Owner of the actual Database !
    I'am looking for another possibility to do it by export the Datbase and import as new Owner !

    Hi Laurent Schneider
    OCM DBA, I successfully run:
    connect SYS/&2 as SYSDBA;
    Update sys.obj$ set owner#=(Select USER# from sys.user$ where NAME = '&4')
    where owner#=(Select USER# from sys.user$ where NAME = '&3');
    commit;
    Afterwards I dropped the &3 User CASCADE and then created the &3 User with less rights ! Before Update-Command the &4 User shouldn't be the Owner of any Object ! At Last I'm not sure that is the right way ?!

  • Can I fix(set) the distorted object?

    I received a object to my client.
    It's distorted by 'Free Distort' effect in illustrator.
    I want distort path and all.
    = I want distort object irrevocably.
    Because of my plotter(big printer) cannot cognize distorted object.
    When i print distorted object, it's printing as NOT distorted object.
    How can I fix(set) the distorted object?
    help me please. :-)

    Thank you so much. it's working

  • List of all objects in the data dictionary

    How to capture the list of all objects in the data dictionary named like PSDFDI and verify they are granted to the FDIREADR role

    See the database security guide http://docs.oracle.com/cd/B28359_01/network.111/b28531/authorization.htm#BABFHBFH
    Finding Information About User Privileges and Roles
    This section discusses the system views that have the grant information.
    The tricky part of this is that because roles can be granted to other roles the data is hierarchical.
    So start with the grants made to the FDIREADR role. So referring to the doc above;
    select * from role_role_privs where role = 'FDIREADR'will list the roles granted to your role.
    You will want to look at ROLE_ROLE_PRIVS, ROLE_TAB_PRIVS and ROLE_SYS_PRIVS.
    I suggest you walk thru the views manually to see how the information is related. Then write a test script that queries the views for you.

  • How to set user preferred timezone in OBIEE for all objects.

    How to set user preferred timezone in OBIEE for all objects based on users TZ(may be from @{session.timeZone}). without changing My Account -> Preferences

    Check
    Time Zone Specification from http://docs.oracle.com/cd/E12844_01/doc/bip.1013/e12187/T421739T481157.htm#4535403
    just in case https://blogs.oracle.com/xmlpublisher/entry/how_to_keep_your_dates_from_go

  • How to return array of object

    public class A{
    public class B{
    publc C[] sample()
    int i=0;
    ResultSet rset = s.executeQuery("select name, id  from emp ");
    while(rs.next()){
    name = rset.getString("nam");
    id = rset.getInt("id");
    c.setName(name )
    c[i].setId(id)
    return c[]
    public class C{
    // here i have getter and setter metod for name & id
    When I try to return the object c[]..i am getting "cannot conver from C to C[]".
    Can u pls help me, how to return array of object and how to get name and id values in other class using this array object
    Thanks for ur help

    public class Starting{
    public long empID;
    Data data = new Data();
    Value[] value;
    int count = 0;
         public static void executeDe(){
              value = new Value[100]
              try{
                     data.getDetails()
                     processDetails(value);
                   }catch(Exception e){e.printStackTrace();}
         public static void processDetails(Value[] value){
         count = data.i;
              int i;
              for(i=0;i<count;i++){
                  empID=value.getempID(); \\ here i am not getting all values..... am getting only last value of the array
    public class Data{
    public long empID;
    public int i=0;
    static Value[] value = new Value[100];
    public static Value[] getDetails(){
    Connection con=null;
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con=DriverManager.getConnection("jdbc:oracle:thin:@" + hostname + ":1521:" + sid, user, password);
    System.out.println(" conn " + con);
    System.out.println("");
    Statement s=con.createStatement();
    try{
         ResultSet rset = s.executeQuery("select EMPID from Employee ");
         while(rset.next()){
    empID = rset.getLong("EMPID");
    value[i].setCycleID(cy_i);
    i++;
         rset.close();
         con.close();
    }catch (SQLException sqle){sqle.printStackTrace();}
         finally{
              try{
              s.close();
         con.close();
              }catch(SQLException e){e.printStackTrace();}
    catch(Exception e){e.printStackTrace();}
    return value;
         public class Value {
         public static long cycleID;
              public static void setempID(long empID) {
                   Value.empID = empID;
              public static long getempID() {
                   return empID;
    This is my actual code..... I am able to set the values in Value class from Data class using getDetails() method, which is returning array of value object.
    In Starting class, I am trying to get values using value[i].. i am getting last value of the array. This is my actual problem... here i want to get all values.
    Please help me how to resolve this.

Maybe you are looking for

  • Error while calling a Web Service from a Session Bean

    I am trying to call a Web Service from a Session Bean using an Axis client, but I am getting the next exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:      java.rmi.RemoteException: org/apache/axis/

  • Report for customer list

    Hi, Is there any report where if i have a list of customer number and i would like to know each of  the payment term of each customer? Or any T-code to display each payment term of each user in a long list? thanks. Joo

  • Is there a difference in Premier and After Effects Performance in terms of intel or AMD?

    Is there a difference in Premier and After Effects Performance in terms of intel or AMD?  Forget the speed issue, assume that the processors are of comparable speed and also assume that the system is built beyond recommended requirements.  When it co

  • IPhone email sub folders do not sync with Push feature

    Greetings all, I have been working with the iPhone for a while with one of my tasks being to the iPhone Sync Push technology to work well for us. Unfortunately it only partially works. It will on push to the root of the INBOX and any other sub folder

  • Only 90MB disk space after installing iLife '11 - how to move iLife?

    Hi, my installation of OS X is on a small SSD and I just barely had enough space to install iLife '11. I need more free disk space though so I need to move the largest iLife programs or maybe the whole thing. Obviously I wouldn't be posting here if t