Results 1 to 1 of 1
- 02-05-2009, 09:00 PM #1Member
- Join Date
- Dec 2007
- Rep Power
xml mapping error with JPA in RAD, RSA
I am İshak Teyran , the data manager of a team which attends to IBM XML Challenge Turkey, we are trying to build a dynamic web project in Rational Software Architect 7.5, WAS 7.0 , DB2 9.5 EE.
the article of Vitor Rodrigues - insert http and www before links ibm.com/developerworks/data/library/techarticle/dm-0901rodrigues/index.html--- introduces pureXML data in Java applications with pureQuery - describes how to map xml to java using pureQuery however we need to do the same using JPA.. is there any difference?
we are trying to achieve the same using JPA. but unfortunately we failed..
for simplifying lets assume we have two tables , STUDENT ( id int, name char) and COURSES ( studentID int , and lessons xml) ... these two tables are related to each other with studentID foreign key... and we want to have student and courses java files where courses.java includes proper mapping to xml column lessons..
i tried to make an .xsd file for xml column lessons.. and then i created its java file.. then i used JPA for creating student and courses java files but it always turns me a null pointer exception.. i dont know why.. and as result , only student.java is being created..
i have tried following steps.
My database connection and the tables are already present.
1- i have created a new dynamic web site project, namely dene..
2- i have created the CourseList.xsd and using -JAXB- i have created lessons.java
3- i right clicked project and from the menu .. JPA tools->Generate Entities .. i choose connection and tables to generate entities but unfortunately no entity gets created ... when i only choose student table to generate the entity of, Student.java is being created however Courses.java always returns nullpointerexception..
the stack trace of the exception is in the picture i attached.. here is its link....ibm.com/developerworks/forums/servlet/JiveServlet/download/430-250134-14212507-336353/hata.JPG
i have thought it might be because i use the openjpa and jaxb libraries of RSA.. and then i tried to load the latest versions of JAXB and openjpa .. i added all of their .jar files to the application classpath.. (if it is sufficient to add only openjpa-1.2.0.jar and jaxb-api.jar files let me know it please).. but this did not work neither..
the only exception i get is :
An internal error occurred during: "Generating Entities".
while creating lessons.java and the entity java files i am making sure that i give the same package name for both ... but i never succeeded creating courses.java..
in RSA when i right click to project and go te JPA Tools menu there is a menu item "Configure Project for JDBC deployment" .. what is this for.. i have also tried using this and then trying to create entities but this failed too..
then when they did not work ;
i have decided to code the classes myself but in order to get things a little easier, i opened my DB and converted the XML column to a SMALLINT column .. just not an XML column... and then using JPA in RSA - i did not include openJPA jars in my project externally- i created the classes .. both Course.java and Student.java have been created well, because the column that was actually xml was converted to small integer..
and if i add the related persistence and strategy lines :
to their proper places and editing the function and attributes data types and return types and then if i re-convert the column to XML data type in database, do you think it will work properly?
so i really need a suggestion.. any help will be appreciated..
what would you suggest?
how can we achieve this goal for those two tables i mentioned above in RSA and using JPA ?
Add to ishakteyran's Reputation
- By ishakteyran in forum XMLReplies: 0Last Post: 02-05-2009, 08:59 PM
- By zigzag in forum JDBCReplies: 1Last Post: 11-11-2008, 09:18 PM
- By coco in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 04:06 AM
- By Heather in forum Java ServletReplies: 1Last Post: 07-14-2007, 06:00 PM