• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Locating a bean without executing ejbCreate

 
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question could be trivial, but I would appreciate your help nevertheless.
Since a client obtains an instance of a bean by executing the ejbCreate, throught the available Create methods, I am wondering what I would do if I just wanted to access a database without inserting rows in it. For example a database that is already populated by some sql script and I just want to execute queries in it. I understand obtaining an instance through the create methods, it means inserting row, for an entity bean.
Herbert.
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Herbert
We have two kind of interfaces for beans. Home and Remote. Now, in Home interface you would see finder methods like findByPrimaryKey and other finder methods that are customized.
These finder methods are the one you are looking for here. Create methods of Home interface would create new records in db and to lookup the existing records via some query you would use finder methods.
e.g. if we have ProductHome object with us we can do following,
// create two products with PK as Product1 and Product2
productHome.create("Product1","Description 1");
productHome.create("Product2","Description 2");
// at some other place you can just lookup the added products as
Product product = productHome.findByPrimaryKey("Product1");
System.out.println(product.getPrice());
....
...
// lookup another product
product = productHome.findByPrimaryKey("Prodduct2");
System.out.println(product.getPrice());
Hopefully this helps a little.
Maulin
 
Herbert Maosa
Ranch Hand
Posts: 289
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Maulin. I will try to do this and tell you how I fair. I am attemtping to access a MySql database, using an entity bean with bean managed persitence: And I have not figured out how to access my sql database yet. I am on Linux, but I guess I can not ask the linux specific question here. But I will report to you how I fair the find methods.
Cheers,
Herbert.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
How to implement entity bean cache, I mean whether ejbFind method will access db each time for BMP? How about CMP? Thanks.
 
author & internet detective
Posts: 42003
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For CMP, the container deals with caching so you don't have to. For BMP, if you want a cache, I think you will have to write one.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by shillong:
Hi,
How to implement entity bean cache, I mean whether ejbFind method will access db each time for BMP? How about CMP? Thanks.


For CMP, it is all vendor-specific. Caching is one of the selling points for an App Server.
 
Straws are for suckers. Now suck on this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic