Boa tarde.
Eu estou com um pequeno problema, eu faço uma requisição AJAX com o seguinte objeto como parametro:
{
obj.active: "Y"
obj.collector: "Rafael"
obj.consolidation: "3"
obj.customer: "111111111"
obj.daysFromBLIssue: "50"
obj.direction: "EXP"
obj.emails: "teste@de.email.com"
obj.excel: "N"
obj.expiration: "1"
obj.id: ""
obj.locale: "0655"
obj.print: "Y"
obj.segregations[0].charge: "2234"
obj.segregations[0].group: 1
obj.segregations[1].charge: "123"
obj.segregations[1].group: 1
obj.segregations[2].charge: "566"
obj.segregations[2].group: 2}
Tenho a seguinte action:
[code]@Post("/special/condition/")
public void save(SpecialCondition obj) {
System.out.println(obj);
message.success("successfully-saved");
}[/code]
Esse sysout gera a seguinte string (alterei o toString para mostrar os campos e os valores):
{
id:null,
customer:{
code:'111111111',
name:'SADIA',
cnpj:'123123123123123'},
collector:'Rafael',
direction:'EXP',
locale:{
code:'0655',
name:'ITAJAÍ'},
emails:'teste@de.email.com',
active:'Y',
consolidation:{
id:3,
name:'VESSEL_CONSOLIDATION'},
daysFromBLIssue:'50',
expiration:{
id:1,
name:'NORMAL_EXPIRATION'},
expirationComplement:'null',
segregations:null,
print:'Y',
excel:'N'
}
Como podem perceber a lista segregations está vindo nula…
Seguem meus 2 modelos:
[code]public class SpecialCondition implements DataTables, SetId {
@Id
@Column(name = "SPECIAL_CONDITION_ID")
private Long id;
@ManyToOne
@JoinColumn(name = "sfc", columnDefinition = "char")
private Customer customer;
@Column(name = "COLLECTOR")
private String collector;
@Enumerated(EnumType.STRING)
@Column(name = "direction", columnDefinition = "char")
private Direction direction;
@ManyToOne
@JoinColumn(name = "locale_code", columnDefinition = "char")
private Locale locale;
@Column(name = "emails")
private String emails;
@Enumerated(EnumType.STRING)
@Column(name = "active", columnDefinition = "char")
private Flag active;
@ManyToOne
@JoinColumn(name = "consolidation_id")
private Consolidation consolidation;
@Column(name = "days_from_bl_issue")
private int daysFromBLIssue;
@ManyToOne
@JoinColumn(name = "special_expiration_id")
private SpecialExpiration expiration;
@Column(name = "special_expiration_complement")
private Integer expirationComplement;
@OneToMany(mappedBy = "specialCondition")
private List<ChargeSegregation> segregations;
@Enumerated(EnumType.STRING)
@Column(name = "print", columnDefinition = "char")
private Flag print;
@Enumerated(EnumType.STRING)
@Column(name = "excel", columnDefinition = "char")
private Flag excel;
// getters e setters
}[/code]
[code]public class ChargeSegregation implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@ManyToOne
@JoinColumn(name = "charge_id")
private Charge charge;
@Id
@ManyToOne
@JoinColumn(name = "special_condition_id")
private SpecialCondition specialCondition;
@Column(name = "charge_segregation_group")
private int group;
// getters e setters
}[/code]
Ou seja, todos os parâmetros estão sendo populados menos a List<ChargeSegregation> segregations… Estou passando errado?