Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does CREATE a EntityBean mean insert a new record into DB?

 
Mike Lin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if we use finder methods ,the Entity Bean must have bean instanced!
right?
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finder methods may return an entityLocal object or a Collection of local objects.
For example if you use findByPrimaryKey() this will return a entityLocal object.
EntityLocal entityLocal = null;
try{
entityLocal = entityLocalHome.findByPrimaryKey(primaryKey);
....................
}
You can use the same sintax after using any finder method. For example, if you have a finder that returns a Collection you can write something like:

EntityLocal entityLocal = null;
try{
Collection collection = entityLocalHome.findBySomeCriteria(criteria);
....................
Iterator it = collection.iterator();
while(it.hasNext()){
entityLocal = (EntityLocal)it.next();
//operations on the entity...
}
}
Hope this helps.
Sergiu.
 
Mike Lin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks very much.
In fact ,what i want to know is "Does CREATE a EntityBean mean insert a new record into DB"???
 
Rufus BugleWeed
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AFAIK - create an entity bean means add a new a record to the db, yes.
 
shyam jakki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact ,what i want to know is "Does CREATE a EntityBean mean insert a new record into DB"???

Hi
Yes Create a EntityBean means inserting a new Record to the database.
Since each entity bean represents a table in the database and each instance of that bean is a row in that table.
Since ejbCreate()-Insert new record
ejbFindxxx()-Select-It is used to locate the entity Bean.
Go through the spec and life cycle of EntityBean
shyam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic