[jboss-user] [JBoss Seam] - Re: Overriding EntityHome.persist problems

MikeDougherty do-not-reply at jboss.com
Fri Mar 9 20:47:47 EST 2007


Thanks for the response.


  | @Name("regionHome")
  | public class RegionHome extends EntityHome<Region>
  | {
  | 
  |     @RequestParameter 
  |     Long regionId;
  | 
  |     @In(required=false)
  |     Region region;
  | 
  |     @In
  |     WorkingMemory regionManagerWorkingMemory;
  |     
  |     @Override
  |     public Object getId() 
  |     { 
  |         if (regionId==null)
  |         {
  |             return super.getId();
  |         }
  |         else
  |         {
  |             return regionId;
  |         }
  |     }
  |     
  |     @Override @Begin(join=true)
  |     public void create() {
  |         info("create()");
  |         super.create();
  |     }
  | 
  |     @Override
  |     public String update() {
  |         info("update("+regionId+")" );
  |         return super.update();
  |     }
  | 
  |     @Override
  |     public String persist() {
  |         info("getId() == #0", getId()); // #1
  |         info("region.getId() == #0", region != null ? region.getId() : "null" ); // #2
  |         info("persist("+regionId+","+ (getInstance() != null ? getInstance().getId() : "null") +")" ); // #3
  | 
  |         if( region != null ) {
  |             regionManagerWorkingMemory.assertObject(region);
  |             regionManagerWorkingMemory.fireAllRules();
  |             setInstance(region);
  |         }
  |         return super.persist();
  |     }
  | 
  |     @Override
  |     public String remove() {
  |         info("remove("+regionId+")" );
  |         return super.remove();
  |     }
  | }
  | 

In the persist method line #1 prints:

  | 17:17:08,163 INFO  [RegionHome] getId() == null
  | 

#2:

  | 17:17:08,164 INFO  [RegionHome] region.getId() == 1
  | 

#3:

  | 17:17:08,165 INFO  [RegionHome] persist(null,null)
  | 

I'm trying to get my head around this in the persist method using existing data (Entities) before tackling the update method... 

Actually, now that you mention it the page *should* be calling the update method. Maybe I need to be looking at the region.xhtml to see why it's calling persist instead of update first.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026819#4026819

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4026819



More information about the jboss-user mailing list