[jboss-user] [EJB 3.0] - Re: Very Weird, Triplicated childs at runtime, all ok in the

raistlinmolina do-not-reply at jboss.com
Thu Sep 21 09:20:44 EDT 2006


I have tired with the other parent (ParameterEJB) and form this side childs are ok, no triplicated entries.

I copy the code from ParameterEJB.java below


  |    @OneToMany (mappedBy = "parameter")
  |    public Set<ReportParameterValueEJB> getReportParameterValues(){
  | 	   return this.reportParameterValues;
  |    }
  | 
  |    /**
  |     * Sets the value of the <code>events</code> property.
  |     *
  |     * @param events the value for the <code>events</code> property
  |     */
  |    public void setReportParameterValues(Set<ReportParameterValueEJB> reportParameterValues){
  | 	   this.reportParameterValues = reportParameterValues;
  |    }
  | 

And now the corresponding side at ReportParameterValueEJB.java


  | @ManyToOne (targetEntity = ParameterEJB.class, fetch = FetchType.EAGER)
  | 	@JoinColumn (name = "idParameter", insertable=false, updatable=false)
  | 	public ParameterEJB getParameter(){
  | 		return this.parameter;
  | 	}
  | 	
  | 	public void setParameter(ParameterEJB parameter){
  | 		this.parameter = parameter;
  | 		this.idParameter = parameter.getId();
  | 	}
  | 

now the code at the client:

  | 				ParameterEJB parameter = remote.getParameterByPK(1);
  | 
  | 				
  | 				if (parameter != null){
  | 					System.out.println(parameter.getName());
  | 					delete(parameter);
  | 				}
  | 				parameter = remote.getParameterByPK(2);
  | 				if (parameter != null){
  | 					System.out.println("Options: " + parameter.getParameterOptions().size());
  | 					if (parameter.getParameterOptions().size() > 0){
  | 						System.out.println("Option1: " + parameter.getParameterOptions().iterator().next().getOptionvalue());
  | 					}
  | 					Iterator <ReportParameterValueEJB> rpvs = parameter.getReportParameterValues().iterator();
  | 					System.out.println("Valores asignados: " + parameter.getReportParameterValues().size());
  | 					while ( rpvs.hasNext()){
  | 						ReportParameterValueEJB rpv = rpvs.next();
  | 						System.out.println("Valor asignado: " + rpv.getId()+" valor:" + rpv.getValue());
  | 					}
  | 					
  | 				}
  | 

And the output


  | Parameter created, Id:17
  | Options: 0
  | Values: 14
  | Value PK: 3 value:27
  | Value PK: 7 value:27
  | Value PK: 18 value:27
  | Value PK: 19 value:27
  | Value PK: 11 value:27
  | Value PK: 2 value:27
  | Value PK: 14 value:27
  | Value PK: 1 value:27
  | Value PK: 17 value:27
  | Value PK: 4 value:27
  | Value PK: 6 value:27
  | Value PK: 5 value:27
  | Value PK: 15 value:34
  | Value PK: 8 value:27
  | 
  | 


This relation works ok, the parameter with PK=2 has 14 childs, as the code shows.

Now, I don't understand why the other relations triplicates the childs!!!, they are the same type, they are coded equal..........

Please, If anyone sees the difference or something i'm doing wrong......

Thanks in advance.

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

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



More information about the jboss-user mailing list