error in the las email :

1- getting the collection from UF, add the city into the collection and 
setting the collection back to the UF (setMunicipios).


municipio = CadastroEJBGetter.getMunicipioHome().create();
municipio.setNome("Curitiba");
municipio.setSigla("CWB");
Collection c= uf.getMunicipios()
c.add(municipio);
-> uf.setMunicipios(uf.getMunicipios());
the right is : uf.setMunicipios(c);

Emerson Cargnin - SICREDI Servi�os wrote:

> I'm converting some bidirectional 1-n relationships no unidirectional, 
> once the navigation is not needed from one side, like cities and state. 
> I changed the relationship removing the accessor method in the blind 
> side and changed the ejb-jar.xml (xdoclet did that).
> 
> It's deployed ok and the tables are created ok too, with a relation 
> column from city (CIDADE) table to state (UF). The problem is that when 
> I create a city and add it to a state (UF) the relation is not added. I 
> tried in two differents ways :
> 
> 1- getting the collection from UF, add the city into the collection and 
> setting the collection back to the UF (setMunicipios).
> 
> 
> municipio = CadastroEJBGetter.getMunicipioHome().create();
> municipio.setNome("Curitiba");
> municipio.setSigla("CWB");
> Collection c= uf.getMunicipios()
> c.add(municipio);
> uf.setMunicipios(uf.getMunicipios());
> 
> 2 - Adding directly into the collection :
> 
> municipio= CadastroEJBGetter.getMunicipioHome().create();
> municipio.setNome("Curitiba");
> municipio.setSigla("CWB");
> uf.getMunicipios().add(municipio);
> 
> 
> Is there a prefered way to deal with unidirectional relations?
> 
> Here goes the ejb-jar.xml (municipio->city / UF -> state):
> 
>   <!-- unidirectional -->
>          <ejb-relationship-role >
>             <ejb-relationship-role-name>uf</ejb-relationship-role-name>
>             <multiplicity>One</multiplicity>
>             <relationship-role-source >
>                <ejb-name>UF</ejb-name>
>             </relationship-role-source>
>             <cmr-field >
>                <cmr-field-name>municipios</cmr-field-name>
>                <cmr-field-type>java.util.Collection</cmr-field-type>
>             </cmr-field>
>          </ejb-relationship-role>
>          <ejb-relationship-role >
> 
> <ejb-relationship-role-name>Municipio</ejb-relationship-role-name>
>             <multiplicity>Many</multiplicity>
>             <relationship-role-source >
>                <ejb-name>Municipio</ejb-name>
>             </relationship-role-source>
>          </ejb-relationship-role>
>       </ejb-relation>
>    </relationships>


-- 
Emerson Cargnin - MSA
SICREDI - Tel : 3358-4860



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to