Hi,
Sorry for my bad english
I want do to a OneToMany Relationship with JPA / Beans.
The Database seems to be correct but my ComboBox does not Represent the Value of my Entity and did not save the Value.
The other fields are working fine.
[code]
@Entity
public class Mwm implements Serializable {
private static final long serialVersionUID = 1L;
public static final String PRIMARY_KEY = null;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String Bezeichnung;
private Integer Nummer;
@OneToMany (mappedBy="mwm")
java.util.Set<Art> arts;
[/code][code]
@Entity
public class Art implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String ArtNr;
private String Bezeichnung;
@ManyToOne
private Mwm mwm;
[/code]I Try to Represent the Values Like This.
[code]
mwm = new ComboBox(āMWMā);
mwm.setContainerDataSource(mwmContainer);
//mwm.setConverter(converter);
mwm.setConverter(MwmConverter.class);
// create FieldGroup
editorFields = new BeanFieldGroup<Art>(Art.class);
editorFields.setItemDataSource(new BeanItem<Art>(a));
editorFields.bindMemberFields(this);
[/code]And I have a Converter ā¦
[code]
public class MwmConverter implements Converter<String, Set>
{
private static final long serialVersionUID = -220989690852205509L;
@Override
public Set convertToModel(String value,
Class<? extends Set> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return null; // Unused
}
@Override
public String convertToPresentation(Set value,
Class<? extends String> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
return value.toString(); // Java 8
}
@Override
public Class<Set> getModelType() {
return (Class<Set>) new HashSet().getClass().getSuperclass();
}
@Override
public Class getPresentationType() {
return String.class;
}
}
[/code]I hope someone can help me
I think the mistake is in the Converter or maybe at the Entity