Hi

I have three entities in my domain: Country, Province and City.
Country has a bi-directional OneTOMany relation with Province as below:
        // In Country.java
        private Set<Province> provinces = new HashSet<Province>();
        ...
        @OneToMany( mappedBy = "country",fetch = FetchType.EAGER)
        public Set<Province> getProvinces() {
                return provinces;
        }
        
        // In Province.java
        private Country country;
        @ManyToOne
        public Country getCountry() {

                return country;
        }

Province has a bi-directional OneToMany relation with City as below:
        // In Province.java
        private Set<City> cities;
        ...
        @OneToMany( mappedBy = "province" , fetch = FetchType.EAGER )
        public Set<City> getCities() {
                return cities;
        }
        
        // In City.java
        private Province province;
        ...
        @ManyToOne
        public Province getProvince() {
                return province;
        }

In my ProvinceAction I have added a countryList that is populated 
with countryManager.getAll() method and displayed in provinceForm.jsp
as a select drop down.

The problem is that I have multiple same entries in this list, for example
if I enter 3 provinces with USA as country, I will have 3 USA in country
select 
box (in database everything is OK).

If I replace Set with List then I had to make my relations LAZY (because an
Entity
can not have 2 EAGER collections) and if I do that I get
LazyInitializationException.

Any hekp please,
Ali Behzadian Nejad.

-- 
View this message in context: 
http://www.nabble.com/OneToMany-Relation-Problem-tp18890496s2369p18890496.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to