cancel
Showing results for 
Search instead for 
Did you mean: 

JDO checker problem : could somebody please tell what I am doing wrong here

Former Member
0 Kudos

I am having a strange problem with the JDO checker. I first read and tried out the exercise described in the "Getting Started with JDO" tutorial which is available both in the SAP Help files and as a download from this website. I am now trying to apply the learnings in a different project.

I created a Java project to create the PC Classes. In my scenario I have a Consultant object and a Solution Object. Both objects have a bi-directional many-to-many relationship. Consultant has a solutions field as a set of Solution Objects, and vice versa.

In the dictionary project I have created three tables

PFL_CONSULTANTS (holding the persistent fields of the Consultant object instances)

PFL_SAPSOLUTIONS (holding the persistent fields of the SAP Solution objects)

PFL_CONS_SOL_MAP (the mapping table)

As I learned from the help files I am using the JDO enhancer, following the instructions in the tutorial.

This means

- I created a Consultant.jdo and Solutions.jdo file

I am adding the Consultant.jdo file as an example

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE jdo SYSTEM "jdo.dtd">

<jdo>

<package name="com.atosorigin.tcc.portal.profiling.jdo">

<class name="Consultant" identity-type="application" objectid-class="Consultant$Id">

<field name="consId" persistence-modifier="persistent" primary-key="true"/>

<field name="firstname" persistence-modifier="persistent"/>

<field name="lastname" persistence-modifier="persistent"/>

<field name="country" persistence-modifier="persistent"/>

<field name="solutions" persistence-modifier="persistent" embedded="false" default-fetch-group="false" >

<collection element-type="com.atosorigin.tcc.portal.profiling.jdo.Solution" embedded-element="false"/>

</class>

</field>

</package>

</jdo>

- I created a mapping file for both classes, Consultant.map resp. Solution.map

I am adding the mapping file content for the Consultant class as an example:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE map SYSTEM "map.dtd">

<map version="1.0">

<package name="com.atosorigin.tcc.portal.profiling.jdo">

<class name="Consultant">

<field name="consId">

<column name="ID" table="PFL_CONSULTANTS" />

</field>

<field name="firstname">

<column name="FIRSTNAME" table="PFL_CONSULTANTS" />

</field>

<field name="lastname">

<column name="LASTNAME" table="PFL_CONSULTANTS" />

</field>

<field name="country">

<column name="COUNTRY" table="PFL_CONSULTANTS" />

</field>

<relationship-field name="solutions" multiplicity="many" join-table="true" >

<foreign-key name="PFL_CONS_SOL_MAP_TO_PFL_SAPSOLUTIONS"

foreign-key-table="PFL_CONS_SOL_MAP"

primary-key-table="PFL_SAPSOLUTIONS">

<column-pair foreign-key-column="SOLUTIONID" primary-key-column="ID" />

</foreign-key>

<foreign-key name="PFL_CONS_SOL_MAP_TO_PFL_CONSULTANTS"

foreign-key-table="PFL_CONS_SOL_MAP"

primary-key-table="PFL_CONSULTANTS">

<column-pair foreign-key-column="CONSULTANTID" primary-key-column="ID" />

</foreign-key>

</relationship-field>

</class>

</package>

</map>

As you can see, I have TWO foreign key nodes in the mapping file. This is as per instruction, because I am expressing a bi-directional many to many relationship. The join-table property is set to true.

- I created build.xml file for the ANT tool, which holds targets for running both the JDO enhancer and the checker against the classes and their ORM mapping information.

I hope this gives you an idea of what I am trying to do. Now over to the actual problem.

The enhancer works fine, no problem there. If I decompile the classes back, I can see that the enhancer has done its work as expected. The JDO interface implementation is there.

However, the checker keeps throwing errors. The error is one of two. Apparently the validating parser has a problem with the foreign-key nodes in the mapping file.

With the mapping file settings as displayed above the error thrown reads as follows :

[java] ... catalog path: TCCProfiling/gen_ddic/dbtables/

[java] javax.jdo.JDOFatalUserException: XML mapping data parse error

[java] NestedThrowables:

[java] com.atosorigin.tcc.portal.profiling.jdo.Consultant: check for PC Class failed / Validation Error: com.sap.engine.lib.xml.parser.ParserException: Unexpected element, foreign-key. It cannot appear here according to the content model of relationship-field(:main:, row:28, col:51)

[java] com.sap.engine.lib.xml.parser.NestedSAXParserException: Validation Error: com.sap.engine.lib.xml.parser.ParserException: Unexpected element, foreign-key. It cannot appear here according to the content model of relationship-field(:main:, row:28, col:51)(:main:, row=28, col=51) -> com.sap.engine.lib.xml.parser.ParserException: Unexpected element, foreign-key. It cannot appear here according to the content model of relationship-field(:main:, row:28, col:51)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.lookupXMLMappingData(MappingModelImpl.java:532)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.lookupXMLMappingData(MappingModelImpl.java:490)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.getMappingClass(MappingModelImpl.java:296)

[java] at com.sap.jdo.sql.util.JDO.checkClasses(JDO.java:201)

[java] at com.sap.jdo.sql.util.JDO.process(JDO.java:423)

[java] at com.sap.jdo.sql.util.JDO.main(JDO.java:406)

[java] NestedThrowablesStackTrace:

[java] com.sap.engine.lib.xml.parser.NestedSAXParserException: Validation Error: com.sap.engine.lib.xml.parser.ParserException: Unexpected element, foreign-key. It cannot appear here according to the content model of relationship-field(:main:, row:28, col:51)(:main:, row=28, col=51) -> com.sap.engine.lib.xml.parser.ParserException: Unexpected element, foreign-key. It cannot appear here according to the content model of relationship-field(:main:, row:28, col:51)

[java] at com.sap.engine.lib.xml.parser.dtd.XMLValidator.startElement(XMLValidator.java:179)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanElement(XMLParser.java:1693)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanContent(XMLParser.java:2298)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanElement(XMLParser.java:1719)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanContent(XMLParser.java:2298)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanElement(XMLParser.java:1719)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanContent(XMLParser.java:2298)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanElement(XMLParser.java:1719)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanContent(XMLParser.java:2298)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanElement(XMLParser.java:1719)

[java] at com.sap.engine.lib.xml.parser.XMLParser.scanDocument(XMLParser.java:2701)

[java] at com.sap.engine.lib.xml.parser.XMLParser.parse0(XMLParser.java:162)

[java] at com.sap.engine.lib.xml.parser.AbstractXMLParser.parseAndCatchException(AbstractXMLParser.java:126)

[java] at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:141)

[java] at com.sap.engine.lib.xml.parser.AbstractXMLParser.parse(AbstractXMLParser.java:193)

[java] at com.sap.engine.lib.xml.parser.Parser.parseWithoutSchemaValidationProcessing(Parser.java:270)

[java] at com.sap.engine.lib.xml.parser.Parser.parse(Parser.java:328)

[java] at com.sap.engine.lib.xml.parser.SAXParser.parse(SAXParser.java:125)

[java] at com.sap.jdo.sql.mapping.xml.Parser_1_0.parse(Parser_1_0.java:203)

[java] at com.sap.jdo.sql.mapping.xml.Parser_1_0.parse(Parser_1_0.java:174)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.lookupXMLMappingData(MappingModelImpl.java:526)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.lookupXMLMappingData(MappingModelImpl.java:490)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.getMappingClass(MappingModelImpl.java:296)

[java] at com.sap.jdo.sql.util.JDO.checkClasses(JDO.java:201)

[java] at com.sap.jdo.sql.util.JDO.process(JDO.java:423)

[java] at com.sap.jdo.sql.util.JDO.main(JDO.java:406)

[java] -


[java] at com.sap.engine.lib.xml.parser.SAXParser.parse(SAXParser.java:142)

[java] at com.sap.jdo.sql.mapping.xml.Parser_1_0.parse(Parser_1_0.java:203)

[java] at com.sap.jdo.sql.mapping.xml.Parser_1_0.parse(Parser_1_0.java:174)

[java] => 1 PC class(es) checked (1 failed), 0 non PC class(es) not checked

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.lookupXMLMappingData(MappingModelImpl.java:526)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.lookupXMLMappingData(MappingModelImpl.java:490)

[java] at com.sap.jdo.sql.mapping.impl.MappingModelImpl.getMappingClass(MappingModelImpl.java:296)

[java] at com.sap.jdo.sql.util.JDO.checkClasses(JDO.java:201)

[java] at com.sap.jdo.sql.util.JDO.process(JDO.java:423)

[java] at com.sap.jdo.sql.util.JDO.main(JDO.java:406)

That would mean that having two foreign key nodes within the relationship-field node is not allowed. However, when I remove one of them I am told it SHOULD have two foreign-key nodes because join-table is set to true.

Is this a bug or could someone give me a hint about what I am doing wrong here.

Thanks in advance for your support.

Message was edited by: Theo Paesen

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Theo,

I took a fast look at it and it seems to be, that

the Consultant.jdo is wrong. You interchange the

tags </class> and </field>.

But it looks a little bit to easy for me.

...

<field name="country" persistence-modifier="persistent"/>

<field name="solutions" persistence-modifier="persistent" embedded="false" default-fetch-group="false" >

<collection element-type="com.atosorigin.tcc.portal.profiling.jdo.Solution" embedded-element="false"/>

<b></class>

</field></b>

</package>

</jdo></i>

kind regards

alex

Former Member
0 Kudos

This is becoming a rather unpleasant monologue I am afraid ... After one week, not a single reply to my question.

Due to the lack of feed-back, as of today I will start spreading the news amongst my colleagues that JDO is currently not properly implemented on SAP Web AS 6.40 (stack level 5) and that we will have to look for one of the other persistence technologies on their platform. JDO is currently not an option because nobody appears to be using it. For a reason perhaps ? The documentation is there all right, the SAP presentations all have the three letter word JDO, but once you want to start using it you run into unexpected errors with even the simplest of exercises.

Still, should there happen to be someone on this forum who can explain to me how the mapping metadata should looko like to express a bidirectional many-to-many relationship between two PC Classes, I am still very curious to know. I tried the documenation provided by SAP but with that I am running in circles : if I declare two foreign keys with join-table = true, the xml parser complains about an unexpected element foreign-key, when I leave it out, the same parser tells me my relation-ship field should declare two ?

For the time being however I consider JDO on Web AS not to be an option.

Message was edited by: Theo Paesen

Former Member
0 Kudos

Hi Theo,

nearly two years later i get the same problem. Meanwhile I solved it. The reason is (in my case) that the key-column of my Oracle-table does not have column-index 0, i.e. there are two columns before the key-column. In DDL:

create table t1 (

c1 varchar2(10),

c2 varchar2(10),

c3 varchar2(10)

)

key-column is not c1, but c2. That's the whole problem. Is this the same problem as your's? Do you have made any more experience with JDO meanwhile? Would you advise to use JDO or better not? Do you know ifmy problem is JDO-specific or is this a problem of the SAP-implementation of JDO?

Kind regards,

Christoph

Former Member
0 Kudos

Am I REALLY the only one here trying out JDO ? Some input would really be higly appreciated.

It's one of three

1. either I am making a mistake in the mapping file.

2. or the help files provided by SAP for defining a bi-directional many-to-many relationship are incorrect.

3. or this is a bug.

In the mean time I just continued my project, created a Session Bean that uses the PC Classes and generated a web service from it. I am now trying to test the Session bean methods. The same error also pops up at runtime.

Any thoughts ?