• 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • 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?
 
Greenhorn
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
attributes.
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++)
{
try{
pk.id = i;
Customer customer = customerhome.findByPrimaryKey(pk);
}catch(javax.ejb.FindingException e) {break;}

if(customer.getDelinquency())
//process
}



 
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.

cheers

sagar
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic