• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to create a new entity bean without insert new records

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when we call EJBCreate() in CMP,the container will insert a new record into database .yet sometimes we just want to get or view some records ,what we can do ???
thanks a lot
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then we use the findBy***() methods.
 
Mike Lin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can findByPrimaryKey() CREATE a new Entity Bean??? if we have none Entity Beans at first?
 
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 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.
 
Mike Lin
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Vishwa Kumba
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 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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic