Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Newbie needs help  RSS feed

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all, i have a noob question regarding j2ee......i'm supposed to write a sessionbean(ABSession) that provides a client interface to 2 CMP entity beans(a and b) that should have a many to many CMR between them. now, i'm confused about the "sessionbean that provides a client interface" part. is this 1 class file that specifies the interface for the 2 entity beans? or is there more to it? thanks for the help.

something like this?:
public interface ABSession extends EJBLocalHome
{
create(String name, int age) throws CreateException;
findByPrimaryKey(String name);
}

or:
public class ABSession implements SessionBean
{
public void ejbCreate() throws CreateException
{
}

//methods here
}
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For every session and entity bean, you must write the bean class, the home interface and the component interface. You will also need the ejb-jar.xml file, which will contain amongst other things the relationships between the beans. Note that a CMR field must be a local interface type (the EJB spec requires this).

Although there is often a tool which generates the ejb-jar.xml file, I recommend writing it yourself as a learning excercise.
 
tan kian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm.....so for my case i'll need a total of 9 files, 3 for the sessionbean and 3 for each entitybean?
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing is that simple in EJB. It is common that there will also be a vendor-specific deployment descriptor file. And if your session bean is invoked by a client, then you will have to write that client class too.

Let's not forget that data has to be passed around as arguments or return type. If your remote client needs either, then you may have to write a serializable class or two for data transfer.
 
tan kian
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i'm supposed to have a client for the sessionbean as well.....damm this is confusing
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!