[jboss-user] [JBoss Seam] - seam-gen : two attributes of same kind in an entity

atao do-not-reply at jboss.com
Wed Feb 28 18:50:46 EST 2007


Hello,

I use seam-gen (seam 1.1.7.RC1) to generate list and home classes from entities with jpaconfiguration .

One class, Contract,  has two attributs, seller and purchaser, with the same type Party. 

The generated ContractHome class contains:

  | 	@In(value = "#{partyHome.managedInstance}", required = false)
  | 	Party seller;
  | 	@In(value = "#{partyHome.managedInstance}", required = false)
  | 	Party purchaser;
  | 
  | 

So seller and purchaser use the same instance!

Any idea to get two different instances?

Regards
Pierre

PJ :



  | @Name("contract")
  | @javax.persistence.Entity
  | public class Contract extends Entity
  | {
  | 	
  |     private DateTime      begin;
  |     private DateTime      end;
  |     private Party         seller;
  |     private Party         purchaser;
  |     
  |     public Contract()
  |     {
  |     	this(null);
  |     }
  | 
  |     public Contract(Party seller)
  |     {
  |         this(seller, null);
  |     }
  | 
  |     public Contract(Party seller, Party purchaser)
  |     {
  |         super();
  |         this.seller = seller;
  |         this.purchaser = purchaser;
  |     }
  | 
  |     @Id 
  |     public String getId() {return super.getId();}
  |     public void setId(String id) {super.setId(id);}
  | 
  |     /**
  |      * the seller
  |      */
  |     @ManyToOne
  |     @JoinColumn(name="sellerId")
  |     public Party getSeller() {return this.seller;}
  |     public void setSeller(Party seller) {this.seller = seller;}
  |     public Contract seller(Party seller) {
  |         setSeller(seller);
  |         return this;
  |     }
  | 
  |     /**
  | 	 * the purchaser
  | 	 */
  | 	@ManyToOne
  |     @JoinColumn(name="purchaserId")
  | 	public Party getPurchaser() {return this.purchaser;}
  | 	public void setPurchaser(Party purchaser) {this.purchaser = purchaser;}
  |     public Contract purchaser(Party purchaser) {
  |         setPurchaser(purchaser);
  |         return this;
  |     }
  | 
  | 	/**
  | 	 * the begin date
  | 	 */
  |     @Column(name="begindate")
  |     @Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
  |     public DateTime getBegin() {return this.begin;}
  | 	public void setBegin(DateTime begin) {this.begin = begin;}
  |     public Contract begin(DateTime begin) {
  |         setBegin(begin);
  |         return this;
  |     }
  | 
  | 	/**
  | 	 * the end date
  | 	 */
  |     @Column(name="enddate")
  |     @Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
  | 	public DateTime getEnd() {return this.end;}
  | 	public void setEnd(DateTime end) {this.end = end;}
  |     public Contract end(DateTime end) {
  |         setEnd(end);
  |         return this;
  |     }
  | 
  |     /* (non-Javadoc)
  |      * @see java.lang.Object#toString()
  |      */
  |     @Override
  | 	public String toString()
  | 	{
  | 		return "Contract("   + getPurchaser().getName() 
  | 		             + " ["  + getBegin() 
  | 		             + " - " + getEnd()
  | 		             + " ])";
  | 	}
  | 
  | }
  | 



  | @Name("contractHome")
  | public class ContractHome extends EntityHome<Contract> {
  | 
  | 	@In(value = "#{partyHome.managedInstance}", required = false)
  | 	Party seller;
  | 	@In(value = "#{partyHome.managedInstance}", required = false)
  | 	Party purchaser;
  | 
  | 	public void setContractId(String id) {
  | 		setId(id);
  | 	}
  | 
  | 	public String getContractId() {
  | 		return (String) getId();
  | 	}
  | 
  | 	@Override
  | 	protected Contract createInstance() {
  | 		Contract contract = new Contract();
  | 		return contract;
  | 	}
  | 
  | 	public void wire() {
  | 		if (seller != null) {
  | 			getInstance().setSeller(seller);
  | 		}
  | 		if (purchaser != null) {
  | 			getInstance().setPurchaser(purchaser);
  | 		}
  | 	}
  | 
  | 	public boolean isWired() {
  | 		return true;
  | 	}
  | 
  | 	public Contract getManagedInstance() {
  | 		return isManaged() ? getInstance() : null;
  | 	}
  | 
  | }
  | 



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

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



More information about the jboss-user mailing list