• Post Reply Bookmark Topic Watch Topic
  • New Topic

New to EJBs  RSS feed

 
Lance X. Greenberg
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to populate a listbox with all the values from a reference table. I'm not quite sure of the "correct" way to do this with EJBs. Should I have a CMP with a findAll method that is called by a session EJB? The session EJB could then iterate through all of the returned CMP references getting the particular field of interest and bundle them up in a vector or array and return them to the client. I am concerned about this if the findAll returns several hundred CMP references. Is this a problem? Thanks in advance.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lance Greenberg:
I am concerned about this if the findAll returns several hundred CMP references. Is this a problem? Thanks in advance.

Your approach is defintely acceptable . Several 100 probably w'd not be an issue. If it's a table with lots of data, then yes. Infact from what i gather (from discussions here) , i have a feelign that , we s'dnt even be mapping an entity bean to such tables. Either way, your solution looks good.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using the values for read only purpose I suggest you to use simple JDBC rather call finder methods.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Infact in most of the applications / screens, data is generally displayed on the UI in a table format. The data is normally picked from 1 / multiple tables. We use a homegrown framework to render such data. It ofcourse has advanced rendering capabilities , has the ability to use a SQL , or any callback methods to generate the data to be rendered. If you can spare some time , and you already dont have one ,try developing one, It c'd be an interesting project and i'm sure it c'd be so easily reused across various projects.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This problem begs the question: how often does data in your drop down change ? If not a lot; you could write something that will query the DB, persist results to a file on disk. Then your drop down is just a load from a text file from the local server. Add some caching for the file, and your form will perform considerably under load.
And you're saved from the performance hits of:
a) remote call to the db server
b) remote call to the EJB container
Pho
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!