users@glassfish.java.net

Re: I have a tabled named

From: <noreply_at_java.net>
Date: Wed, 03 Nov 2010 08:11:50 -0700

I know it's frustrating but your question is still too general.

Here's a clip from a @Stateless session bean:

NOTE: /mfglbt/ is an entity bean wrapped into GLbudget class.

 

  /**

       Given an newGeneral Leger Budget, commit it to the DB, first
setting the status and date-created fields.

 **/

   public void insert(GLbudget budget) throws EXCdbio {
     budget.mfglbt.setStatus(EntityStatus.isLive);
     budget.mfglbt.setDateCreated(new Date());
     em.persist(budget.mfglbt);
  }
 

  /**

       Given an existing  General Leger Budget, commit it to the DB,
first setting the date-last-updated field.

 **/
  public void update(GLbudget budget) throws EXCdbio {
     budget.mfglbt.setDateChanged(new Date());
     em.merge(budget.mfglbt);
  }

Notice the *merge()*

 

These are snippets from working code ... hope they'll help you when thinking
about your problem.
 


--
[Message sent by forum member 'joerobbins']
View Post: http://forums.java.net/node/711073