View RSS Feed

heart_throbber

How to set value to entity?

Rate this Entry
by , 03-03-2012 at 07:42 AM (857 Views)
Quote Originally Posted by heart_throbber View Post
Hi all,
I have 2 DTOs & 2 Entities, 1 controller & 1 service implementation over here.

Now, my problem is at the service implementation setStates. I dont know how to set states to address entity from addressDTO's getStatesList. because address entity includes state entity while addressDTO using stateDTO .

My Address Entity:
Java Code:
public class Address
{
    private List<State> states;

    public List<State> getStates()
    {
        return states;
    }

    public void setStates(List<State> states)
    {
        this.states = states;
    }
}
My Address DTO:
Java Code:
public class AddressDTO
{
    private List<StateDTO> statesList;

    public List<StateDTO> getStatesList()
    {
        return statesList;
    }

    public void setStatesList(List<StateDTO> statesList)
    {
        this.statesList = statesList;
    }
}
My StateDTO:
Java Code:
public class StateDTO
{
    private StateTypeEnum stateType;

    private Map<String, String> stateAttr;

    public StateTypeEnum getStateType()
    {
        return stateType;
    }
    public void setStateType(StateTypeEnum stateType)
    {
        this.stateType = stateType;
    }
    public Map<String, String> getCertificationAttr()
    {
        return stateAttr;
    }
    public void setStateAttr(Map<String, String> stateAttr)
    {
        this.stateAttr = stateAttr;
    }
}
My State entity:
Java Code:
public class State
{
    private StateTypeEnum stateType;
    private Blob stateLogo;
    private Map<String, String> stateAttr;

    public StateTypeEnum getStateType()
    {
        return stateType;
    }
    public void setStateType(StateTypeEnum stateType)
    {
        this.stateType = stateType;
    }
    public Blob getStateLogo()
    {
        return stateLogo;
    }
    public void setStateLogo(Blob stateLogo)
    {
        this.stateLogo = stateLogo;
    }
    public Map<String, String> getStateAttr()
    {
        return stateAttr;
    }
    public void setStateAttr(Map<String, String> stateAttr)
    {
        this.stateAttr = stateAttr;
    }
}
My controller:
Java Code:
    private void submitAddress(AddressDTO addressDTO)
    { AddressService.createAddress(addressDTO); }
My service implementation:
Java Code:
    public void createAddress(AddressDTO addressDTO)
    {
        Address address = new Address();

       [B] address.setStates(addressDTO.getStatesList());[/B]
        AddressDAO.createAddress(address);
    }


Please guide..

Submit "How to set value to entity?" to Facebook Submit "How to set value to entity?" to Digg Submit "How to set value to entity?" to del.icio.us Submit "How to set value to entity?" to StumbleUpon Submit "How to set value to entity?" to Google

Tags: None Add / Edit Tags
Categories
Uncategorized

Comments