This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Originally posted by Mike Lin: Can findByPrimaryKey() CREATE a new Entity Bean??? if we have none Entity Beans at first?
No, findByPrimaryKey() method is supposed to be a read-only method. It is not supposed to create/update the rows in the database. To create() rows in the database, you should use create() methods in the entity bean. It is also possible not to have create() methods in an entity bean, if your design does not include inserstion of new rows by the entity beans. U can have read-only entity beans with no create() methods...and have only finder methods and some business methods. But findByPrimaryKey() is a compulsory method, to be defined in ur entity bean.
Joined: Oct 29, 2002
what i want is not a read only Entity Bean but a BEAN replasents a record of a DB and maybe i will update it. so how can i get that Entity Bean?
Am not clear about the read-only beans that is being discussed here. But i guess some of the business method might be provided to update the bean. So since the finder returns a valid Local / remote reference, cant i update the bean using that reference? I understand that i cannot create rows in the DB since i have not provided a create.
Joined: Aug 27, 2003
Originally posted by Mike Lin: what i want is not a read only Entity Bean but a BEAN replasents a record of a DB and maybe i will update it. so how can i get that Entity Bean?
-You need to design/write an Entity Bean. If you are not interested in having create() methods to insert new rows in your associated table, then don't have it. You could have finder methods and business methods. You may have to refer an EJB book to know, details of writing an Entity Bean...