JAXB - Nested custom objects marshaling and unmarshaling - java

I'm attempting to parse a generated .xml report from ReadyAPI through unmarshalling but am having trouble building out the classes. My example is much more complex then most of the research I have done online so it is hard for me to compare them. Could anyone help me build the object structure for something like this?
Example.xml
<testSuiteResults>
<testSuite>
<startTime>00:00:00</startTime>
<status>PASS</status>
<testSuiteName>Example Test Suite Name</testSuiteName>
<timeTaken>246</timeTaken>
<testRunnerResults>
<testCase>
<startTime>00:00:00</startTime>
<status>PASS</status>
<testCaseId>111aaa111aaa111aaa111</testCaseId>
<testCaseName>Example TestCase Name</testCaseName>
<timeTaken>123</timeTaken>
<testStepResults>
<result>
<message>Example Message</message>
<name>Example Result Name</name>
<order>1</order>
<started>00:00:00</started>
<status>PASS</status>
<timeTaken>123</timeTaken>
</result>
</testStepResults>
<testStepParameters>
<parameters>
<iconPath>/icon_path.png</iconPath>
<testStepName>Example Test</testStepName>
</parameters>
</testStepParameters>
</failedTestSteps>
</testCase>
<testCase>
<reason>Example Fail Reason</reason>
<startTime>00:00:00</startTime>
<status>FAIL</status>
<testCaseId>123abc123abc123abc123</testCaseId>
<testCaseName>Example Test Case Name 2</testCaseName>
<timeTaken>123</timeTaken>
<testStepResults>
<result>
<message>Example Message 2</message>
<name>Example Test Step Name 2</name>
<order>1</order>
<started>00:00:00</started>
<status>FAIL</status>
<timeTaken>123</timeTaken>
</result>
</testStepResults>
<testStepParameters>
<parameters>
<iconPath>/icon_path_2.png</iconPath>
<testStepName>Example Test Step Name 2</testStepName>
</parameters>
</testStepParameters>
<failedTestSteps>
<error>
<detail>Example Detail</detail>
<icon>icon.png</icon>
<testCaseName>Example Test Case Name 2</testCaseName>
<testStepName>Example Test Step Name 2</testStepName>
<testSuiteName>Example Test Suite Name</testSuiteName>
</error>
</failedTestSteps>
</testCase>
</testRunnerResults>
</testSuite>
</testSuiteResults>
After many iterations I have landed on this structure:
#XmlRootElement(name = "testSuiteResults")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestSuiteResults {
#XmlElement(name = "testSuite")
private List<TestSuite> testSuites;
public void setTestSuites(List<TestSuite> testSuites) {
this.testSuites = testSuites;
}
public List<TestSuite> getTestSuites() {
return this.testSuites;
}
public boolean hasTestSuites() {
return this.testSuites != null && this.testSuites.size() > 0;
}
}
#XmlRootElement(name = "testSuite")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestSuite {
#XmlElement(name = "startTime")
private String startTime;
#XmlElement(name = "status")
private String status;
#XmlElement(name = "testSuiteName")
private String testSuiteName;
#XmlElement(name = "timeTaken")
private String timeTaken;
#XmlElementWrapper(name = "testRunnerResults")
#XmlElement(name = "testCase", type = TestCase.class)
private List<TestCase> testRunnerResults;
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public void setStatus(String status) {
this.status = status;
}
public void setTestSuiteName(String testSuiteName) {
this.testSuiteName = testSuiteName;
}
public void setTimeTaken(String timeTaken) {
this.timeTaken = timeTaken;
}
public void setTestRunnerResults(List<TestCase> testRunnerResults) {
this.testRunnerResults = testRunnerResults;
}
public String getTestSuitename() {
return this.testSuiteName;
}
public List<TestCase> getTestCases() {
return this.testRunnerResults;
}
public boolean hasTestCases() {
return this.testRunnerResults != null;
}
}
#XmlRootElement(name = "testCase")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestCase {
#XmlElement(name = "reason")
private String reason;
#XmlElement(name = "startTime")
private String startTime;
#XmlElement(name = "status")
private String status;
#XmlElement(name = "testCaseId")
private String testCaseId;
#XmlElement(name = "testCaseName")
private String testCaseName;
#XmlElement(name = "timeTaken")
private String timeTaken;
#XmlElementWrapper(name = "testStepResults")
#XmlElement(name = "result")
private List<TestStepResult> testStepResults;
#XmlElementWrapper(name = "testStepParameters")
#XmlElement(name = "parameters")
private List<TestStepParameter> testStepParameters;
#XmlElementWrapper(name = "failedTestSteps")
#XmlElement(name = "error")
private List<TestStepError> failedTestSteps;
public void setReason(String reason) {
this.reason = reason;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public void setStatus(String status) {
this.status = status;
}
public void setTestCaseId(String testCaseId) {
this.testCaseId = testCaseId;
}
public void setTestCaseName(String testCaseName) {
this.testCaseName = testCaseName;
}
public void setTimeTaken(String timeTaken) {
this.timeTaken = timeTaken;
}
public void setTestStepResults(List<TestStepResult> testStepResults) {
this.testStepResults = testStepResults;
}
public void setTestStepParameters(List<TestStepParameter> testStepParameters) {
this.testStepParameters = testStepParameters;
}
public void setFailedTestSteps(List<TestStepError> failedTestSteps) {
this.failedTestSteps = failedTestSteps;
}
public String getReason() {
return this.reason;
}
public String getStartTime() {
return this.startTime;
}
public String getStatus() {
return this.status;
}
public String getTestCaseId() {
return this.testCaseId;
}
public String getTestCaseName() {
return this.testCaseName;
}
public String getTimeTaken() {
return this.timeTaken;
}
public List<TestStepResult> getTestStepResults() {
return this.testStepResults;
}
public List<TestStepParameter> getTestStepParameters() {
return this.testStepParameters;
}
public List<TestStepError> getFailedTestSteps() {
return this.failedTestSteps;
}
}
#XmlRootElement(name = "result")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestStepResult {
#XmlElement(name = "message")
private String message;
#XmlElement(name = "name")
private String testStepName;
#XmlElement(name = "order")
private int order;
#XmlElement(name = "started")
private String started;
#XmlElement(name = "status")
private String status;
#XmlElement(name = "timeTaken")
private String timeTaken;
public void setMessage(String message) {
this.message = message;
}
public void setTestStepName(String testStepName) {
this.testStepName = testStepName;
}
public void setOrder(int order) {
this.order = order;
}
public void setStarted(String started) {
this.started = started;
}
public void setStatus(String status) {
this.status = status;
}
public void setTimeTaken(String timeTaken) {
this.timeTaken = timeTaken;
}
public String getTestStepName() {
return this.testStepName;
}
}
#XmlRootElement(name = "paramters")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestStepParameter {
#XmlElement(name = "iconPath")
private String iconPath;
#XmlElement(name = "testStepName")
private String testStepName;
public void setIconPath(String iconPath) {
this.iconPath = iconPath;
}
public void setTestStepName(String testStepName) {
this.testStepName = testStepName;
}
public String getTestStepName() {
return this.testStepName;
}
}
#XmlRootElement(name = "error")
#XmlAccessorType(XmlAccessType.FIELD)
public class TestStepError {
#XmlElement(name = "detail")
private String detail;
#XmlElement(name = "icon")
private String icon;
#XmlElement(name = "testCaseName")
private String testCaseName;
#XmlElement(name = "testStepName")
private String testStepName;
#XmlElement(name = "testSuiteName")
private String testSuiteName;
public void setDetail(String detail) {
this.detail = detail;
}
public void setIcon(String icon) {
this.icon = icon;
}
public void setTestCaseName(String testCaseName) {
this.testCaseName = testCaseName;
}
public void setTestStepName(String testStepName) {
this.testStepName = testStepName;
}
public void setTestSuiteName(String testSuiteName) {
this.testSuiteName = testSuiteName;
}
}
The Example.xml is how the report is generated, I have begun attempting to marshal it myself using sample data to confirm I am building this correctly. I've been able to get this response:
<testSuiteResults>
<testSuite>
<startTime>00:00:00</startTime>
<status>PASS</status>
<testSuiteName>TestSuiteName</testSuiteName>
<timeTaken>123</timeTaken>
<testRunnerResults/>
</testSuite>
</testSuiteResults>
It always stops on populating testRunnerResults, so I've attempted to look into XmlAdapters but I have had a lot of trouble understanding how to work it into this structure.

Related

JAXB IllegalAnnotationsException

This statement throws IllegalAnnotationException. I would like to know why. I'm having a hard time finding the issue myself because I'm unfamiliar with JAXB and there is no information in the error thrown apart from the name.
JAXBContext context = JAXBContext.newInstance(Article.class);
Here's the Article class:
#XmlRootElement(name = "article")
#XmlAccessorType(XmlAccessType.FIELD)
public class Article {
#XmlElement(name = "meta")
private Metadata metadata;
#XmlElement
private Body body;
#XmlElement(name = "tags")
private Tags tags;
public Metadata getMetadata() {
return metadata;
}
public Body getBody() {
return body;
}
public Tags getTags() {
return tags;
}
public void setTags(Tags tags) {
this.tags = tags;
}
public List<Paragraph> getParagraphs() {
return body.getParagraphs();
}
}
The Tag class:
#XmlAccessorType(XmlAccessType.FIELD)
public class Tags {
#XmlElement(name = "headword")
private List<Headword> headword;
#XmlElement(name = "formParenthesis")
private List<FormParenthesis> formParenthesis;
#XmlElement(name = "etymology")
private List<Etymology> etymology;
#XmlElement(name = "overview")
private List<Overview> overview;
#XmlElement(name = "connections")
private List<Connections> connections;
#XmlElement(name = "compounds")
private List<Compounds> compounds;
#XmlElement(name = "derivations")
private List<Derivations> derivations;
#XmlElement(name = "reference")
private List<Reference> reference;
#XmlElementWrapper(name = "sources")
#XmlElement(name = "source")
private List<Source> sources;
#XmlElementWrapper(name = "definitions")
#XmlElement(name = "definition")
private List<Definition> definitions;
#XmlElementWrapper(name = "professions")
#XmlElement(name = "profession")
private List<Profession> professions;
#XmlElementWrapper(name = "usabilities")
#XmlElement(name = "usability")
private List<Usability> usabilities;
#XmlElementWrapper(name = "remarks")
#XmlElement(name = "remark")
private List<Commentary> commentaries;
#XmlElementWrapper(name = "languageTests")
#XmlElement(name = "languageTest")
private List<LanguageTest> languageTests;
public List<Headword> getHeadword() {
return headword;
}
public List<FormParenthesis> getFormParenthesis() {
return formParenthesis;
}
public List<Etymology> getEtymology() {
return etymology;
}
public List<Overview> getOverview() {
return overview;
}
public List<Connections> getConnections() {
return connections;
}
public List<Compounds> getCompounds() {
return compounds;
}
public List<Derivations> getDerivations() {
return derivations;
}
public List<Reference> getReference() {
return reference;
}
public List<Source> getSources() {
return sources;
}
public void setSources(List<Source> sources) {
this.sources = sources;
}
public boolean hasSources() {
return sources != null;
}
public List<Definition> getDefinitions() {
return definitions;
}
public List<Definition> setDefinitions(List<Definition> definitions) {
this.definitions = definitions;
return this.definitions;
}
public boolean hasDefinitions() {
return definitions != null;
}
public List<Profession> getProfessions() {
return professions;
}
public List<Profession> setProfessions(List<Profession> professions) {
this.professions = professions;
return this.professions;
}
public boolean hasProfessions() {
return professions != null;
}
public List<Usability> getUsabilities() {
return usabilities;
}
public List<Usability> setUsabilities(List<Usability> usabilities) {
this.usabilities = usabilities;
return this.usabilities;
}
public boolean hasUsabilities() {
return usabilities != null;
}
public List<Commentary> getCommentaries() {
return commentaries;
}
public List<Commentary> setCommentaries(List<Commentary> commentaries) {
this.commentaries = commentaries;
return this.commentaries;
}
public boolean hasCommentaries() {
return commentaries != null;
}
public List<LanguageTest> getLanguageTests() {
return languageTests;
}
public List<LanguageTest> setLanguageTests(List<LanguageTest> languageTests) {
this.languageTests = languageTests;
return this.languageTests;
}
public boolean hasLanguageTests() {
return languageTests != null;
}
}
What is Illegal about these annotations?
Please let me know if there is some other part of the code you would like to see.
UPDATE:
I've identified three tags that cause the error. I ran with just one of them not commented out:
Tags.java:
#XmlElement(name = "derivations")
private List<Derivations> derivations;
and here is the stack trace:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:445)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:124)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1123)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.mycom.ap.processing.io.utils.ArticleSerializationHelper.fromFile(ArticleSerializationHelper.java:33)
at com.mycom.ap.processing.ArticleProcessingWrapper.run(ArticleProcessingWrapper.java:34)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Derivations.java:
public class Derivations extends PositionalIds {
#XmlElement(name = "derivation")
List<Derivation> derivations;
public List<Derivation> getDerivations() {
return derivations;
}
}
PositionalIds.java
#XmlTransient
public abstract class PositionalIds {
#XmlAttribute(name = "start")
private String startId;
#XmlAttribute(name = "end")
private String endId;
public String getStartId() {
return startId;
}
public String getEndId() {
return endId;
}
}
UDPATE:
Changing Derivations.java to:
#XmlAccessorType(XmlAccessType.FIELD)
public class Derivations extends PositionalIds {
#XmlElement(name = "derivation")
List<Derivation> derivations;
public List<Derivation> getDerivations() {
return derivations;
}
}
does not solve the problem. The same error remains.
Make sure also your Derivations (and other possible similar classes) has:
#XmlAccessorType(XmlAccessType.FIELD)
Otherwise you will show JAXB same field two times because you also have getter.

Hibernate ResultTransformer returning map with all null values

I am trying to prepate a list of maps, where each map represents a row of table data having keys as column names and values are column values i.e., Map. I could able to prepare the list of maps, but except Id column all other column values are returning as null. could you please help on this. Whats wrong with my code. There are no NullPointer exception for sessionfactory access with below code
Criteria crt = session.createCriteria(SampleCsv.class)
.add( Restrictions.between("Id", 3, 6) )
.setResultTransformer(new BasicTransformerAdapter() {
#SuppressWarnings("deprecation")
#Override
public Object transformTuple(Object[] tuple, String[] aliases) {
PassThroughResultTransformer rt = PassThroughResultTransformer.INSTANCE;
final Object o = rt.transformTuple(tuple, aliases);
ClassMetadata cm = getSessionFactory().getClassMetadata(o.getClass());
List<String> pns = new ArrayList<String>(Arrays.asList(cm.getPropertyNames()));
Map<String, Object> m = new HashMap<String, Object>();
for(String pn : pns) {
m.put(pn, cm.getPropertyValue(o, pn));
}
m.put(cm.getIdentifierPropertyName(), cm.getIdentifier(o));
return m;
}
});
List<Map<String,Object>> aliasToValueMap = (List<Map<String, Object>>)crt.list();
and my pojo class is
#Entity
#Table(name="SAMPLE_CSV")
public class SampleCsv {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name="ID", nullable = false)
private int Id;
#Column(name = "Type", nullable = true)
private String Type;
#Column(name = "NomMedia")
private String NomMedia;
#Column(name = "sRep")
private String sRep;
#Column(name = "UrlMedia")
private String UrlMedia;
#Column(name = "Indice")
private String Indice;
#Column(name = "CodeFourSAP")
private String CodeFourSAP;
#Column(name = "NomDepositaire")
private String NomDepositaire;
#Column(name = "PrenomDepositaire")
private String PrenomDepositaire;
#Column(name = "EMailDepositaire")
private String EMailDepositaire;
#Column(name = "DateDepot")
private String DateDepot;
#Column(name = "PhotoPrincipale")
private String PhotoPrincipale;
#Column(name = "NomPhotographe")
private String NomPhotographe;
#Column(name = "PrenomPhotographe")
private String PrenomPhotographe;
#Column(name = "SocieteProprietaireDesDroits")
private String SocieteProprietaireDesDroits;
#Column(name = "DateCreationOuModificationMediaH")
private String DateCreationOuModificationMediaH;
#Column(name = "Commentaire")
private String Commentaire;
#Column(name = "WEB_Valide")
private String WEB_Valide;
#Column(name = "WEB_DateValidation")
private String WEB_DateValidation;
#Column(name = "WEB_ValidePar")
private String WEB_ValidePar;
#Column(name = "WEB_Classement")
private String WEB_Classement;
#Column(name = "CreditPhoto")
private String CreditPhoto;
#Column(name = "WEB_Commentaire")
private String WEB_Commentaire;
#Column(name = "NB_IMAGES")
private String NB_IMAGES;
#Column(name = "Watermark")
private String Watermark;
#Column(name = "Zoom")
private String Zoom;
#Column(name = "Traite")
private String Traite;
#Column(name = "TailleX")
private String TailleX;
#Column(name = "TailleY")
private String TailleY;
#Column(name = "MediaH_CodeArtSAP")
private String MediaH_CodeArtSAP;
#Column(name = "RefLoueur")
private String RefLoueur;
#Column(name = "Extension")
private String Extension;
#Column(name = "MediaP_CodeArtSAP")
private String MediaP_CodeArtSAP;
#Column(name = "DateDebutDroit")
private String DateDebutDroit;
#Column(name = "DateFinDroit")
private String DateFinDroit;
#Column(name = "DateCreationOuModificationCopyright")
private String DateCreationOuModificationCopyright;
public int getId() {
return Id;
}
public void setId(int id) {
this.Id = id;
}
public String getType() {
return Type;
}
public void setType(String type) {
Type = type;
}
public String getNomMedia() {
return NomMedia;
}
public void setNomMedia(String nomMedia) {
NomMedia = nomMedia;
}
public String getsRep() {
return sRep;
}
public void setsRep(String sRep) {
this.sRep = sRep;
}
public String getUrlMedia() {
return UrlMedia;
}
public void setUrlMedia(String urlMedia) {
UrlMedia = urlMedia;
}
public String getIndice() {
return Indice;
}
public void setIndice(String indice) {
Indice = indice;
}
public String getCodeFourSAP() {
return CodeFourSAP;
}
public void setCodeFourSAP(String codeFourSAP) {
CodeFourSAP = codeFourSAP;
}
public String getNomDepositaire() {
return NomDepositaire;
}
public void setNomDepositaire(String nomDepositaire) {
NomDepositaire = nomDepositaire;
}
public String getPrenomDepositaire() {
return PrenomDepositaire;
}
public void setPrenomDepositaire(String prenomDepositaire) {
PrenomDepositaire = prenomDepositaire;
}
public String getEMailDepositaire() {
return EMailDepositaire;
}
public void setEMailDepositaire(String eMailDepositaire) {
EMailDepositaire = eMailDepositaire;
}
public String getDateDepot() {
return DateDepot;
}
public void setDateDepot(String dateDepot) {
DateDepot = dateDepot;
}
public String getPhotoPrincipale() {
return PhotoPrincipale;
}
public void setPhotoPrincipale(String photoPrincipale) {
PhotoPrincipale = photoPrincipale;
}
public String getNomPhotographe() {
return NomPhotographe;
}
public void setNomPhotographe(String nomPhotographe) {
NomPhotographe = nomPhotographe;
}
public String getPrenomPhotographe() {
return PrenomPhotographe;
}
public void setPrenomPhotographe(String prenomPhotographe) {
PrenomPhotographe = prenomPhotographe;
}
public String getSocieteProprietaireDesDroits() {
return SocieteProprietaireDesDroits;
}
public void setSocieteProprietaireDesDroits(String societeProprietaireDesDroits) {
SocieteProprietaireDesDroits = societeProprietaireDesDroits;
}
public String getDateCreationOuModificationMediaH() {
return DateCreationOuModificationMediaH;
}
public void setDateCreationOuModificationMediaH(
String dateCreationOuModificationMediaH) {
DateCreationOuModificationMediaH = dateCreationOuModificationMediaH;
}
public String getCommentaire() {
return Commentaire;
}
public void setCommentaire(String commentaire) {
Commentaire = commentaire;
}
public String getWEB_Valide() {
return WEB_Valide;
}
public void setWEB_Valide(String wEB_Valide) {
WEB_Valide = wEB_Valide;
}
public String getWEB_DateValidation() {
return WEB_DateValidation;
}
public void setWEB_DateValidation(String wEB_DateValidation) {
WEB_DateValidation = wEB_DateValidation;
}
public String getWEB_ValidePar() {
return WEB_ValidePar;
}
public void setWEB_ValidePar(String wEB_ValidePar) {
WEB_ValidePar = wEB_ValidePar;
}
public String getWEB_Classement() {
return WEB_Classement;
}
public void setWEB_Classement(String wEB_Classement) {
WEB_Classement = wEB_Classement;
}
public String getCreditPhoto() {
return CreditPhoto;
}
public void setCreditPhoto(String creditPhoto) {
CreditPhoto = creditPhoto;
}
public String getWEB_Commentaire() {
return WEB_Commentaire;
}
public void setWEB_Commentaire(String wEB_Commentaire) {
WEB_Commentaire = wEB_Commentaire;
}
public String getNB_IMAGES() {
return NB_IMAGES;
}
public void setNB_IMAGES(String nB_IMAGES) {
NB_IMAGES = nB_IMAGES;
}
public String getWatermark() {
return Watermark;
}
public void setWatermark(String watermark) {
Watermark = watermark;
}
public String getZoom() {
return Zoom;
}
public void setZoom(String zoom) {
Zoom = zoom;
}
public String getTraite() {
return Traite;
}
public void setTraite(String traite) {
Traite = traite;
}
public String getTailleX() {
return TailleX;
}
public void setTailleX(String tailleX) {
TailleX = tailleX;
}
public String getTailleY() {
return TailleY;
}
public void setTailleY(String tailleY) {
TailleY = tailleY;
}
public String getMediaH_CodeArtSAP() {
return MediaH_CodeArtSAP;
}
public void setMediaH_CodeArtSAP(String mediaH_CodeArtSAP) {
MediaH_CodeArtSAP = mediaH_CodeArtSAP;
}
public String getRefLoueur() {
return RefLoueur;
}
public void setRefLoueur(String refLoueur) {
RefLoueur = refLoueur;
}
public String getExtension() {
return Extension;
}
public void setExtension(String extension) {
Extension = extension;
}
public String getMediaP_CodeArtSAP() {
return MediaP_CodeArtSAP;
}
public void setMediaP_CodeArtSAP(String mediaP_CodeArtSAP) {
MediaP_CodeArtSAP = mediaP_CodeArtSAP;
}
public String getDateDebutDroit() {
return DateDebutDroit;
}
public void setDateDebutDroit(String dateDebutDroit) {
DateDebutDroit = dateDebutDroit;
}
public String getDateFinDroit() {
return DateFinDroit;
}
public void setDateFinDroit(String dateFinDroit) {
DateFinDroit = dateFinDroit;
}
public String getDateCreationOuModificationCopyright() {
return DateCreationOuModificationCopyright;
}
public void setDateCreationOuModificationCopyright(
String dateCreationOuModificationCopyright) {
DateCreationOuModificationCopyright = dateCreationOuModificationCopyright;
}
}
I am posting the out put of final list with two maps as below
[{Id=3,PrenomDepositaire=null, RefLoueur=null, DateCreationOuModificationCopyright=null, EMailDepositaire=null, SocieteProprietaireDesDroits=null, NomMedia=null, TailleX=null, CodeFourSAP=null, PrenomPhotographe=null, Commentaire=null, MediaP_CodeArtSAP=null, NomDepositaire=null, WEB_Commentaire=null, UrlMedia=null, Zoom=null, TailleY=null, WEB_Valide=null, DateDepot=null, sRep=null, WEB_ValidePar=null, Indice=null, CreditPhoto=null, DateCreationOuModificationMediaH=null, MediaH_CodeArtSAP=null, DateDebutDroit=null, WEB_Classement=null, DateFinDroit=null, NB_IMAGES=null, NomPhotographe=null, PhotoPrincipale=null, Extension=null, Type=null, WEB_DateValidation=null, Traite=null, Watermark=null},
{ Id=4,PrenomDepositaire=null, RefLoueur=null, DateCreationOuModificationCopyright=null, EMailDepositaire=null, SocieteProprietaireDesDroits=null, NomMedia=null, TailleX=null, CodeFourSAP=null, PrenomPhotographe=null, Commentaire=null, MediaP_CodeArtSAP=null, NomDepositaire=null, WEB_Commentaire=null, UrlMedia=null, Zoom=null, TailleY=null, WEB_Valide=null, DateDepot=null, sRep=null, WEB_ValidePar=null, Indice=null, CreditPhoto=null, DateCreationOuModificationMediaH=null, MediaH_CodeArtSAP=null, DateDebutDroit=null, WEB_Classement=null, DateFinDroit=null, NB_IMAGES=null, NomPhotographe=null, PhotoPrincipale=null, Extension=null, Type=null, WEB_DateValidation=null, Traite=null, Watermark=null}
]
But table data having non null data as well..

SAXParser parse complex object

I am a novice in SAXParser. I don't know is it possible to parse complex object with SAXParser. I have a class which contain Item list. And my response xml is like that :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetPaymentServiceInfoResponse xmlns="http://quetzalcoatlus/EpulPaymentService"><GetPaymentServiceInfoResult><ResultCodes>OK</ResultCodes><Description>User is temporary blocked</Description><Items><Item><Amount>122</Amount></Item><Item><Amount>23232</Amount></Item></Items></GetPaymentServiceInfoResult></GetPaymentServiceInfoResponse></s:Body></s:Envelope>
And my POJO class is like following:
#XmlRootElement(name = "PGResponse")
public class CheckAbonSuccessResponseModel {
private String message;
private String message_code;
private BigDecimal amount;
private String invoiceCode;
private String operationCode;
private List<Item> items;
#XmlElement(name = "message")
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
#XmlElement(name = "message_code")
public String getMessage_code() {
return message_code;
}
public void setMessage_code(String message_code) {
this.message_code = message_code;
}
#XmlElement(name = "amount")
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
#XmlElement(name = "invoice_code")
public String getInvoiceCode() {
return invoiceCode;
}
public void setInvoiceCode(String invoiceCode) {
this.invoiceCode = invoiceCode;
}
#XmlElement(name = "operation_code")
public String getOperationCode() {
return operationCode;
}
public void setOperationCode(String operationCode) {
this.operationCode = operationCode;
}
#XmlElement(name = "items")
public List<Item> getItems() {
return items;
}
public void setItems(List<Item> items) {
this.items = items;
}
#XmlRootElement(name = "item")
public static class Item {
private String label;
private String value;
#XmlElement(name = "label")
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
#XmlElement(name = "value")
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
How I can parse my xml string to CheckAbonSuccessResponseModel. Is it possible or not? I was trying but it shows just amount inside Result element.I need just know how I must write DefaultHandler class.
Thanks in advance.

How to call native query for spring repository(Join three tables and tables haven't any relationship)

I have three tables which called SLSNotification,SLSWorkflow and Importer These tables are not any relationships... I want to get three tables for jasper report.. So I create a native query for it.. It works fine on MySQL... But when i add it to the SLSWorkflowRepository retrieve only workflow class only.. I want to get other classes also from this repository... I think it retrieves only because i write this like this
#Query(value = "select * from slsnotification a join sls_wrkflw b on a.snumber = b.snumber join importers c on c.importer_vat_number = a.importervat where a.importervat = :importerVatNumber and a.snumber = :snumber", nativeQuery = true)
Object getForPrint(#Param("snumber") Long snumber,#Param("importerVatNumber") String importerVatNumber);
can i get other classes for SLSIWorkflow getForPrint() methord...
If i wrong please give some onother way...
This is my models
SLSNotification Model
#Entity
#Table(name = "slsnotification")
public class SLSNotification {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(length = 16)
private Long snumber;
#Column(length = 100)
private String serialCord;
private String date;
// #JsonFormat(pattern = "yyyy-MM-dd")
// private Date appPostdate = new Date();
#Column(nullable = false)
private String appPostdate;
#Column(length = 8)
private String cusOffice;
#Column(length = 1)
private String cusSerial;
#Column(length = 50)
private String cusDecNo;
#JsonFormat(pattern = "yyyy-MM-dd")
private Date cusDate;
#Column(length = 300)
private String manufacturer;
#Column(length = 300)
private String exporterAddress;
#Column(length = 20, nullable = false)
private String importerVAT;
#NotEmpty
#Column(length = 20, nullable = false)
private String declarantVAT;
private String declarantDetails;
private String vessel;
private String blNo;
private String loadingPort;
private String tradingCountry;
private String countryOrigin;
private String invoiceNo;
#JsonFormat(pattern = "yyyy-MM-dd")
private Date invoiceDate;
private Double invoiceValue;
public Long getSnumber() {
return snumber;
}
public void setSnumber(Long snumber) {
this.snumber = snumber;
}
public String getSerialCord() {
return serialCord;
}
public void setSerialCord(String serialCord) {
this.serialCord = serialCord;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getCusOffice() {
return cusOffice;
}
public void setCusOffice(String cusOffice) {
this.cusOffice = cusOffice;
}
public String getCusSerial() {
return cusSerial;
}
public void setCusSerial(String cusSerial) {
this.cusSerial = cusSerial;
}
public String getCusDecNo() {
return cusDecNo;
}
public void setCusDecNo(String cusDecNo) {
this.cusDecNo = cusDecNo;
}
public Date getCusDate() {
return cusDate;
}
public void setCusDate(Date cusDate) {
this.cusDate = cusDate;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getExporterAddress() {
return exporterAddress;
}
public void setExporterAddress(String exporterAddress) {
this.exporterAddress = exporterAddress;
}
public String getImporterVAT() {
return importerVAT;
}
public void setImporterVAT(String importerVAT) {
this.importerVAT = importerVAT;
}
public String getDeclarantVAT() {
return declarantVAT;
}
public void setDeclarantVAT(String declarantVAT) {
this.declarantVAT = declarantVAT;
}
public String getVessel() {
return vessel;
}
public void setVessel(String vessel) {
this.vessel = vessel;
}
public String getBlNo() {
return blNo;
}
public void setBlNo(String blNo) {
this.blNo = blNo;
}
public String getLoadingPort() {
return loadingPort;
}
public void setLoadingPort(String loadingPort) {
this.loadingPort = loadingPort;
}
public String getTradingCountry() {
return tradingCountry;
}
public void setTradingCountry(String tradingCountry) {
this.tradingCountry = tradingCountry;
}
public String getCountryOrigin() {
return countryOrigin;
}
public void setCountryOrigin(String countryOrigin) {
this.countryOrigin = countryOrigin;
}
public String getInvoiceNo() {
return invoiceNo;
}
public void setInvoiceNo(String invoiceNo) {
this.invoiceNo = invoiceNo;
}
public Date getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(Date invoiceDate) {
this.invoiceDate = invoiceDate;
}
public Double getInvoiceValue() {
return invoiceValue;
}
public void setInvoiceValue(Double invoiceValue) {
this.invoiceValue = invoiceValue;
}
SLSWorkflow Model
#Entity
#Table(name = "sls_wrkflw")
public class SLSIWorkflow {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long SNumber;
private String qc;
private String inv;
private String manuTr;
private String packList;
private String blAttached;
private String otherDoc;
private String otherDocName;
private String ad;
private String MAUsername;
private String appMan;
private String accptdQc;
private String accptTR;
private String manufacturer;
private String validMark;
private String otherDocBoolean;
private String cnfrmtyTest;
private String dtSampling;
private String otherDocDet;
private String adUsername;
private String recom;
private String reaRec;
private String tests;
private String wfStatus;
public Long getSNumber() {
return SNumber;
}
public void setSNumber(Long SNumber) {
this.SNumber = SNumber;
}
public String getQc() {
return qc;
}
public void setQc(String qc) {
this.qc = qc;
}
public String getInv() {
return inv;
}
public void setInv(String inv) {
this.inv = inv;
}
public String getManuTr() {
return manuTr;
}
public void setManuTr(String manuTr) {
this.manuTr = manuTr;
}
public String getPackList() {
return packList;
}
public void setPackList(String packList) {
this.packList = packList;
}
public String getBlAttached() {
return blAttached;
}
public void setBlAttached(String blAttached) {
this.blAttached = blAttached;
}
public String getMaattachUser() {
return maattachUser;
}
public void setMaattachUser(String maattachUser) {
this.maattachUser = maattachUser;
}
public String getMauser() {
return mauser;
}
public void setMauser(String mauser) {
this.mauser = mauser;
}
public String getMareattachUser() {
return mareattachUser;
}
public void setMareattachUser(String mareattachUser) {
this.mareattachUser = mareattachUser;
}
public String getOtherDoc() {
return otherDoc;
}
public void setOtherDoc(String otherDoc) {
this.otherDoc = otherDoc;
}
public String getOtherDocName() {
return otherDocName;
}
public void setOtherDocName(String otherDocName) {
this.otherDocName = otherDocName;
}
}
Importer Model
#Entity
#Table(name = "importers")
public class Importer {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "importer_id")
private long importerId;
private String importerBrc;
#NotEmpty
#Column(unique = true, nullable = false)
private String importerVatNumber;
#Column(nullable = false)
private String category;
private String importerSVatNumber;
#NotEmpty
private String importerName;
private String importerAddress1;
#NotEmpty
private String officePhoneNumber;
#NotEmpty
private String mobilePhoneNumber;
#Email
#NotEmpty
private String email;
#Email
private String optemail1;
#Email
private String optemail2;
#NotEmpty
private String userIDandTime;
#NotEmpty
private String recentUpdateBy;
public String getOptemail1() {
return optemail1;
}
public void setOptemail1(String optemail1) {
this.optemail1 = optemail1;
}
public String getOptemail2() {
return optemail2;
}
public void setOptemail2(String optemail2) {
this.optemail2 = optemail2;
}
#ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
#JoinTable(name = "importer_agents",
joinColumns = {
#JoinColumn(name = "importerId")},
inverseJoinColumns = {
#JoinColumn(name = "agentId")})
private List<Agent> agentList;
public String getImporterBrc() {
return importerBrc;
}
public void setImporterBrc(String importerBrc) {
this.importerBrc = importerBrc;
}
public String getImporterVatNumber() {
return importerVatNumber;
}
public void setImporterVatNumber(String importerVatNumber) {
this.importerVatNumber = importerVatNumber;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getImporterSVatNumber() {
return importerSVatNumber;
}
public void setImporterSVatNumber(String importerSVatNumber) {
this.importerSVatNumber = importerSVatNumber;
}
public String getImporterName() {
return importerName;
}
public void setImporterName(String importerName) {
this.importerName = importerName;
}
public String getImporterAddress1() {
return importerAddress1;
}
public void setImporterAddress1(String importerAddress1) {
this.importerAddress1 = importerAddress1;
}
}
SLSIWorkflowRepository
public interface SLSIWorkflowRepository extends CrudRepository<SLSIWorkflow,Long> {
#Override
SLSIWorkflow save(SLSIWorkflow slsiWorkflow);
#Override
SLSIWorkflow findOne(Long Long);
#Override
boolean exists(Long Long);
#Override
Iterable<SLSIWorkflow> findAll();
#Override
long count();
#Override
void delete(SLSIWorkflow entity);
#Query(value = "select * from slsnotification a join sls_wrkflw b on a.snumber = b.snumber join importers c on c.importer_vat_number = a.importervat where a.importervat = :importerVatNumber and a.snumber = :snumber", nativeQuery = true)
Object getForPrint(#Param("snumber") Long snumber,#Param("importerVatNumber") String importerVatNumber);
WorkflowServices
public class WorkflowServices {
private static final Logger serviceLogger = LogManager.getLogger(WorkflowServices.class);
private static final String INIT_WORKFLOW_STATUS = "INIT";
#Autowired
private SLSIWorkflowRepository workflowRepository;
#Autowired
private FileSystemStorageService storageService;
#Autowired
private SLSNotificationRepository slsNotificationRepository;
public void initWorkflow(Long slsNumber) {
SLSIWorkflow workflow = new SLSIWorkflow();
workflow.setSNumber(slsNumber);
workflow.setWfStatus(INIT_WORKFLOW_STATUS);
workflowRepository.save(workflow);
}
public SLSIWorkflow getApplicationForPrint(Long SNumber, String importerVatNumber) {
return workflowRepository.getForPrint(SNumber, importerVatNumber);
}
}
Workflow Controller //this is large and i gives my cord only
#RequestMapping(path = "/viewTAXInvoice/{snumber}/{importerVatNumber}", method = RequestMethod.POST)
public ModelAndView getPDFReport(#PathVariable("snumber") String snumber, #PathVariable("importerVatNumber") String importerVatNumber) {
File reportsDir = Paths.get(servletContext.getRealPath(reportDataLocation)).toFile();
if (!reportsDir.exists()) {
throw ProductWithSameSerialExistsException.getInstance();
}
JRDataSource dataSource = new JRBeanCollectionDataSource(Arrays.asList(workflowServices.getApplicationForPrint(Long.parseLong(snumber), importerVatNumber)));
Map<String, Object> parameterMap = new HashMap<>();
parameterMap.put("datasource", dataSource);
parameterMap.put("JasperCustomSubReportDatasource", dataSource);
parameterMap.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(reportsDir));
System.out.println("Dt Source1 "+dataSource);
return new ModelAndView("pdfReportforVAT", parameterMap);
}
How to connect three tables... Please help me someone...
You are getting a SLSIWorkflow only because you are returning that Entity only in the following code in WorkflowServices.
public SLSIWorkflow getApplicationForPrint(Long SNumber, String importerVatNumber) {
return workflowRepository.getForPrint(SNumber, importerVatNumber);
}
If you return an Object it will have all the fields from tables slsnotification, sls_wrkflw, importers as a Object[].
Plus using a Plain JOIN it will result in an INNER JOIN by default. This will not return anything if one joined table doesn't satisfy the ON criteria. It is good if you use LEFT JOIN so that the null will be returned.

JAXB IllegalAnnotationExceptions

I am working with JAXB for the first time, and am having some issues understanding what it wants me to do.
I've setup a class that will be part of a fairly large XML - this class will represent the "Header" section of the XML document.
package com.somecompany.jscentral.xml.integrator.soc;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.somecompany.jscentral.xml.AbstractXML;
#XmlRootElement(name = "Header")
#XmlAccessorType(XmlAccessType.NONE)
#XmlType(propOrder = {"OrderRoutine", "CreationDate", "CreationTime", "UserId", "CustomerNumber",
"OrderType", "Salesman", "Handler", "Warehouse", "PrimaryCurrency", "OrderNumber",
"Name", "OrderDate", "DeliveryAddressNumber", "ConfirmationAddressNumber", "FullName999",
"CompanyName999", "StreetAddress999Line1", "StreetAddress999Line2", "City999", "StateProvince999",
"PostCode999", "Country999", "Resale999", "InvoiceCustomerNumber", "CustomerReference",
"NumberOfInvoiceCopies", "Language", "VAT", "Backlog", "OrderDiscountPercent", "DiscountGroup",
"PriceCode", "StandardTextNumber", "HoldOrder", "TermsOfPayment", "CreditDays", "TermsOfDelivery",
"MannerOfTransport", "FreightFee", "PostageFee", "InsuranceFee", "AdministrationFee", "InvoiceFee",
"CustomersOrderNumberReference", "GoodsMarking", "HoldInvoice", "DeliveryAddressEngineer",
"DeliveryAddressLocation", "CountryDispatchedToArrivedFrom", "VATRegNumberOfDebtorAddr",
"NatureOfTransaction", "VATHandlingCode", "PortOfArrivalDispatch", "CountryOfTrader", "InternalOrder",
"ToWarehouse", "RouteId", "DepartureId", "DestinationId", "ShippingAgent", "ContactListCode",
"Salesman2", "CreationDate2", "Sequence", "DebtorNumber", "DebtorAddressNumber", "InvoiceAddressNumber",
"WebOrder", "Confirmed", "ClientIdentity"})
public class Header extends AbstractXML {
public Header() throws JAXBException {
super();
}
#XmlElement(name = "OrderRoutine", required = true)
private String orderRoutine;
public void setOrderRoutine(String orderRoutine) {
this.orderRoutine = orderRoutine;
}
public String getOrderRoutine() {
return this.orderRoutine;
}
#XmlElement(name = "CreationDate", required = false)
private String creationDate;
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
public String getCreationDate() {
return this.creationDate;
}
#XmlElement(name = "CreationTime", required = false)
private String creationTime;
public void setCreationTime(String creationTime) {
this.creationTime = creationTime;
}
public String getCreationTime() {
return this.creationTime;
}
#XmlElement(name = "UserId", required = false)
private String userId;
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return this.userId;
}
#XmlElement(name = "CustomerNumber", required = true)
private String customerNumber;
public void setCustomerNumber(String customerNumber) {
this.customerNumber = customerNumber;
}
public String getCustomerNumber() {
return this.customerNumber;
}
#XmlElement(name = "OrderType", required = true)
private String orderType;
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getOrderType() {
return this.orderType;
}
#XmlElement(name = "Salesman", required = true)
private String salesman;
public void setSalesman(String salesman) {
this.salesman = salesman;
}
public String getSalesman() {
return this.salesman;
}
#XmlElement(name = "Handler", required = true)
private String handler;
public void setHandler(String handler) {
this.handler = handler;
}
public String getHandler() {
return this.handler;
}
#XmlElement(name = "Warehouse", required = true)
private String warehouse;
public void setWarehouse(String warehouse) {
this.warehouse = warehouse;
}
public String getWarehouse() {
return this.warehouse;
}
#XmlElement(name = "PrimaryCurrency", required = true)
private String primaryCurrency;
public void setPrimaryCurrency(String primaryCurrency) {
this.primaryCurrency = primaryCurrency;
}
public String getPrimaryCurrency() {
return this.primaryCurrency;
}
#XmlElement(name = "OrderNumber", required = false)
private String orderNumber;
public void setOrderNumber(String orderNumber) {
this.orderNumber = orderNumber;
}
public String getOrderNumber() {
return this.orderNumber;
}
#XmlElement(name = "Name", required = false)
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
#XmlElement(name = "OrderDate", required = false)
private String orderDate;
public void setOrderDate(String orderDate) {
this.orderDate = orderDate;
}
public String getOrderDate() {
return this.orderDate;
}
#XmlElement(name = "DeliveryAddressNumber", required = false)
private String deliveryAddressNumber;
public void setDeliveryAddressNumber(String deliveryAddressNumber) {
this.deliveryAddressNumber = deliveryAddressNumber;
}
public String getDeliveryAddressNumber() {
return this.deliveryAddressNumber;
}
#XmlElement(name = "ConfirmationAddressNumber", required = false)
private String confirmationAddressNumber;
public void setConfirmationAddressNumber(String confirmationAddressNumber) {
this.confirmationAddressNumber = confirmationAddressNumber;
}
public String getConfirmationAddressNumber() {
return this.confirmationAddressNumber;
}
#XmlElement(name = "FullName999", required = true)
private String fullName999;
public void setFullName999(String fullName999) {
this.fullName999 = fullName999;
}
public String getFullName999() {
return this.fullName999;
}
#XmlElement(name = "CompanyName999", required = true)
private String companyName999;
public void setCompanyName999(String companyName999) {
this.companyName999 = companyName999;
}
public String getCompanyName999() {
return this.companyName999;
}
#XmlElement(name = "StreetAddress999Line1", required = true)
private String streetAddress999Line1;
public void setStreetAddress999Line1(String streetAddress999Line1) {
this.streetAddress999Line1 = streetAddress999Line1;
}
public String getStreetAddress999Line1() {
return this.streetAddress999Line1;
}
#XmlElement(name = "StreetAddress999Line2", required = true)
private String streetAddress999Line2;
public void setStreetAddress999Line2(String streetAddress999Line2) {
this.streetAddress999Line2 = streetAddress999Line2;
}
public String getStreetAddress999Line2() {
return this.streetAddress999Line2;
}
#XmlElement(name = "City999", required = true)
private String city999;
public void setCity999(String city999) {
this.city999 = city999;
}
public String getCity999() {
return this.city999;
}
#XmlElement(name = "StateProvince999", required = true)
private String stateProvince999;
public void setStateProvince999(String stateProvince999) {
this.stateProvince999 = stateProvince999;
}
public String getStateProvince999() {
return this.stateProvince999;
}
#XmlElement(name = "PostCode999", required = true)
private String postCode999;
public void setPostCode999(String postCode999) {
this.postCode999 = postCode999;
}
public String getPostCode999() {
return this.postCode999;
}
#XmlElement(name = "Country999", required = true)
private String country999;
public void setCountry999(String country999) {
this.country999 = country999;
}
public String getCountry999() {
return this.country999;
}
#XmlElement(name = "Resale999", required = false)
private String resale999;
public void setResale999(String resale999) {
this.resale999 = resale999;
}
public String getResale999() {
return this.resale999;
}
#XmlElement(name = "InvoiceCustomerNumber", required = false)
private String invoiceCustomerNumber;
public void setInvoiceCustomerNumber(String invoiceCustomerNumber) {
this.invoiceCustomerNumber = invoiceCustomerNumber;
}
public String getInvoiceCustomerNumber() {
return this.invoiceCustomerNumber;
}
#XmlElement(name = "CustomerReference", required = false)
private String customerReference;
public void setCustomerReference(String customerReference) {
this.customerReference = customerReference;
}
public String getCustomerReference() {
return this.customerReference;
}
#XmlElement(name = "NumberOfInvoiceCopies", required = false)
private String numberOfInvoiceCopies;
public void setNumberOfInvoiceCopies(String numberOfInvoiceCopies) {
this.numberOfInvoiceCopies = numberOfInvoiceCopies;
}
public String getNumberOfInvoiceCopies() {
return this.numberOfInvoiceCopies;
}
#XmlElement(name = "Language", required = false)
private String language;
public void setLanguage(String language) {
this.language = language;
}
public String getLanguage() {
return this.language;
}
#XmlElement(name = "VAT", required = false)
private String vat;
public void setVAT(String vat) {
this.vat = vat;
}
public String getVAT() {
return this.vat;
}
#XmlElement(name = "Backlog", required = false)
private String backlog;
public void setBacklog(String backlog) {
this.backlog = backlog;
}
public String getBacklog() {
return this.backlog;
}
#XmlElement(name = "OrderDiscountPercent", required = false)
private String orderDiscountPercent;
public void setOrderDiscountPercent(String orderDiscountPercent) {
this.orderDiscountPercent = orderDiscountPercent;
}
public String getOrderDiscountPercent() {
return this.orderDiscountPercent;
}
#XmlElement(name = "DiscountGroup", required = false)
private String discountGroup;
public void setDiscountGroup(String discountGroup) {
this.discountGroup = discountGroup;
}
public String getDiscountGroup() {
return this.discountGroup;
}
#XmlElement(name = "PriceCode", required = false)
private String priceCode;
public void setPriceCode(String priceCode) {
this.priceCode = priceCode;
}
public String getPriceCode() {
return this.priceCode;
}
#XmlElement(name = "StandardTextNumber", required = false)
private String standardTextNumber;
public void setStandardTextNumber(String standardTextNumber) {
this.standardTextNumber = standardTextNumber;
}
public String getStandardTextNumber() {
return this.standardTextNumber;
}
#XmlElement(name = "HoldOrder", required = false)
private String holdOrder;
public void setHoldOrder(String holdOrder) {
this.holdOrder = holdOrder;
}
public String getHoldOrder() {
return this.holdOrder;
}
#XmlElement(name = "TermsOfPayment", required = true)
private String termsOfPayment;
public void setTermsOfPayment(String termsOfPayment) {
this.termsOfPayment = termsOfPayment;
}
public String getTermsOfPayment() {
return this.termsOfPayment;
}
#XmlElement(name = "CreditDays", required = false)
private String creditDays;
public void setCreditDays(String creditDays) {
this.creditDays = creditDays;
}
public String getCreditDays() {
return this.creditDays;
}
#XmlElement(name = "TermsOfDelivery", required = false)
private String termsOfDelivery;
public void setTermsOfDelivery(String termsOfDelivery) {
this.termsOfDelivery = termsOfDelivery;
}
public String getTermsOfDelivery() {
return this.termsOfDelivery;
}
#XmlElement(name = "MannerOfTransport", required = true)
private String mannerOfTransport;
public void setMannerOfTransport(String mannerOfTransport) {
this.mannerOfTransport = mannerOfTransport;
}
public String getMannerOfTransport() {
return this.mannerOfTransport;
}
#XmlElement(name = "FreightFee", required = true)
private String freightFee;
public void setFreightFee(String freightFee) {
this.freightFee = freightFee;
}
public String getFreightFee() {
return this.freightFee;
}
#XmlElement(name = "PostageFee", required = false)
private String postageFee;
public void setPostageFee(String postageFee) {
this.postageFee = postageFee;
}
public String getPostageFee() {
return this.postageFee;
}
#XmlElement(name = "InsuranceFee", required = false)
private String insuranceFee;
public void setInsuranceFee(String insuranceFee) {
this.insuranceFee = insuranceFee;
}
public String getInsuranceFee() {
return this.insuranceFee;
}
#XmlElement(name = "AdministrationFee", required = false)
private String administrationFee;
public void setAdministrationFee(String administrationFee) {
this.administrationFee = administrationFee;
}
public String getAdministrationFee() {
return this.administrationFee;
}
#XmlElement(name = "InvoiceFee", required = false)
private String invoiceFee;
public void setInvoiceFee(String invoiceFee) {
this.invoiceFee = invoiceFee;
}
public String getInvoiceFee() {
return this.invoiceFee;
}
#XmlElement(name = "CustomersOrderNumberReference", required = true)
private String customersOrderNumberReference;
public void setCustomersOrderNumberReference(String customersOrderNumberReference) {
this.customersOrderNumberReference = customersOrderNumberReference;
}
public String getCustomersOrderNumberReference() {
return this.customersOrderNumberReference;
}
#XmlElement(name = "GoodsMarking", required = true)
private String goodsMarking;
public void setGoodsMarking(String goodsMarking) {
this.goodsMarking = goodsMarking;
}
public String getGoodsMarking() {
return this.goodsMarking;
}
#XmlElement(name = "HoldInvoice", required = false)
private String holdInvoice;
public void setcustomersOrderNumberReference(String holdInvoice) {
this.holdInvoice = holdInvoice;
}
public String getcustomersOrderNumberReference() {
return this.holdInvoice;
}
#XmlElement(name = "DeliveryAddressEngineer", required = false)
private String deliveryAddressEngineer;
public void setDeliveryAddressEngineer(String deliveryAddressEngineer) {
this.deliveryAddressEngineer = deliveryAddressEngineer;
}
public String getDeliveryAddressEngineer() {
return this.deliveryAddressEngineer;
}
#XmlElement(name = "DeliveryAddressLocation", required = false)
private String deliveryAddressLocation;
public void setDeliveryAddressLocation(String deliveryAddressLocation) {
this.deliveryAddressLocation = deliveryAddressLocation;
}
public String getDeliveryAddressLocation() {
return this.deliveryAddressLocation;
}
#XmlElement(name = "CountryDispatchedToArrivedFrom", required = false)
private String countryDispatchedToArrivedFrom;
public void setCountryDispatchedToArrivedFrom(String countryDispatchedToArrivedFrom) {
this.countryDispatchedToArrivedFrom = countryDispatchedToArrivedFrom;
}
public String getCountryDispatchedToArrivedFrom() {
return this.countryDispatchedToArrivedFrom;
}
#XmlElement(name = "VATRegNumberOfDebtorAddr", required = false)
private String vatRegNumberOfDebtorAddr;
public void setVATRegNumberOfDebtorAddr(String vatRegNumberOfDebtorAddr) {
this.vatRegNumberOfDebtorAddr = vatRegNumberOfDebtorAddr;
}
public String getVATRegNumberOfDebtorAddr() {
return this.vatRegNumberOfDebtorAddr;
}
#XmlElement(name = "NatureOfTransaction", required = false)
private String natureOfTransaction;
public void setNatureOfTransaction(String natureOfTransaction) {
this.natureOfTransaction = natureOfTransaction;
}
public String getNatureOfTransaction() {
return this.natureOfTransaction;
}
#XmlElement(name = "VATHandlingCode", required = false)
private String vatHandlingCode;
public void setVATHandlingCode(String vatHandlingCode) {
this.vatHandlingCode = vatHandlingCode;
}
public String getVATHandlingCode() {
return this.vatHandlingCode;
}
#XmlElement(name = "PortOfArrivalDispatch", required = false)
private String portOfArrivalDispatch;
public void setPortOfArrivalDispatch(String portOfArrivalDispatch) {
this.portOfArrivalDispatch = portOfArrivalDispatch;
}
public String getPortOfArrivalDispatch() {
return this.portOfArrivalDispatch;
}
#XmlElement(name = "CountryOfTrader", required = false)
private String countryOfTrader;
public void setCountryOfTrader(String countryOfTrader) {
this.countryOfTrader = countryOfTrader;
}
public String getCountryOfTrader() {
return this.countryOfTrader;
}
// ETC...
}
Here's the stack trace:
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 142 counts of IllegalAnnotationExceptions
Property orderRoutine is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.orderRoutine
at com.somecompany.jscentral.xml.integrator.soc.Header
Property creationDate is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.creationDate
at com.somecompany.jscentral.xml.integrator.soc.Header
Property creationTime is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.creationTime
at com.somecompany.jscentral.xml.integrator.soc.Header
Property userId is present but not specified in #XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.userId
at com.somecompany.jscentral.xml.integrator.soc.Header
.. ETC ..
Property OrderRoutine appears in #XmlType.propOrder, but no such property exists. Maybe you meant orderRoutine?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property CreationDate appears in #XmlType.propOrder, but no such property exists. Maybe you meant creationDate?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property CreationTime appears in #XmlType.propOrder, but no such property exists. Maybe you meant creationTime?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
.. ETC ..
Property InvoiceAddressNumber appears in #XmlType.propOrder, but no such property exists. Maybe you meant invoiceAddressNumber?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property WebOrder appears in #XmlType.propOrder, but no such property exists. Maybe you meant webOrder?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property Confirmed appears in #XmlType.propOrder, but no such property exists. Maybe you meant confirmed?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property ClientIdentity appears in #XmlType.propOrder, but no such property exists. Maybe you meant clientIdentity?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at com.somecompany.jscentral.xml.AbstractXML.<init>(AbstractXML.java:21)
at com.somecompany.jscentral.xml.integrator.soc.Header.<init>(Header.java:33)
at com.somecompany.jscentral.xml.integrator.IntegratorSOCXML.main(IntegratorSOCXML.java:22)
I have tried different #XmlAccessorType's ... but no change. I have also tried annotating the methods with #XmlTransient and no difference. What am I doing wrong?
The propOrder is based on the field/property name and not the element name. If you make this change everything will work correctly.
http://blog.bdoughan.com/2012/02/jaxbs-xmltype-and-proporder.html
Also if you are going to annotate the fields you should specify #XmlAccessorType(XmlAccessType.FIELD) on your class.
http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html
Also since I notice you have inheritance in your model you can't include inherited properties in the propOrder unless you mark the part class with #XmlTransient.
http://blog.bdoughan.com/2012/08/jaxbs-xmltransient-and-property-order.html

Categories

Resources