TwinColSelect ManyToMany HbnContainer

Hi there,
i always get Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of org.ba.exchange.timetable.connector.dto.Bunch.id

I try to save a ManyToMany relation in TwinColSelect … Im using (testing ENterprise app) but that’s not the problem …


package org.ba.exchange.timetable.connector.dto;

import javax.persistence.*;



import java.util.Collection;


@Entity
@CrudTable(filteringPropertyName="login")
@Table(name="`user`")
public class User extends Dto implements User {
	
	private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy= GenerationType.AUTO)
    @Column(name = "id")
	private Long id;
	
	@Column(nullable=false, unique=true)
	private String login;
	
	@Column(nullable=false)
	@CrudField(isPassword=true, showInTable=false)
	private String password;

	@Column(nullable=false)
	private boolean configurationAccess;

	@Column(nullable=false)
	private boolean reportsAccess;
	
	@Override
	public String toString() {
		return login;
	}

	@Override
	public Long getId() {
		return id;
	}

	@Override
	public void setId(Object id) {
		this.id = (Long) id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	@Override
	public String getPassword() {
		return password;
	}

	@Override
	public void setPassword(String password) {
		this.password = password;
	}

	public boolean getConfigurationAccess() {
		return configurationAccess;
	}

	public void setConfigurationAccess(boolean configurationAccess) {
		this.configurationAccess = configurationAccess;
	}

	public boolean getReportsAccess() {
		return reportsAccess;
	}

	public void setReportsAccess(boolean reportsAccess) {
		this.reportsAccess = reportsAccess;
	}

    public boolean getCreateAccess(String module) {
        return true;
    }

    public boolean getReadAccess(String module) {
        return true;
    }

    public boolean getModifyAccess(String module) {
        return true;
    }

    public boolean getDeleteAccess(String module) {
        return true;
    }

    @ManyToMany(targetEntity=Bunch.class,cascade = CascadeType.DETACH,mappedBy = "user")
  
    private Collection<Bunch> bunch;

    public Collection<Bunch> getBunch() {
        return bunch;
    }

    public void setBunch(Collection<Bunch> bunch) {
        this.bunch = bunch;
    }

    @Override
    public int hashCode() {
        return getId().hashCode();
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj)
            return true;
        if (!(obj instanceof User))
            return false;
        return getId().equals(((User) obj).getId());
    }

}

and



package org.ba.exchange.timetable.connector.dto;



import javax.persistence.*;
import java.util.Collection;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: jakob
 * Date: 21.08.12
 * Time: 20:11
 * To change this template use File | Settings | File Templates.
 */
@Entity
public class Bunch extends Dto {
    @Id
    @GeneratedValue(strategy= GenerationType.AUTO)
    @Column(name = "id")
    private Long id;

    @Column(nullable=false)
    private String name;

    @Column(nullable=false)
    private String description;

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Object id) {
        this.id = (Long) id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @ManyToMany(targetEntity=User.class,cascade = CascadeType.DETACH)
    private Collection<User> user;

    public Collection<User> getUser() {
        return user;
    }

    public void setUser(List<User> user) {
        this.user = user;
    }

    @ManyToMany(cascade = CascadeType.DETACH, fetch = FetchType.EAGER)
    private Collection<Module> module;

    public Collection<Module> getModule() {
        return module;
    }

    public void setModule(Collection<Module> module) {
        this.module = module;
    }

    @Override
    public int hashCode() {
        return getId().hashCode();
    }

    // Note that I don't use direct field access inside my entity classes and
    // call getters instead. That's because Persistence provider (PP) might
    // want to load entity data lazily. And I don't use
    //    this.getClass() == other.getClass()
    // for the same reason. In order to support laziness PP might need to wrap
    // my entity object in some kind of proxy, i.e. subclassing it.
    @Override
    public boolean equals(final Object obj) {
        if (this == obj)
            return true;
        if (!(obj instanceof Bunch))
            return false;
        return getId().equals(((Bunch) obj).getId());
    }
}

and



   public EntityTwinColumn(Class<?> type, Collection<?> set,String visibleColumn) {
        this.type = type;
        this.container = ContainerFactory.getInstance().getContainer(type);


        initTwinColumnComponent();
        select.setSizeFull();
        select.setImmediate(true);

        //left
        select.setContainerDataSource(container);
        //right
        //select.setValue(set);  ?????

        select.setItemCaptionPropertyId(visibleColumn);

        refreshButton = new Button(Constants.uiRefresh);
        refreshButton.setTabIndex(-1);
        refreshButton.setStyleName(Reindeer.BUTTON_SMALL);
        refreshButton.addListener((Button.ClickListener) this);

        layout = new HorizontalLayout();
        layout.setSizeFull();
        layout.setSpacing(true);
        layout.addComponent(select);
        layout.setExpandRatio(select, 1);
        layout.addComponent(refreshButton);

        update();
        setCompositionRoot(layout);
    }

    protected void initTwinColumnComponent() {
        select = new TwinColSelect();
        select.setMultiSelect(true);
        select.setNullSelectionAllowed(true);
    }

    @Override
    public void attach() {
        super.attach();
        if(CrudTable.class.isAssignableFrom(getParent().getClass())) {
            refreshButton.setVisible(false);
        }
    }

    /**
     * Updates field items.
     */
    public void update() {
        select.removeAllItems();
        List<?> list = container.listAll();

        for(Object o : list) {
            String stringRep = o.toString();

            select.addItem(o);
            select.setItemCaption(o, stringRep);
        }


    }

    @Override
    public Class<?> getType() {
        return type;
    }

    @Override
    public void setValue(Object newValue) {
        select.setValue(newValue);
    }

    @Override
    public Object getValue() {
        return select.getValue();
    }

    @Override
    public void setPropertyDataSource(Property newDataSource) {
        select.setPropertyDataSource(newDataSource);
    }

    @Override
    public boolean isValid() {
        return select.isValid();
    }

    @Override
    public void validate() throws Validator.InvalidValueException {
        select.validate();
    }

    @Override
    public void setReadOnly(boolean readOnly) {
        select.setReadOnly(readOnly);
        refreshButton.setVisible(!readOnly);
    }

    @Override
    public void buttonClick(ClickEvent event) {
        update();
    }

    @Override
    public boolean isRequired() {
        return select.isRequired();
    }

    @Override
    public void setRequired(boolean required) {
        select.setRequired(required);
    }

    @Override
    public String getRequiredError() {
        return select.getRequiredError();
    }

    @Override
    public void setRequiredError(String requiredMessage) {
        select.setRequiredError(requiredMessage);
    }

    @Override
    public void addListener(Property.ValueChangeListener listener) {
        select.addListener(listener);
    }

    @Override
    public void addStyleName(String style) {
        select.addStyleName(style);
    }

    @Override
    public void setStyleName(String style) {
        select.setStyleName(style);
    }

    /**
     * @return layout where the field is presented.
     */
    public HorizontalLayout getLayout() {
        return layout;
    }

    /**
     * @return select field.
     */
    public AbstractSelect getSelect() {
        return select;
    }



set is selected, container is all …

Whats wrong ?

Thank you
Matthias