ejbCreate and ResultSet - Whats Best

Discussions

EJB programming & troubleshooting: ejbCreate and ResultSet - Whats Best

  1. ejbCreate and ResultSet - Whats Best (6 messages)

    Hi All,

    I have a ResultSet which I want to pass to an Entity EJB ejbCreate method.

    Q. Should I pass it row by row, i.e. the ejbCreate method will only process one row at a time and have a parameter list matching the row column structure or should I just past the complete ResultSet to the ejbCreate method and handle the row and column split in the ejbCreate method?

    Thanks in advance,
    Stephen

     
  2. Hi,

    This really depends on what you are trying to do. Are you trying to:

    a) Create a single entity per row of the result set? In that case, your client code will have to call the create method of the home interface, and it should pass in the appropriate attributes that you want to create your entity bean with.

    b) Create a single entity based on data from multiple rows of the result set?

    In that case you will have to pass in the whole result set. Of course, you cannot call the create method more than once on the same entity.

    In general, I would not recommend passing a whole result set. This may be a LOT of information. You also have to ensure that the result set is serializable. Do you know for certain that it is?

    Can you give further details about what you are trying to accomplish?

    Regards,
    Steve
  3. What I trying to do is:

    Taking data, a resultset, from of a Sybase table, from a remote DB Server, (using a Session Bean which is calling a Stored Procedure, After somemore digging, Can a Session Bean return a ResultSet?).

    Then I am putting this data into a UDB table, which is in a UDB Database which resides on the Application Server. Client will then view data by looking through an Entity EJB which is attached to the UDB table on the App Server.

    You may ask why not attach the Entity to the Sybase table?
    Answer is:
    The client needs their own local copy of data, (a buffer prior to dumping changes back to Sybase) and the client requires fullish?? failover. With Clustering/Cloning I can spread the Entity EJB's attached to the UDB database across multiple servers.

    Then I getting into my EJB spaceship................ :-)
  4. I'm assuming you have a result set and each row in the result set should correspond to one entity bean...

    I don't think you can return a result set..result set are connected and probably not serializable..you'll need to extract the info from the result set and put it in your own, serializable "resultset."

    when you get this back i'd probably would not create the entity beans by calling create on the home ref..just have a store proc on udb do this or have a class that iterates through your result set and do a bunch of inserts...the reason is i figure doing a home lookup and doing a create is more expensive than just a batch sql or stor proc...

    --
    Tinou
    www.tinou.com
  5. ejbCreate and ResultSet - Whats Best[ Go to top ]

    You should NOT return a ResultSet object back to the client - the previous reply is correct, the ResultSet is connected to the DB. You should, however make use of the Value Object pattern to represent the data returned from the ResultSet, and make sure the VO is Serializable - then return this to the client.
  6. What about using CachedRowSet?
  7. What about using CachedRowSet?