JPAContainer ManyToMany binding with TwinColSelect and FieldGroup
Hi,
i’m trying to bind a property to a TwinColSelect using the FieldGroup. I’ve tried a lot of examples which i came across but nothing works.
This are my simplified entities:
Vehicle Entity
@Entity
public class Vehicles implements Serializable {
@Id
private Integer id;
@Column(length = 255, nullable = false)
private String name;
@Column(nullable = true)
private String description;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "t_vehicles_features", joinColumns = { @JoinColumn(name = "vehicles_id") }, inverseJoinColumns = { @JoinColumn(name = "features_id") })
private Set<Features> features = new HashSet<Features>();
...
Features Entity
@Entity
public class Features implements Serializable {
@Id
private Integer id;
@Column(length = 255, nullable = false)
private String name;
@Column(nullable = true)
private String description;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "t_vehicles_features", joinColumns = { @JoinColumn(name = "features_id") }, inverseJoinColumns = { @JoinColumn(name = "vehicles_id") })
private List<Vehicles> vehicles = new Vector<Vehicles>();
...
The component initialisation
mFeaturesTwinColSelect = new TwinColSelect();
mFeaturesTwinColSelect.setImmediate(true);
mFeaturesTwinColSelect.setNullSelectionAllowed(true);
mFeaturesTwinColSelect.setMultiSelect(true);
mFeaturesTwinColSelect.setLeftColumnCaption("Available");
mFeaturesTwinColSelect.setRightColumnCaption("Selected");
mFieldGroup.bind(mFeaturesTwinColSelect, "features");
Container datasource assignment
JPAContainer<Features> container = JPAContainerFactory.makeNonCachedReadOnly(Features.class, mEntityManager);
container.sort(new Object[] { "name" }, new boolean[]
{ true });
mFeaturesTwinColSelect.setContainerDataSource(container);
mFeaturesTwinColSelect.setItemCaptionPropertyId("name");
//Set the converter
mFeaturesTwinColSelect.setConverter(new MultiSelectConverter(mFeaturesTwinColSelect));
I really don’t get where the problem is. If anyone could help me out i would be really grateful.
Thanks in advance.