• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Bean List?

Ranch Hand
Posts: 297
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
New to all this, wondering how one goes about obtaining a list when using beans. For example, I have a customer bean, with primary key of customerID. What to do if I wanted a list of all the customers that, say, are delinquent on payments?
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you would have to create an entity bean called customer
which captures the business concept of delinqucy in it's
then, a client program would find the bean by findByPrimaryKey
method which is passed the primary key for the bean ; for ex :
CustomerHome customerhome = (CustomerHome)context.lookup("customer");

CustomerPK pk = new CustomerPK();
for (i=0;;i++)
pk.id = i;
Customer customer = customerhome.findByPrimaryKey(pk);
}catch(javax.ejb.FindingException e) {break;}


Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively you could create another session (stateless) bean to do the dtatabase search and call call this bean from your JSP/Servlet to return the resultset. The design choice is yours. But I would recommend a different stateless session bean to do this query as this would make your business logic more portable and reusable.
If your "search requirements" change in the future then you need to just change the fields to the method of the session bean without interfering with the Entity Bean-Customer.

Think about it.


To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic