how to create a new Entity Bean without insert a new record

Discussions

EJB programming & troubleshooting: how to create a new Entity Bean without insert a new record

  1. 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
  2. dont call the create method use the findByPrimaryKey method
  3. hi,
     stephen,thanks a lot !

    Can findByPrimaryKey() CREATE a new Entity Bean???? if we have none Entity Beans at first?
  4. hi,

    > stephen,thanks a lot !
    >
    > Can findByPrimaryKey() CREATE a new Entity Bean???? if we have none Entity Beans at first?

    if you wanna do that make a method in a facade bean and then call the findByPrimaryKey and if it returns null then create a new entity bean with the key you passed to findByPrimaryKey
  5. hi,
    stephen,thanks very much !!!!!!!!!!!!!!!!

    what does that facade bean do? create a new Entity Bean?so,when that FACADE create a new Entity Bean,it will insert a new record into DB too!
    so what should i do????

    thanks
    byw,do you get MSN?
  6. i think you need to re up on some j2ee design patterns and more on the EJB's session and entity
  7. I found some info from java.sun.com below:

    There are times when you do not want to provide create methods in an entity bean's home interface. Omit the create methods when you do not want the entity bean to create persistent data. Typically in these situations, some other system or process is responsible for creating the data underlying the entity bean's persistent representation. For example, database functions insert new data into a database, and clients use the entity bean to retrieve data.

    that's just what i mean.It's solution is "clients use the entity bean to retrieve data",yet ,i do not know how to retrieve data and create that Entity Bean.

    :'(