When sending the POST request from my angular client to my Rest API, I am getting the above error.
below is my request model coming from angular client:
{
"anmeldename":"KBBT765",
"nachname":"nach",
"vorname":"vor",
"telefonnummer":"4563",
"password":"szpi;ItM",
"rolle":"B",
"region":"Z",
"eiuname":"",
"zbname":"",
"evuname":"",
"spnv":false,
"spfv":false,
"sgv":false,
"fromEdit":false
}
Below is the rest API POST method to handle the request from angular client and parse the json fields to Benutzer Model:
#POST
#Path("speichern")
#Consumes(MediaType.APPLICATION_JSON)
public boolean speichern(Benutzer benutzerInfo) {
--------------
---------------
}
Rest API Benutzer Model is below:
#JsonIgnoreProperties(ignoreUnknown = true)
public class Benutzer implements Serializable {
private String nachname;
private String anmeldename;
private String vorname;
private String rolle;
private String region;
private String eiuname;
private String zbname;
private String evuname;
private String password;
private String telefonnummer;
private String defaultAnmeldname;
private Boolean spnv;
private Boolean spfv;
private Boolean sgv;
private Boolean fromEdit;
#JsonProperty("evuProfilelist")
private List<EvuProfilSelectedItem> evuProfilelist;
public void setRolle(String rolle) {
this.rolle = rolle;
}
public void setRegion(String region) {
this.region = region;
}
public void setEiuname(String eiuname) {
this.eiuname = eiuname;
}
public void setZbname(String zbname) {
this.zbname = zbname;
}
public void setEvuname(String evuname) {
this.evuname = evuname;
}
public void setSpnv(Boolean spnv) {
this.spnv = spnv;
}
public void setSpfv(Boolean spfv) {
this.spfv = spfv;
}
public void setSgv(Boolean sgv) {
this.sgv = sgv;
}
public String getRolle() {
return rolle;
}
public String getRegion() {
return region;
}
public String getEiuname() {
return eiuname;
}
public String getZbname() {
return zbname;
}
public String getEvuname() {
return evuname;
}
public Boolean isSpnv() {
return spnv;
}
public Boolean isSpfv() {
return spfv;
}
public Boolean isSgv() {
return sgv;
}
public void setPassword(String password) {
this.password = password;
}
public List<EvuProfilSelectedItem> getEvuProfilelist() {
return evuProfilelist;
}
public void setEvuProfilelist(List<EvuProfilSelectedItem> evuProfilelist) {
this.evuProfilelist = evuProfilelist;
}
public String getPassword() {
return password;
}
public String getTelefonnummer() {
return telefonnummer;
}
public void setTelefonnummer(String telefonnummer) {
this.telefonnummer = telefonnummer;
}
public String getNachname() {
return nachname;
}
public void setNachname(String nachname) {
this.nachname = nachname;
}
public String getAnmeldename() {
return anmeldename;
}
public void setAnmeldename(String anmeldename) {
this.anmeldename = anmeldename;
}
public String getVorname() {
return vorname;
}
public void setVorname(String vorname) {
this.vorname = vorname;
}
public Boolean isFromEdit() {
return fromEdit;
}
public void setFromEdit(Boolean fromEdit) {
this.fromEdit = fromEdit;
}
public String getDefaultAnmeldname() {
return defaultAnmeldname;
}
public void setDefaultAnmeldname(String defaultAnmeldname) {
this.defaultAnmeldname = defaultAnmeldname;
}
}
Stack Trace:
2020-03-05 06:42:57,017|ERROR|http-0.0.0.0:17206-4|kigbau.client.RestExceptionMapper||(Request-ID: 9fdG4mDBJWUqtjnqWhdx32) Propagating Exception to the client||| org.codehaus.jackson.map.JsonMappingException: Illegal type (de.db.kigbau.client.domain.Benutzer) to deserialize: prevented for security reasons at org.codehaus.jackson.map.deser.BeanDeserializerFactory.checkLegalTypes(BeanDeserializerFactory.java:1536) at org.codehaus.jackson.map.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:668)
Is this due to blank or null values in the fields coming from angular client or some thing else?
Please help. Thank you in advance.
I am doing a liferay project which use ejb at back end. so my ejb method looks like this:-
#Override
public List<RmisPaymentDetailsDto> getEpaymentDetails(String ebpCode) {
Query q = entityManager.createQuery("select s from EpaymentBo s where s.ebpCode=:ebpcode")
.setParameter("ebpcode",ebpCode);
#SuppressWarnings("unchecked")
List<ProductBo> list = q.getResultList();
Iterator<ProductBo> i = list.iterator();
List<RmisPaymentDetailsDto> rList = new ArrayList<RmisPaymentDetailsDto>();
while(i.hasNext()){
EpaymentBo ep =(EpaymentBo) i.next();
RmisPaymentDetailsDto dto = new RmisPaymentDetailsDto();
dto.setAdvertisementcode(ep.getAdvertisementcode());
dto.setAmount(ep.getAmount());
dto.setStudentmasterid(ep.getStudentmasterid());
dto.setEbpgendate(ep.getEbp_gen_date());
dto.setEbpcode(ep.getEbpCode());
dto.setPaymentstatus(ep.getPaymentstatus());
dto.setCandidatenameinnepali(ep.getCandidatenameinnepali());
rList.add(dto);
}
return rList;
}
the above method successfully fetches data from database and sets it to my RmisPaymentDetailsDto.
like this:-
now i am calling same method from my liferay controlller.
PreExaminationRemote preRef = (PreExaminationRemote) jndiContext
.lookup("PreExamination/remote");
List<RmisPaymentDetailsDto> rDto = preRef.getEpaymentDetails(ebpCode);
I am wondering how my one property(candidatenameinnepali) is lost as i return same dto from my ejb.
My dto looks like this:-
public class RmisPaymentDetailsDto implements Serializable {
private static final long serialVersionUID = 1L;
private String advertisementcode;
private String ebpcode;
private String amount;
private String studentmasterid;
private Date ebpgendate;
private String paymentstatus;
private String candidatenameinnepali;
public String getCandidatenameinnepali() {
return candidatenameinnepali;
}
public void setCandidatenameinnepali(String candidatenameinnepali) {
this.candidatenameinnepali = candidatenameinnepali;
}
public String getAdvertisementcode() {
return advertisementcode;
}
public void setAdvertisementcode(String advertisementcode) {
this.advertisementcode = advertisementcode;
}
public String getEbpcode() {
return ebpcode;
}
public void setEbpcode(String ebpcode) {
this.ebpcode = ebpcode;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getStudentmasterid() {
return studentmasterid;
}
public void setStudentmasterid(String studentmasterid) {
this.studentmasterid = studentmasterid;
}
public Date getEbpgendate() {
return ebpgendate;
}
public void setEbpgendate(Date ebpgendate) {
this.ebpgendate = ebpgendate;
}
public String getPaymentstatus() {
return paymentstatus;
}
public void setPaymentstatus(String paymentstatus) {
this.paymentstatus = paymentstatus;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
I'm struggling to implement a solution to retrieve multiple values from my api response ( https://www.thecocktaildb.com/api/json/v1/1/lookup.php?i=13060 ) and assign specific values to an array. Specifically values, strIngredient1, strIngredient2, strIngredient3 etc...
At present i created a POJO cocktail class as follows:
public class Cocktail implements Serializable {
#SerializedName("idDrink")
#Expose
private String idDrink;
#SerializedName("strDrink")
#Expose
private String strDrink;
#SerializedName("strVideo")
#Expose
private Object strVideo;
#SerializedName("strCategory")
#Expose
private String strCategory;
#SerializedName("strIBA")
#Expose
private Object strIBA;
#SerializedName("strAlcoholic")
#Expose
private String strAlcoholic;
#SerializedName("strGlass")
#Expose
private String strGlass;
#SerializedName("strInstructions")
#Expose
private String strInstructions;
#SerializedName("strDrinkThumb")
#Expose
private String strDrinkThumb;
#SerializedName("strIngredient1")
#Expose
private String strIngredient1;
#SerializedName("strIngredient2")
#Expose
private String strIngredient2;
#SerializedName("strIngredient3")
#Expose
private String strIngredient3;
#SerializedName("strIngredient4")
#Expose
private String strIngredient4;
#SerializedName("strIngredient5")
#Expose
private String strIngredient5;
#SerializedName("strIngredient6")
#Expose
private String strIngredient6;
#SerializedName("strIngredient7")
#Expose
private String strIngredient7;
#SerializedName("strIngredient8")
#Expose
private String strIngredient8;
#SerializedName("strIngredient9")
#Expose
private String strIngredient9;
#SerializedName("strIngredient10")
#Expose
private String strIngredient10;
#SerializedName("strIngredient11")
#Expose
private String strIngredient11;
#SerializedName("strIngredient12")
#Expose
private String strIngredient12;
#SerializedName("strIngredient13")
#Expose
private String strIngredient13;
#SerializedName("strIngredient14")
#Expose
private String strIngredient14;
#SerializedName("strIngredient15")
#Expose
private String strIngredient15;
#SerializedName("strMeasure1")
#Expose
private String strMeasure1;
#SerializedName("strMeasure2")
#Expose
private String strMeasure2;
#SerializedName("strMeasure3")
#Expose
private String strMeasure3;
#SerializedName("strMeasure4")
#Expose
private String strMeasure4;
#SerializedName("strMeasure5")
#Expose
private String strMeasure5;
#SerializedName("strMeasure6")
#Expose
private String strMeasure6;
#SerializedName("strMeasure7")
#Expose
private String strMeasure7;
#SerializedName("strMeasure8")
#Expose
private String strMeasure8;
#SerializedName("strMeasure9")
#Expose
private String strMeasure9;
#SerializedName("strMeasure10")
#Expose
private String strMeasure10;
#SerializedName("strMeasure11")
#Expose
private String strMeasure11;
#SerializedName("strMeasure12")
#Expose
private String strMeasure12;
#SerializedName("strMeasure13")
#Expose
private String strMeasure13;
#SerializedName("strMeasure14")
#Expose
private String strMeasure14;
#SerializedName("strMeasure15")
#Expose
private String strMeasure15;
#SerializedName("dateModified")
#Expose
private String dateModified;
public String getIdDrink() {
return idDrink;
}
public void setIdDrink(String idDrink) {
this.idDrink = idDrink;
}
public String getStrDrink() {
return strDrink;
}
public void setStrDrink(String strDrink) {
this.strDrink = strDrink;
}
public Object getStrVideo() {
return strVideo;
}
public void setStrVideo(Object strVideo) {
this.strVideo = strVideo;
}
public String getStrCategory() {
return strCategory;
}
public void setStrCategory(String strCategory) {
this.strCategory = strCategory;
}
public Object getStrIBA() {
return strIBA;
}
public void setStrIBA(Object strIBA) {
this.strIBA = strIBA;
}
public String getStrAlcoholic() {
return strAlcoholic;
}
public void setStrAlcoholic(String strAlcoholic) {
this.strAlcoholic = strAlcoholic;
}
public String getStrGlass() {
return strGlass;
}
public void setStrGlass(String strGlass) {
this.strGlass = strGlass;
}
public String getStrInstructions() {
return strInstructions;
}
public void setStrInstructions(String strInstructions) {
this.strInstructions = strInstructions;
}
public String getStrDrinkThumb() {
return strDrinkThumb;
}
public void setStrDrinkThumb(String strDrinkThumb) {
this.strDrinkThumb = strDrinkThumb;
}
public String getStrIngredient1() {
return strIngredient1;
}
public void setStrIngredient1(String strIngredient1) {
this.strIngredient1 = strIngredient1;
}
public String getStrIngredient2() {
return strIngredient2;
}
public void setStrIngredient2(String strIngredient2) {
this.strIngredient2 = strIngredient2;
}
public String getStrIngredient3() {
return strIngredient3;
}
public void setStrIngredient3(String strIngredient3) {
this.strIngredient3 = strIngredient3;
}
public String getStrIngredient4() {
return strIngredient4;
}
public void setStrIngredient4(String strIngredient4) {
this.strIngredient4 = strIngredient4;
}
public String getStrIngredient5() {
return strIngredient5;
}
public void setStrIngredient5(String strIngredient5) {
this.strIngredient5 = strIngredient5;
}
public String getStrIngredient6() {
return strIngredient6;
}
public void setStrIngredient6(String strIngredient6) {
this.strIngredient6 = strIngredient6;
}
public String getStrIngredient7() {
return strIngredient7;
}
public void setStrIngredient7(String strIngredient7) {
this.strIngredient7 = strIngredient7;
}
public String getStrIngredient8() {
return strIngredient8;
}
public void setStrIngredient8(String strIngredient8) {
this.strIngredient8 = strIngredient8;
}
public String getStrIngredient9() {
return strIngredient9;
}
public void setStrIngredient9(String strIngredient9) {
this.strIngredient9 = strIngredient9;
}
public String getStrIngredient10() {
return strIngredient10;
}
public void setStrIngredient10(String strIngredient10) {
this.strIngredient10 = strIngredient10;
}
public String getStrIngredient11() {
return strIngredient11;
}
public void setStrIngredient11(String strIngredient11) {
this.strIngredient11 = strIngredient11;
}
public String getStrIngredient12() {
return strIngredient12;
}
public void setStrIngredient12(String strIngredient12) {
this.strIngredient12 = strIngredient12;
}
public String getStrIngredient13() {
return strIngredient13;
}
public void setStrIngredient13(String strIngredient13) {
this.strIngredient13 = strIngredient13;
}
public String getStrIngredient14() {
return strIngredient14;
}
public void setStrIngredient14(String strIngredient14) {
this.strIngredient14 = strIngredient14;
}
public String getStrIngredient15() {
return strIngredient15;
}
public void setStrIngredient15(String strIngredient15) {
this.strIngredient15 = strIngredient15;
}
public String getStrMeasure1() {
return strMeasure1;
}
public void setStrMeasure1(String strMeasure1) {
this.strMeasure1 = strMeasure1;
}
public String getStrMeasure2() {
return strMeasure2;
}
public void setStrMeasure2(String strMeasure2) {
this.strMeasure2 = strMeasure2;
}
public String getStrMeasure3() {
return strMeasure3;
}
public void setStrMeasure3(String strMeasure3) {
this.strMeasure3 = strMeasure3;
}
public String getStrMeasure4() {
return strMeasure4;
}
public void setStrMeasure4(String strMeasure4) {
this.strMeasure4 = strMeasure4;
}
public String getStrMeasure5() {
return strMeasure5;
}
public void setStrMeasure5(String strMeasure5) {
this.strMeasure5 = strMeasure5;
}
public String getStrMeasure6() {
return strMeasure6;
}
public void setStrMeasure6(String strMeasure6) {
this.strMeasure6 = strMeasure6;
}
public String getStrMeasure7() {
return strMeasure7;
}
public void setStrMeasure7(String strMeasure7) {
this.strMeasure7 = strMeasure7;
}
public String getStrMeasure8() {
return strMeasure8;
}
public void setStrMeasure8(String strMeasure8) {
this.strMeasure8 = strMeasure8;
}
public String getStrMeasure9() {
return strMeasure9;
}
public void setStrMeasure9(String strMeasure9) {
this.strMeasure9 = strMeasure9;
}
public String getStrMeasure10() {
return strMeasure10;
}
public void setStrMeasure10(String strMeasure10) {
this.strMeasure10 = strMeasure10;
}
public String getStrMeasure11() {
return strMeasure11;
}
public void setStrMeasure11(String strMeasure11) {
this.strMeasure11 = strMeasure11;
}
public String getStrMeasure12() {
return strMeasure12;
}
public void setStrMeasure12(String strMeasure12) {
this.strMeasure12 = strMeasure12;
}
public String getStrMeasure13() {
return strMeasure13;
}
public void setStrMeasure13(String strMeasure13) {
this.strMeasure13 = strMeasure13;
}
public String getStrMeasure14() {
return strMeasure14;
}
public void setStrMeasure14(String strMeasure14) {
this.strMeasure14 = strMeasure14;
}
public String getStrMeasure15() {
return strMeasure15;
}
public void setStrMeasure15(String strMeasure15) {
this.strMeasure15 = strMeasure15;
}
public String getDateModified() {
return dateModified;
}
public void setDateModified(String dateModified) {
this.dateModified = dateModified;
}
And my API call is as follows:
#Override
protected Cocktail doInBackground(Cocktail... cocktails) {
Call<Cocktails> call = mApiService.getCocktail(id);
try {
Response<Cocktails> response = call.execute();
this.cocktails = response.body();
this.cocktail = this.cocktails.getCocktail().get(0);
Log.i(TAG, "Success: " + response.body().toString());
} catch (IOException e) {
Log.e(TAG, "IOException: " + e);
e.printStackTrace();
} catch (IllegalStateException e) {
Log.e(TAG, "IllegalStateException: " + e);
e.printStackTrace();
}
return cocktail;
}
I know enough to realise that a large number of variables, ingredients and measures (many of which are empty) is the wrong approach but i'm struggling to find a solution with retrofit to create an array of these values. I've not found any way to assign multiple SerializedNames to a single array variable?
The option that jumps out at me is looping through the response pulling out the key values in onSuccess but this seems to go against the simplicity of using retrofit?
I'm using the JAXB Unmarshaller to convert an XML string into a Java object structure (using Java 7; Java 8 is not an option at this time). I'm having a problem with lists of objects though. (I apologize in advance for all the code included.) This is the input XML string:
<claimImportCompositeDTO>
<claimId>900</claimId>
<claimNumber>AT0000000000018</claimNumber>
<claimDTO>
<recordId>900</recordId>
<version>1</version>
<clmAddress>
<recordId>900</recordId>
<version>0</version>
</clmAddress>
<claimStatus>
<expired class="list">
<claimStatusDTO>
<recordId>900</recordId>
<version>1</version>
</claimStatusDTO>
<claimStatusDTO>
<recordId>910</recordId>
<version>2</version>
</claimStatusDTO>
</expired>
<statusCompleteWorkItemFlag>false</statusCompleteWorkItemFlag>
</claimStatus>
</claimDTO>
<notes class="list">
<notepadDTO>
<recordId>3503</recordId>
<version>0</version>
<notepadText class="list">
<notepadTextDTO>
<recordId>3503</recordId>
<version>0</version>
</notepadTextDTO>
<notepadTextDTO>
<recordId>3504</recordId>
<version>0</version>
</notepadTextDTO>
</notepadText>
</notepadDTO>
</notes>
</claimImportCompositeDTO>
This is the definition for the various objects:
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
#XmlRootElement
public class ClaimImportCompositeDTO {
private String _claimId;
private String _claimNumber;
private ClaimDTO _claimDTO;
private List<NotepadDTO> _notes;
public String getClaimId() {
return _claimId;
}
public String getClaimNumber() {
return _claimNumber;
}
public ClaimDTO getClaimDTO() {
return _claimDTO;
}
public List<NotepadDTO> getNotes() {
return _notes;
}
public void setClaimId(String claimId) {
this._claimId = claimId;
}
public void setClaimNumber(String claimNumber) {
this._claimNumber = claimNumber;
}
public void setClaimDTO(ClaimDTO claimDTO) {
this._claimDTO = claimDTO;
}
public void setNotes(List<NotepadDTO> notes) {
this._notes = notes;
}
}
public class ClaimDTO {
private String _recordId;
private String _version;
private ClmAddress _clmAddress;
private ClaimStatus _claimStatus;
public String getRecordId() {
return _recordId;
}
public String getVersion() {
return _version;
}
public ClmAddress getClmAddress() {
return _clmAddress;
}
public ClaimStatus getClaimStatus() {
return _claimStatus;
}
public void setRecordId(String recordId) {
this._recordId = recordId;
}
public void setVersion(String version) {
this._version = version;
}
public void setClmAddress(ClmAddress clmAddress) {
this._clmAddress = clmAddress;
}
public void setClaimStatus(ClaimStatus claimStatus) {
this._claimStatus = claimStatus;
}
}
public class ClmAddress {
private String _recordId;
private String _version;
public String getRecordId() {
return _recordId;
}
public String getVersion() {
return _version;
}
public void setRecordId(String recordId) {
this._recordId = recordId;
}
public void setVersion(String version) {
this._version = version;
}
}
import java.util.List;
public class ClaimStatus {
private List<ClaimStatusDTO> _expired;
private boolean _statusCompleteWorkItemFlag;
public List<ClaimStatusDTO> getExpired() {
return _expired;
}
public boolean isStatusCompleteWorkItemFlag() {
return _statusCompleteWorkItemFlag;
}
public void setExpired(List<ClaimStatusDTO> expired) {
this._expired = expired;
}
public void setStatusCompleteWorkItemFlag(boolean statusCompleteWorkItemFlag) {
this._statusCompleteWorkItemFlag = statusCompleteWorkItemFlag;
}
}
public class ClaimStatusDTO {
private String _recordId;
private String _version;
public String getRecordId() {
return _recordId;
}
public String getVersion() {
return _version;
}
public void setRecordId(String recordId) {
this._recordId = recordId;
}
public void setVersion(String version) {
this._version = version;
}
}
import java.util.List;
public class NotepadDTO {
private String _recordId;
private String _version;
private List<NotepadTextDTO> _notepadText;
public List<NotepadTextDTO> getNotepadText() {
return _notepadText;
}
public String getRecordId() {
return _recordId;
}
public String getVersion() {
return _version;
}
public void setNotepadText(List<NotepadTextDTO> notepadText) {
this._notepadText = notepadText;
}
public void setRecordId(String recordId) {
this._recordId = recordId;
}
public void setVersion(String version) {
this._version = version;
}
}
public class NotepadTextDTO {
private String _recordId;
private String _version;
public String getRecordId() {
return _recordId;
}
public String getVersion() {
return _version;
}
public void setRecordId(String recordId) {
this._recordId = recordId;
}
public void setVersion(String version) {
this._version = version;
}
}
This is the output:
<claimImportCompositeDTO>
<claimId>900</claimId>
<claimNumber>AT0000000000018</claimNumber>
<claimDTO>
<recordId>900</recordId>
<version>1</version>
<clmAddress>
<recordId>900</recordId>
<version>0</version>
</clmAddress>
<claimStatus>
<expired class="list">
<claimStatusDTO>
<recordId>null</recordId>
<version>null</version>
</claimStatusDTO>
</expired>
<statusCompleteWorkItemFlag>false</statusCompleteWorkItemFlag>
</claimStatus>
</claimDTO>
<notes class="list">
<notepadDTO>
<recordId>null</recordId>
<version>null</version>
<notepadText class="list"/>
</notepadDTO>
</notes>
</claimImportCompositeDTO>
When I run the unmarshaller, the non-list data is read correctly, but anything in a list is skipped. Well, one object is created (regardless of how many are in the list) and all of the fields are null (i.e., the claimsStatus -> expired list or the notes list).
I'm hoping I'm missing something fairly basic, but I've been unable to find what that may be. Any ideas?
The problem is that the xml provided does not correspond to the structure of the your POJOs. An easy way to fix it, following your existing setup and coding style is to add #XmlElementWrapper on the fields that are lists of items and change their names. You need to change the 3 following classes to how they look below and it will work:
#XmlRootElement
#XmlAccessorType(XmlAccessType.PROPERTY)
public class ClaimImportCompositeDTO {
private String _claimId;
private String _claimNumber;
private ClaimDTO _claimDTO;
private List<NotepadDTO> _notepadDTO;
public String getClaimId() {
return _claimId;
}
public String getClaimNumber() {
return _claimNumber;
}
public ClaimDTO getClaimDTO() {
return _claimDTO;
}
#XmlElementWrapper(name = "notes")
public List<NotepadDTO> getNotepadDTO() {
return _notepadDTO;
}
public void setClaimId(String claimId) {
this._claimId = claimId;
}
public void setClaimNumber(String claimNumber) {
this._claimNumber = claimNumber;
}
public void setClaimDTO(ClaimDTO claimDTO) {
this._claimDTO = claimDTO;
}
public void setNotepadDTO(List<NotepadDTO> notes) {
this._notepadDTO = notes;
}
}
ClaimStatus class would be:
#XmlAccessorType(XmlAccessType.PROPERTY)
public class ClaimStatus {
private List<ClaimStatusDTO> _claimStatusDTO;
private boolean _statusCompleteWorkItemFlag;
#XmlElementWrapper(name = "expired")
public List<ClaimStatusDTO> getClaimStatusDTO() {
return _claimStatusDTO;
}
public void setClaimStatusDTO(List<ClaimStatusDTO> claimStatusDto) {
this._claimStatusDTO = claimStatusDto;
}
public boolean isStatusCompleteWorkItemFlag() {
return _statusCompleteWorkItemFlag;
}
public void setStatusCompleteWorkItemFlag(boolean statusCompleteWorkItemFlag) {
this._statusCompleteWorkItemFlag = statusCompleteWorkItemFlag;
}
}
And NotepadDTO:
#XmlAccessorType(XmlAccessType.PROPERTY)
public class NotepadDTO {
private String _recordId;
private String _version;
private List<NotepadTextDTO> _notepadTextDTO;
#XmlElementWrapper(name = "notepadText")
public List<NotepadTextDTO> getNotepadTextDTO() {
return _notepadTextDTO;
}
public String getRecordId() {
return _recordId;
}
public String getVersion() {
return _version;
}
public void setNotepadTextDTO(List<NotepadTextDTO> notepadText) {
this._notepadTextDTO = notepadText;
}
public void setRecordId(String recordId) {
this._recordId = recordId;
}
public void setVersion(String version) {
this._version = version;
}
}
You need the #XmlElement annotation on the list. Something like this.
#XmlElement(name = "notepadDTO")
private List<NotepadDTO> _notes;
Here's a tutorial I used:
https://howtodoinjava.com/jaxb/jaxb-exmaple-marshalling-and-unmarshalling-list-or-set-of-objects/
I'm working with Mybatis to batch insert data,specifically my parameterType is a class,which has a List property,so I use foreach to do the traversal.But it didn't work,here are the debug and codes.Thanks.
DEBUG
here is the sql:
<insert id="batchInsertSn" parameterType="domain.collectSn.IbSnTransit">
insert into
ib_sn_transit (
sn, inbound_no, container_no,
goods_no,goods_name, owner_no,
owner_name,create_user,update_user,
create_time,update_time,yn,
org_no,org_name,distribute_no,
warehouse_no,receiving_no,supplier_no
,out_wave_no)
values
<foreach collection="snList" item="item" index="index" separator="," >
(
#{item.sn,jdbcType=VARCHAR}, #{inboundNo,jdbcType=VARCHAR}, #{containerNo,jdbcType=VARCHAR},
#{goodsNo,jdbcType=VARCHAR},#{goodsName,jdbcType=VARCHAR},#{ownerNo,jdbcType=VARCHAR},
#{ownerName,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{updateUser,jdbcType=VARCHAR},
now(),now(),#{yn,jdbcType=TINYINT},
#{orgNo,jdbcType=VARCHAR},#{orgName,jdbcType=VARCHAR},#{distributeNo,jdbcType=VARCHAR},
#{warehouseNo,jdbcType=VARCHAR},#{receivingNo,jdbcType=VARCHAR},#{supplierNo,jdbcType=VARCHAR}
,#{outWaveNo,jdbcType=VARCHAR}
)
</foreach>
</insert>
here is the class
public class IbSnTransit {
private String outWaveNo;
private String queryUser;
private String finishFlag;
private Integer id;
private String inboundNo;
private String sn;
private String snStart;
private String snEnd;
private String containerNo;
private String goodsNo;
private String goodsName;
private String ownerNo;
private String ownerName;
private String createUser;
private Date createTime;
private String updateUser;
private Date updateTime;
private Integer yn;
private String orgNo;
private String orgName;
private String distributeNo;
private String warehouseNo;
private String receivingNo;
private String supplierNo;
private List<String> snList;
public String getSupplierNo() {
return supplierNo;
}
public void setSupplierNo(String supplierNo) {
this.supplierNo = supplierNo;
}
public Integer getId() {
return id;
}
public void setId(Integer id){
this.id = id;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public String getOrgName() {
return orgName;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public String getSn() {
return sn;
}
public void setSn(String sn){
this.sn = sn;
}
public String getInboundNo() {
return inboundNo;
}
public void setInboundNo(String inboundNo) {
this.inboundNo = inboundNo;
}
public String getGoodsNo() {
return goodsNo;
}
public void setGoodsNo(String goodsNo) {
this.goodsNo = goodsNo;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public String getContainerNo() {
return containerNo;
}
public void setContainerNo(String containerNo) {
this.containerNo = containerNo;
}
public String getOwnerNo() {
return ownerNo;
}
public void setOwnerNo(String ownerNo) {
this.ownerNo = ownerNo;
}
public String getCreateUser() {
return createUser;
}
public void setCreateUser(String createUser) {
this.createUser = createUser;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateUser() {
return updateUser;
}
public void setUpdateUser(String updateUser) {
this.updateUser = updateUser;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getYn() {
return yn;
}
public void setYn(Integer yn) {
this.yn = yn;
}
public String getDistributeNo() {
return distributeNo;
}
public void setDistributeNo(String distributeNo) {
this.distributeNo = distributeNo;
}
public String getOrgNo() {
return orgNo;
}
public void setOrgNo(String orgNo) {
this.orgNo = orgNo;
}
public String getWarehouseNo() {
return warehouseNo;
}
public void setWarehouseNo(String warehouseNo) {
this.warehouseNo = warehouseNo;
}
public String getSnStart() {
return snStart;
}
public void setSnStart(String snStart) {
this.snStart = snStart;
}
public String getSnEnd() {
return snEnd;
}
public void setSnEnd(String snEnd) {
this.snEnd = snEnd;
}
public String getReceivingNo() {
return receivingNo;
}
public void setReceivingNo(String receivingNo) {
this.receivingNo = receivingNo;
}
public String getFinishFlag() {
return finishFlag;
}
public void setFinishFlag(String finishFlag) {
this.finishFlag = finishFlag;
}
public String getQueryUser() {
return queryUser;
}
public void setQueryUser(String queryUser) {
this.queryUser = queryUser;
}
public String getOutWaveNo() {
return outWaveNo;
}
public void setOutWaveNo(String outWaveNo) {
this.outWaveNo = outWaveNo;
}
public List<String> getSnList() {
return snList;
}
public void setSnList(List<String> snList) {
this.snList = snList;
}
}
the result
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '' in 'class java.lang.String'
IbSnTransit.snList is declared as List of String.class objects so, when you use #{item.sn,jdbcType=VARCHAR} in your mapper you are asked for a property sn in the String.class. Maybe you must use #{item,jdbcType=VARCHAR} instead.