Horizontal mapping + MappingInfoNotFoundException
Hi,
i got a problem with the mappingtool.
I'am using horizontal mapping.
The abstract superclass Person has an primary key field called id.
Here is the jdo-metadata from package.jdo:
<class name="Person" identity-type="application"
objectid-class="PersonId">
<field name="location" embedded="true"/>
<field name="id" primary-key="true"/>
<field name="kidNames">
<collection element-type="java.lang.String"/>
</field>
</class>
Here is the mapping data from package.mapping:
<class name="Person">
<jdbc-class-map type="horizontal"/>
</class>
I looked at the manual, section 7.6.4.
Thank you
Zach
688 INFO [main] kodo.Tool - Mapping tool running on type "class
xxx.persistence.jdo.business.Course" with action "validate".
kodo.jdbc.meta.MappingInfoNotFoundException: No mapping information was
found fo
r "xxx.business.Person.id".
at
kodo.jdbc.meta.RuntimeMappingProvider.getFieldMapping(RuntimeMappingP
rovider.java:149)
at
kodo.jdbc.meta.MappingRepository.getFieldMapping(MappingRepository.ja
va:429)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:911)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:888)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:666)
at
kodo.jdbc.meta.RuntimeMappingProvider.initialize(RuntimeMappingProvid
er.java:89)
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository
java:364)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:30
7)
at
kodo.jdbc.meta.AbstractFieldMapping.getTypeMapping(AbstractFieldMappi
ng.java:661)
at
kodo.jdbc.meta.OneToOneFieldMapping.fromMappingInfo(OneToOneFieldMapp
ing.java:123)
at
kodo.jdbc.meta.RuntimeMappingProvider.getFieldMapping(RuntimeMappingP
rovider.java:160)
at
kodo.jdbc.meta.MappingRepository.getFieldMapping(MappingRepository.ja
va:429)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:911)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:891)
at
kodo.jdbc.meta.AbstractClassMapping.getMappings(AbstractClassMapping.
java:854)
at
kodo.jdbc.meta.AbstractClassMapping.getDeclaredFieldMappings(AbstractClassMapping.java:617)
at
kodo.jdbc.meta.AbstractClassMapping.resolve(AbstractClassMapping.java
:758)
at
kodo.jdbc.meta.BaseClassMapping.resolve(BaseClassMapping.java:323)
at
kodo.jdbc.meta.MappingRepository.resolve(MappingRepository.java:390)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:30
8)
at
kodo.jdbc.meta.AbstractFieldMapping.getTypeMapping(AbstractFieldMappi
ng.java:661)
at
kodo.jdbc.meta.OneToOneFieldMapping.fromMappingInfo(OneToOneFieldMapp
ing.java:123)
at
kodo.jdbc.meta.RuntimeMappingProvider.getFieldMapping(RuntimeMappingP
rovider.java:160)
at
kodo.jdbc.meta.MappingRepository.getFieldMapping(MappingRepository.ja
va:429)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:911)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:891)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapp
ing.java:666)
at
kodo.jdbc.meta.RuntimeMappingProvider.initialize(RuntimeMappingProvid
er.java:89)
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository
java:364)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:30
7)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:16
2)
at kodo.jdbc.meta.MappingTool.validate(MappingTool.java:621)
at kodo.jdbc.meta.MappingTool.run(MappingTool.java:939)
at kodo.jdbc.meta.MappingTool.run(MappingTool.java:850)
at kodo.jdbc.meta.MappingTool.main(MappingTool.java:783)
Exception in thread "main"
Does Person have any concrete subclasses that map the id field to their
own table? Do other classes have relations to Person?
Similar Messages
-
Horizontal Mapping and Flat mapping with Metadata Value Indicator
Hi
I have an abstract class B which itself extends another abstract class A.
There is no table for A. The fields in A are mapped to B. I believe this
is called "horizontal mapping"
C and D inherit off B. There's a also a table named B (mapped to class B),
but none for C or D. Instances of C and D are recorded in table B. I
believe this is called "flat mapping"
B has a field foo whose possible values are 'fred' and 'wilma'.
If foo='fred', then the record is of type C
If foo='wilma', then the record is of type D
I believe this is called "class indicator" of type metadata.
To express this, I have package.jdo which says
<class name="A"/>
<class name="B" persistence-capable-superclass="A"/>
<class name="C" persistence-capable-superclass="B"/>
<class name="D" persistence-capable-superclass="B"/>
In B.mapping, I have
<mapping>
<package name="domain">
<class name="B">
<jdbc-class-map type="horizontal"/>
<jdbc-class-ind type="metadata-value" column="foo"/>
</class>
</package>
</mapping>
B.java has a private String foo.
In C.mapping, I have
<mapping>
<package name="domain">
<class name="C">
<jdbc-class-map type="flat"/>
<jdbc-class-ind-value value="fred"/>
field mappings for C
</class>
</package>
</mapping>
and similarly in D for value='wilma'
My questions are...
1. Is this kind of mapping supported by kodo?
2. If so, is this configuration correct? I guess not, since I don't
specify the table name anywhere. Where should it go?
3. If I remove the "class indicator" mapping and run a simple test I get
kodo.util.FatalUserException: There is no superclass mapping for mapping
for "class domain.D".
at
kodo.jdbc.meta.FlatClassMapping.assertParentMapping(FlatClassMapping.java:49)
at kodo.jdbc.meta.FlatClassMapping.getTable(FlatClassMapping.java:85)
at
kodo.jdbc.meta.OneToManyFieldMapping.fromMappingInfo(OneToManyFieldMapping.java:87)
at
kodo.jdbc.meta.RuntimeMappingProvider.getFieldMapping(RuntimeMappingProvider.java:160)
at
kodo.jdbc.meta.MappingRepository.getFieldMapping(MappingRepository.java:443)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapping.java:949)
4. If I run a simple test with the horizontal, flat and class-indicator
mappings, I get
kodo.jdbc.meta.MappingInfoNotFoundException: The "class-column"
attribute/extension for the class indicator on type
"domain.B.<class-indicator>" is missing or names a column that does not
exist.
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:135)
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:121)
at
kodo.jdbc.meta.ColumnClassIndicator.fromMappingInfo(ColumnClassIndicator.java:95)
at
kodo.jdbc.meta.RuntimeMappingProvider.initialize(RuntimeMappingProvider.java:135)
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository.java:378)
What am I doing wrong?
Thanks in advance
SriniI solved this problem by removing the identifier field from the
class/mapping (kodo support).
Thanks
Srini
Stephen Kim wrote:
Do you have two fields mapped to the same column? Did you make sure you
set everything which maps to the column?
Srinivasan Ranganathan wrote:
I found what was wrong with this, fixed it and got a different (more
sensible) error. To correct this mapping, I specified B's mapping type as
"base" and gave its table and pk names. Also, I moved the common field
mappings to B.mapping so C.mapping and D.mapping only have fields that are
specific to each.
Now when I run a simple test, I get
testC:
kodo.util.FatalUserException: Attempt to set column "B.FOO" to two
different values: (java.lang.Object)"java.lang.Object@2f608ac2",
(java.lang.String)"fred" This can occur when you fail to set both sides of
a two-sided relation between objects, or when you map different fields to
the same column, but you do not keep the values of these fields in synch.
at kodo.jdbc.runtime.VRow.setObjectInternal(VRow.java(Compiled Code))
at kodo.jdbc.sql.AbstractRow.setObject(AbstractRow.java(Compiled Code))
at
kodo.jdbc.meta.ColumnClassIndicator.insert(ColumnClassIndicator.java:143)
at kodo.jdbc.runtime.UpdateManagerImpl.insert(UpdateManagerImpl.java:216)
at kodo.jdbc.runtime.UpdateManagerImpl.insert(UpdateManagerImpl.java:219)
at kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:108)
at kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:73)
testD:
kodo.util.FatalUserException: Attempt to set column "B.FOO" to two
different values: (java.lang.Object)"java.lang.Object@2f608ac2",
(java.lang.String)"wilma" This can occur when you fail to set both sides
of a two-sided relation between objects, or when you map different fields
to the same column, but you do not keep the values of these fields in
synch.
at kodo.jdbc.runtime.VRow.setObjectInternal(VRow.java(Compiled Code))
at kodo.jdbc.sql.AbstractRow.setObject(AbstractRow.java(Compiled Code))
at
kodo.jdbc.meta.ColumnClassIndicator.insert(ColumnClassIndicator.java:143)
at kodo.jdbc.runtime.UpdateManagerImpl.insert(UpdateManagerImpl.java:216)
at kodo.jdbc.runtime.UpdateManagerImpl.insert(UpdateManagerImpl.java:219)
at kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:108)
at kodo.jdbc.runtime.UpdateManagerImpl.flush(UpdateManagerImpl.java:73)
I've checked for the two possible errors to the best of my knowledge. Any
input to resolve this issue is appreciated.
Thanks in advance
Srini
Srinivasan Ranganathan wrote:
Hi
I have an abstract class B which itself extends another abstract class A.
There is no table for A. The fields in A are mapped to B. I believe this
is called "horizontal mapping"
C and D inherit off B. There's a also a table named B (mapped to class B),
but none for C or D. Instances of C and D are recorded in table B. I
believe this is called "flat mapping"
B has a field foo whose possible values are 'fred' and 'wilma'.
If foo='fred', then the record is of type C
If foo='wilma', then the record is of type D
I believe this is called "class indicator" of type metadata.
To express this, I have package.jdo which says
<class name="A"/>
<class name="B" persistence-capable-superclass="A"/>
<class name="C" persistence-capable-superclass="B"/>
<class name="D" persistence-capable-superclass="B"/>
In B.mapping, I have
<mapping>
<package name="domain">
<class name="B">
<jdbc-class-map type="horizontal"/>
<jdbc-class-ind type="metadata-value" column="foo"/>
</class>
</package>
</mapping>
B.java has a private String foo.
In C.mapping, I have
<mapping>
<package name="domain">
<class name="C">
<jdbc-class-map type="flat"/>
<jdbc-class-ind-value value="fred"/>
field mappings for C
</class>
</package>
</mapping>
and similarly in D for value='wilma'
My questions are...
1. Is this kind of mapping supported by kodo?
2. If so, is this configuration correct? I guess not, since I don't
specify the table name anywhere. Where should it go?
3. If I remove the "class indicator" mapping and run a simple test I get
kodo.util.FatalUserException: There is no superclass mapping for mapping
for "class domain.D".
at
kodo.jdbc.meta.FlatClassMapping.assertParentMapping(FlatClassMapping.java:49)
at kodo.jdbc.meta.FlatClassMapping.getTable(FlatClassMapping.java:85)
at
kodo.jdbc.meta.OneToManyFieldMapping.fromMappingInfo(OneToManyFieldMapping.java:87)
>>
at
kodo.jdbc.meta.RuntimeMappingProvider.getFieldMapping(RuntimeMappingProvider.java:160)
>>
at
kodo.jdbc.meta.MappingRepository.getFieldMapping(MappingRepository.java:443)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapping.java:949)
>>
>>
>>
>>
4. If I run a simple test with the horizontal, flat and class-indicator
mappings, I get
kodo.jdbc.meta.MappingInfoNotFoundException: The "class-column"
attribute/extension for the class indicator on type
"domain.B.<class-indicator>" is missing or names a column that does not
exist.
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:135)
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:121)
at
kodo.jdbc.meta.ColumnClassIndicator.fromMappingInfo(ColumnClassIndicator.java:95)
>>
at
kodo.jdbc.meta.RuntimeMappingProvider.initialize(RuntimeMappingProvider.java:135)
>>
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository.java:378)
>>
>>
>>
What am I doing wrong?
Thanks in advance
Srini
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com -
Horizontal mapping + embedded one-to-one problem
Hi,
this message corresponds to the article "Embedded One-to-One mapping
problem". But this article is more exactly then the first without less
unnessary information.
I got an abstract super-class Person which is mapped horizontal.
Student inherits from Person.
Person contains an attribute called location(instance of Class Location)
which should be mapped "embedded one-to-one".
Since Person is mapped horizontal no table will be used for Person.
I get following exception when running mappingtool on action "buildSchema"
kodo.jdbc.meta.MappingInfoNotFoundException: No mapping information was
found for "xxx.yyy.zzz.persistence.jdo.business.Location.lat"
I think Kodo tries to map the field "location" since the field is declared
as embedded. But it can not embed the field since Person is horizontal
mapped and no table for Person exists where the corresponding field of
Location could be placed in. Also it is not possible to set the "embedded"
attribute in the subclass Student for the field "location" because it must
be specified in the superclass.
Can you help me ?
Thanks a lot,
Felix
Additional information:
=======================
Exception stack trace:
[mappingtool] kodo.jdbc.meta.MappingInfoNotFoundException: No mapping
information was found for "xxx.yyy.zzz.persistence.jdo.business.Location".
[mappingtool] at
kodo.jdbc.meta.RuntimeMappingProvider.getMapping(RuntimeMappingProvider.java:44)
[mappingtool] at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository.java:352)
[mappingtool] at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:307)
[mappingtool] at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:162)
[mappingtool] at
kodo.jdbc.meta.MappingTool.buildSchema(MappingTool.java:646)
[mappingtool] at kodo.jdbc.meta.MappingTool.run(MappingTool.java:951)
[mappingtool] at
kodo.jdbc.ant.MappingToolTask.executeOn(MappingToolTask.java:175)
[mappingtool] at com.solarmetric.ant.TaskBase.execute(TaskBase.java:105)
[mappingtool] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
[mappingtool] at org.apache.tools.ant.Task.perform(Task.java:364)
[mappingtool] at org.apache.tools.ant.Target.execute(Target.java:301)
[mappingtool] at
org.apache.tools.ant.Target.performTasks(Target.java:328)
[mappingtool] at
org.apache.tools.ant.Project.executeTarget(Project.java:1215)
[mappingtool] at
org.apache.tools.ant.Project.executeTargets(Project.java:1063)
[mappingtool] at org.apache.tools.ant.Main.runBuild(Main.java:632)
[mappingtool] at org.apache.tools.ant.Main.startAnt(Main.java:183)
[mappingtool] at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
[mappingtool] at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
Here is the JDO-Metadata:
<?xml version="1.0" encoding="UTF-8"?>
<jdo>
<package name="xxx.yyy.zzz.persistence.jdo.business">
<class name="Location"/>
<class name="Person" identity-type="application"
objectid-class="PersonId">
<field name="location" embedded="true"/>
<field name="id" primary-key="true"/>
</class>
<class name="Student" identity-type="application"
persistence-capable-superclass="Person"/>
</package>
</jdo>
Here is the mapping-metadata:
<?xml version="1.0" encoding="UTF-8"?>
<mapping>
<package name="xxx.yyy.zzz.persistence.jdo.business">
<class name="Person">
<jdbc-class-map type="horizontal"/>
</class>
<class name="Student">
<jdbc-class-map type="base" table="STUDENT"/>
<jdbc-version-ind type="version-number" column="JDOVERSION"/>
<jdbc-class-ind type="in-class-name" column="JDOCLASS"/>
<field name="Person.birthDate">
<jdbc-field-map type="value" column="BIRTHDATE"/>
</field>
<field name="Person.city">
<jdbc-field-map type="value" column="CITY"/>
</field>
<field name="Person.id">
<jdbc-field-map type="value" column="ID"/>
</field>
<field name="Person.location">
<jdbc-field-map type="embedded"
null-ind-column="NULL_INDICATOR" synthetic="false">
<field name="lat">
<jdbc-field-map type="value" column="LATITUDE"/>
</field>
<field name="lon">
<jdbc-field-map type="value" column="LONGITUDE"/>
</field>
</jdbc-field-map>
</field>
<field name="Person.name">
<jdbc-field-map type="value" column="NAME"/>
</field>
<field name="Person.picture">
<jdbc-field-map type="value" column="PICTURE"/>
</field>
<field name="Person.state">
<jdbc-field-map type="value" column="STATE"/>
</field>
<field name="Person.street">
<jdbc-field-map type="value" column="STREET"/>
</field>
<field name="Person.zipcode">
<jdbc-field-map type="value" column="ZIPCODE"/>
</field>
</class>
<class name="Location">
<jdbc-class-map type="none"/>
<field name="lat">
<jdbc-field-map type="none"/>
</field>
<jdbc-class-map type="none"/>
<field name="lon">
<jdbc-field-map type="none"/>
</field>
</class>
</package>
</mapping>
Here are the class definitions:
Class Location:
public class Location {
private int lat;
private int lon;
Class Person:
public abstract class Person {
private int id;
private String name;
private String street;
private String city;
private String state;
private String zipcode;
private Date birthDate;
private String picture;
private Location location;
Class Person:
public class Student extends Person {You'll probably have much better luck sending this question to
[email protected]; the newsgroup is generally for quick questions
about certain features or problems the community might be able to solve
without input from SolarMetric developers. -
Horizontal mapping not working in Kodo 4.1.2
Hello,
I am having troubles in trying to get the class mapping I want in Kodo 4.1.2.
I want to go from Kodo 3.3 to Kodo 4.1, and still in the evaluation process. Basically, all I want is to have my package.jdo files to work in Kodo 4.1, with the minimum modifications, before moving to JPA.
The mapping is defined is my package.jdo using the <extension vendor-name="kodo" key="jdbc-class-map" value="XXX"/> where XXX can be one of horizontal, base or flat (I dont use vertical in this applicaion). This element does not seem to be properly recognized by the new mapping tool, and all my classes are mapped in the same base table.
After some digging in the docs and in the examples provided, I found this <inheritance strategy="XXX"/> element, that can be put in my package.jdo file. This is not clearly said in the docs (it seems this element is only mentionned in the new orm DTD), but is used in the sample/jdo/horizontal/package.jdo file.
Then I modified my package.jdo files, with this new element, where XXX is one of subclass-table, new-table (with no <join/> nested element) or superclass-table. But the result is not the one expected : all the classes are mapped in the same table.
I then gave a try at the example provided, compiled, enhanced and mapped the sample/jdo/horizontal classes provided with the distribution, since this example covers exactly what I want to do. It seems to me that this example does not work either.
The package.jdo says :
<jdo>
<package name="samples.jdo.horizontal">
<sequence name="sjvm" factory-class="sjvm" strategy="nontransactional"/>
<class name="LastModified">
<inheritance strategy="subclass-table"/>
</class>
The mapping file I get says :
<mapping>
<package name="samples.jdo.horizontal">
<class name="LastModified">
<jdbc-class-map type="base" pk-column="ID" table="LASTMODIFIED"/>
<jdbc-version-ind type="version-number" column="VERSN"/>
<jdbc-class-ind type="in-class-name" column="TYP"/>
<field name="creationDate">
<jdbc-field-map type="value" column="CREATIONDATE"/>
</field>
<field name="lastModificationDate">
<jdbc-field-map type="value" column="LASTMODIFICATIONDATE"/>
</field>
</class>
The enhancement is made using jdoc, the mapping file is generated using the following command line (the DB is empty) :
mappingtool -a refresh -f mapping.xml samples.jdo.horizontal.LastModifiedI would expect an horizontal mapping, with a class element containing only a <jdbc-class-map type="horizontal"/> element, as it is the case if I use my Kodo 3.3 mapping tool.
I tried the enhancement / mapping file generation process with two configuration of the kodo.properties file : the first one with kodo3 as the Mapping Factory and the second with jdo. The result is the same in both cases. I verified by setting the log level to TRACE for the Tool what the factory used. In fact in both case, it is the MappingFileDeprecatedJDOMappingFactory, which seems weird to me.
Bytheway, setting the MappingFactory to jpa leads to the following IllegalArgumentException during enhancement :
Exception in thread "main" org.apache.openjpa.lib.util.ParseException: Instantiation of plugin "MetaDataFactory" with value "jpa" caused an error "java.lang.IllegalArgumentException : java.lang.ClassNotFoundException: jpa". The alias or class name may have been misspelled, or the class may not have be available in the class path. Valid aliases for this plugin are: [jdo, kodo3]
I'd be glad to get any hint if I'm wrong on anything, or any workaround / patch to get my case to work.
Thank you in advance,
JoseIf the same exact app and code works with 4.0 with the same ForeignKeyDeleteAction setting, I suggest that you open a case with support.
This property hasn't changed since 4.0
http://e-docs.bea.com/kodo/docs41/full/html/ref_guide_mapping_defaults.html
Laurent -
About Horizontal mapping !!!
Hello,
I want to use the horizontal mapping, I have read the documentation
several times but no succes until now !!!
I have managed to use the vertical one and it worked...
I did add this line in yhe kodo property file:
kodo.jdbc.SubclassMapping: vertical
Then in order to use the horizontal mapping I tried to add this line:
kodo.jdbc.SubclassMapping: horizontal ---> but it did not work.
then I tried to do this in my package.jdo file:
<class name="Customer" identity-type="datastore"
persistence-capable-uperclass="Person">
<extension vendor-name="kodo" key="jdbc-class-map" value="horizontal"/>
</class>
but no succes ...
what I want is this:
I have those classes
class Person
private String first_name;
private String last_name
class Customer extends Person
private String city;
private String country;
I want a mapping that associate on table to a class as following:
table person:
first_name
last_name
table Customer:
first_name
last_name
city
country
Can you tell what can I do please !!!
I have red the doc but I can find it out ...
thank a lot for your help
smailhello,
Are you sure ?
because in your docs it is mentioned that you support it.
go to this link :
http://docs.solarmetric.com/manual.html#ref_guide_mapping_classmapping
it is explained there !
thanks,
smail -
Horizontal mapping with inverse-owner doesn't work
Hi,
We encountered a problem of using inverse-owner with horizontal mapping.
Here is the example.
public abstract class A {
//collection of class T
private Set ts = new HashSet()
public class B extends A {
private String name;
public class T {
private A owner;
private String text;
we use metadata factory. package.jdo looks like this.
<class name="T"/>
<class name="A">
<extension vendor-name="kodo" key="jdbc-class-map" value="horizontal"/>
<field name="ts">
<collection element-type="T"/>
<extension vendor-name="kodo" key="inverse-owner"
value="owner"/>
</field>
</class>
<class name="B" persistence-capable-superclass="A">
</class>
mappingtool gives java.lang.ClassCastException
at kodo.jdbc.meta.OneToManyFieldMapping.map(OneToManyFieldMapping.java:126)Fred-
This is a bug in the automatic generation of mappings. See:
http://bugzilla.solarmetric.com/show_bug.cgi?id=1096
Note this this bug only seems to apply to the automatic generation of
mappings: if you manually compose the .mapping file, then you can
express the one-many mapping (provided you can cast it down to a single
concrete type with the "type" extension).
See the bug report page for an example mapping file solution.
In article <[email protected]>, Fred Chen wrote:
Hi,
When using horizontal mappings, you cannot have an inverse type relation
to a horizontally mapped class (there is no table to hold the
inverse!)But that is precisely why we want to use the inverse mapping (to AVOID the
unecessary middle table). Can you explain in a bit more detail why this is
not supported?
Thanks,
Fred
"Stephen Kim" <[email protected]> wrote in message
news:[email protected]...
When using horizontal mappings, you cannot have an inverse type relation
to a horizontally mapped class (there is no table to hold the
inverse!). However, if you have a concrete type that it is always
mapped to, you can indicate that using the type and element-type
extensions to override the Java declarations to the concrete mapped type.
Fred Chen wrote:
Hi,
We encountered a problem of using inverse-owner with horizontal mapping.
Here is the example.
public abstract class A {
//collection of class T
private Set ts = new HashSet()
public class B extends A {
private String name;
public class T {
private A owner;
private String text;
we use metadata factory. package.jdo looks like this.
<class name="T"/>
<class name="A">
<extension vendor-name="kodo" key="jdbc-class-map" value="horizontal"/>
<field name="ts">
<collection element-type="T"/>
<extension vendor-name="kodo" key="inverse-owner"
value="owner"/>
</field>
</class>
<class name="B" persistence-capable-superclass="A">
</class>
mappingtool gives java.lang.ClassCastException
at
kodo.jdbc.meta.OneToManyFieldMapping.map(OneToManyFieldMapping.java:126)
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com
Marc Prud'hommeaux
SolarMetric Inc. -
Horizontal mapping base class query
Greetings,
I have a class hierarchy which looks like the following:
abstract class A {
int num;
class B extends A
class C extends A
class D extends A
This hierarchy is horizontally mapped. Say I want to run the following query. Give me the 10 objects of type A (either B,C or D practically) with the highest num. I would run the following query:
Query query = pm.newQuery("select from A.class range 0, 10");
query.setOrdering("num descending");
I would expect this query to return a maximum of 10 results. It in fact returns up to 30 results, i.e. 10 per subclass type. What is wrong in the structure of the query or my classes? Is this expected behaviour and does anyone know how I may remedy this situation?
Thanks in advance,
Adam.David-
Did I understand that correctly?You are correct.
If so, why does this limitation exist?It is because a proper relation cannot exist in the database if the
target table is unknown (which it is for horizontally mapped classes),
and joins would become tremendously complex or, in some cases, simply
impossible to accomplish with a single SQL statement.
We are considering adding some support for querying across horizontal
relations that are using non-composite primary keys, but it is currently
not possible.
In article <d3eig3$ssb$[email protected]>, David Ezzio wrote:
Hi guys,
Suppose that we have the following inheritance structure:
Class: LegalEntity
Field: LegalEntity relatedTo
Field: String name
Class: Person extends LegalEntity
Field: String ssn
Class: Corporation extends LegalEntity
Field: String location
Class: CollegeStudent extends Person
Field: String school
Class: Employee extends Person
Field: Corporation company
If a flat mapping is used throughout, then we end up with one table
(LEGALENTITY) with the columns: relatedTo, name, ssn, location, school,
and company, plus the Kodo created jdo columns.
If we wanted to create several tables, we could map LegalEntity and
Person horizontally, making the base tables COLLEGESTUDENT, EMPLOYEE,
and CORPORATION.
If I understand section 7.6.4.3 correctly, the value stored in the
relatedto column will be a stringified object identity, and Kodo does
does not support queries across this relation. Thus, the query find all
CollegeStudent objects that satisfies the filter "relatedTo.name ==
\"Sally\"" is not supported.
Did I understand that correctly?
If so, why does this limitation exist?
David
Marc Prud'hommeaux
SolarMetric Inc. -
Internal exception with horizontal mapping
When two horizontally mapped classes stored with the same ID system comits
work to database and the throws internal exception. As result corrupt data
is saved which can not be read back
1469 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 20089978> [0 ms]
executing prepstmnt 3972145 SELECT DISTINCT JDO_CLASS FROM TEST.CONTRACT
1500 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 24257622> [0 ms]
executing prepstmnt 9649099 SELECT t0.JDO_CLASS, t0.JDO_LOCK FROM
TEST.CONTRACT t0 WHERE t0.CONTRACT_ID = ? [params=(long) 1]
1563 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 30008954> [0 ms]
executing prepstmnt 10233621 INSERT INTO TEST.ORGANIZATION (ACRONYM,
CONTRACT_ID, JDO_CLASS, JDO_LOCK, NAME, ORG_ID) VALUES (?, ?, ?, ?, ?, ?)
[params=(null) null, (long) 1, (String) com.peacetech.test.jdo.Organization,
(int) 0, (null) null, (long) 3]
1563 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 30008954> [0 ms]
executing prepstmnt 3823508 INSERT INTO TEST.PERSON (CONTRACT_ID, JDO_CLASS,
JDO_LOCK, NAME, NICK_NAME, ORG_ID, PERSON_ID) VALUES (?, ?, ?, ?, ?, ?, ?)
[params=(long) 1, (String) com.peacetech.test.jdo.Person, (int) 0, (null)
null, (null) null, (long) 3, (long) 3]
1563 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 30008954> [0 ms]
executing prepstmnt 4973260 INSERT INTO TEST.POST (CONTRACT_ID, JDO_CLASS,
JDO_LOCK, NAME, ORG_ID, POST_ID, TITLE) VALUES (?, ?, ?, ?, ?, ?, ?)
[params=(long) 1, (String) com.peacetech.test.jdo.Post, (int) 0, (null)
null, (long) 3, (long) 3, (null) null]
1594 TRACE [main] kodo.Runtime - An exception occurred while ending the
transaction. This exception will be re-thrown.
kodo.util.FatalInternalException: 3 :: 3:kodo.runtime.PNonTransState@129b0e1
:: 3:kodo.runtime.PNonTransState@129b0e1
at
kodo.runtime.PersistenceManagerImpl.setStateManager(PersistenceManagerImpl.j
ava:3314)
at kodo.runtime.StateManagerImpl.commit(StateManagerImpl.java:737)
at
kodo.runtime.PersistenceManagerImpl.endTransaction(PersistenceManagerImpl.ja
va:1103)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:842)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:86)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
1594 TRACE [main] kodo.Runtime - An exception occurred while ending the
transaction. This exception will be re-thrown.
kodo.util.UserException: Can only perform operation while a transaction is
active.
at
kodo.runtime.PersistenceManagerImpl.assertActiveTransaction(PersistenceManag
erImpl.java:3602)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:840)
at kodo.runtime.LocalManagedRuntime.rollback(LocalManagedRuntime.java:125)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:101)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
1594 TRACE [main] kodo.Runtime - An exception occurred while ending the
transaction. This exception will be re-thrown.
kodo.util.FatalInternalException: 3 :: 3:kodo.runtime.PNonTransState@129b0e1
:: 3:kodo.runtime.PNonTransState@129b0e1
at
kodo.runtime.PersistenceManagerImpl.setStateManager(PersistenceManagerImpl.j
ava:3314)
at kodo.runtime.StateManagerImpl.commit(StateManagerImpl.java:737)
at
kodo.runtime.PersistenceManagerImpl.endTransaction(PersistenceManagerImpl.ja
va:1103)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:842)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:86)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Exception in thread "main" kodo.util.FatalInternalException: 3 ::
3:kodo.runtime.PNonTransState@129b0e1 ::
3:kodo.runtime.PNonTransState@129b0e1
at
kodo.runtime.PersistenceManagerImpl.setStateManager(PersistenceManagerImpl.j
ava:3314)
at kodo.runtime.StateManagerImpl.commit(StateManagerImpl.java:737)
at
kodo.runtime.PersistenceManagerImpl.endTransaction(PersistenceManagerImpl.ja
va:1103)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:842)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:86)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
..java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Process terminated with exit code 1Note that this bug is reported at:
http://bugzilla.solarmetric.com/show_bug.cgi?id=940
Currently, the only solution is to ensure that you are using globally
unique IDs. One good way of doing this is to use an application identity
hierarchy that mirrors the hierarchy of the persistent classes, as
described in the documentation at:
http://docs.solarmetric.com/manual.html#horizontal_caveats.
In article <[email protected]>, Alex Roytman wrote:
When two horizontally mapped classes stored with the same ID system comits
work to database and the throws internal exception. As result corrupt data
is saved which can not be read back
1469 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 20089978> [0 ms]
executing prepstmnt 3972145 SELECT DISTINCT JDO_CLASS FROM TEST.CONTRACT
1500 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 24257622> [0 ms]
executing prepstmnt 9649099 SELECT t0.JDO_CLASS, t0.JDO_LOCK FROM
TEST.CONTRACT t0 WHERE t0.CONTRACT_ID = ? [params=(long) 1]
1563 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 30008954> [0 ms]
executing prepstmnt 10233621 INSERT INTO TEST.ORGANIZATION (ACRONYM,
CONTRACT_ID, JDO_CLASS, JDO_LOCK, NAME, ORG_ID) VALUES (?, ?, ?, ?, ?, ?)
[params=(null) null, (long) 1, (String) com.peacetech.test.jdo.Organization,
(int) 0, (null) null, (long) 3]
1563 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 30008954> [0 ms]
executing prepstmnt 3823508 INSERT INTO TEST.PERSON (CONTRACT_ID, JDO_CLASS,
JDO_LOCK, NAME, NICK_NAME, ORG_ID, PERSON_ID) VALUES (?, ?, ?, ?, ?, ?, ?)
[params=(long) 1, (String) com.peacetech.test.jdo.Person, (int) 0, (null)
null, (null) null, (long) 3, (long) 3]
1563 TRACE [main] kodo.jdbc.SQL - <t 20688146, conn 30008954> [0 ms]
executing prepstmnt 4973260 INSERT INTO TEST.POST (CONTRACT_ID, JDO_CLASS,
JDO_LOCK, NAME, ORG_ID, POST_ID, TITLE) VALUES (?, ?, ?, ?, ?, ?, ?)
[params=(long) 1, (String) com.peacetech.test.jdo.Post, (int) 0, (null)
null, (long) 3, (long) 3, (null) null]
1594 TRACE [main] kodo.Runtime - An exception occurred while ending the
transaction. This exception will be re-thrown.
kodo.util.FatalInternalException: 3 :: 3:kodo.runtime.PNonTransState@129b0e1
:: 3:kodo.runtime.PNonTransState@129b0e1
at
kodo.runtime.PersistenceManagerImpl.setStateManager(PersistenceManagerImpl.j
ava:3314)
at kodo.runtime.StateManagerImpl.commit(StateManagerImpl.java:737)
at
kodo.runtime.PersistenceManagerImpl.endTransaction(PersistenceManagerImpl.ja
va:1103)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:842)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:86)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
1594 TRACE [main] kodo.Runtime - An exception occurred while ending the
transaction. This exception will be re-thrown.
kodo.util.UserException: Can only perform operation while a transaction is
active.
at
kodo.runtime.PersistenceManagerImpl.assertActiveTransaction(PersistenceManag
erImpl.java:3602)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:840)
at kodo.runtime.LocalManagedRuntime.rollback(LocalManagedRuntime.java:125)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:101)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
1594 TRACE [main] kodo.Runtime - An exception occurred while ending the
transaction. This exception will be re-thrown.
kodo.util.FatalInternalException: 3 :: 3:kodo.runtime.PNonTransState@129b0e1
:: 3:kodo.runtime.PNonTransState@129b0e1
at
kodo.runtime.PersistenceManagerImpl.setStateManager(PersistenceManagerImpl.j
ava:3314)
at kodo.runtime.StateManagerImpl.commit(StateManagerImpl.java:737)
at
kodo.runtime.PersistenceManagerImpl.endTransaction(PersistenceManagerImpl.ja
va:1103)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:842)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:86)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Exception in thread "main" kodo.util.FatalInternalException: 3 ::
3:kodo.runtime.PNonTransState@129b0e1 ::
3:kodo.runtime.PNonTransState@129b0e1
at
kodo.runtime.PersistenceManagerImpl.setStateManager(PersistenceManagerImpl.j
ava:3314)
at kodo.runtime.StateManagerImpl.commit(StateManagerImpl.java:737)
at
kodo.runtime.PersistenceManagerImpl.endTransaction(PersistenceManagerImpl.ja
va:1103)
at
kodo.runtime.PersistenceManagerImpl.afterCompletion(PersistenceManagerImpl.j
ava:842)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:86)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
com.peacetech.test.jdo.TestJDOHelper.commitTransaction(TestJDOHelper.java:40
at com.peacetech.test.HorizontalTest.insert(HorizontalTest.java:57)
at com.peacetech.test.HorizontalTest.main(HorizontalTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:495)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Process terminated with exit code 1
Marc Prud'hommeaux
SolarMetric Inc. -
Horizontal mapping and query limitation
Hi guys,
Suppose that we have the following inheritance structure:
Class: LegalEntity
Field: LegalEntity relatedTo
Field: String name
Class: Person extends LegalEntity
Field: String ssn
Class: Corporation extends LegalEntity
Field: String location
Class: CollegeStudent extends Person
Field: String school
Class: Employee extends Person
Field: Corporation company
If a flat mapping is used throughout, then we end up with one table
(LEGALENTITY) with the columns: relatedTo, name, ssn, location, school,
and company, plus the Kodo created jdo columns.
If we wanted to create several tables, we could map LegalEntity and
Person horizontally, making the base tables COLLEGESTUDENT, EMPLOYEE,
and CORPORATION.
If I understand section 7.6.4.3 correctly, the value stored in the
relatedto column will be a stringified object identity, and Kodo does
does not support queries across this relation. Thus, the query find all
CollegeStudent objects that satisfies the filter "relatedTo.name ==
\"Sally\"" is not supported.
Did I understand that correctly?
If so, why does this limitation exist?
DavidDavid-
Did I understand that correctly?You are correct.
If so, why does this limitation exist?It is because a proper relation cannot exist in the database if the
target table is unknown (which it is for horizontally mapped classes),
and joins would become tremendously complex or, in some cases, simply
impossible to accomplish with a single SQL statement.
We are considering adding some support for querying across horizontal
relations that are using non-composite primary keys, but it is currently
not possible.
In article <d3eig3$ssb$[email protected]>, David Ezzio wrote:
Hi guys,
Suppose that we have the following inheritance structure:
Class: LegalEntity
Field: LegalEntity relatedTo
Field: String name
Class: Person extends LegalEntity
Field: String ssn
Class: Corporation extends LegalEntity
Field: String location
Class: CollegeStudent extends Person
Field: String school
Class: Employee extends Person
Field: Corporation company
If a flat mapping is used throughout, then we end up with one table
(LEGALENTITY) with the columns: relatedTo, name, ssn, location, school,
and company, plus the Kodo created jdo columns.
If we wanted to create several tables, we could map LegalEntity and
Person horizontally, making the base tables COLLEGESTUDENT, EMPLOYEE,
and CORPORATION.
If I understand section 7.6.4.3 correctly, the value stored in the
relatedto column will be a stringified object identity, and Kodo does
does not support queries across this relation. Thus, the query find all
CollegeStudent objects that satisfies the filter "relatedTo.name ==
\"Sally\"" is not supported.
Did I understand that correctly?
If so, why does this limitation exist?
David
Marc Prud'hommeaux
SolarMetric Inc. -
Hello,
I have and Person, Post and Organization extending Party class. I map
Person, Post and Organization class each on its own table
Now Person and Organization have a bi-directional association with each
other (via inverted relation) - Organization has a collection of Persons
and Person references back to Organization
I would like to know how Kodo will fetch persons for a given organization.
Will Kodo optimize SQL to not to attempts to query all tables of
implementations of Party when fetching relation expressed on specific
subclasses - Organization and Person in this case
Could you please post some details on horizontal mapping rules and what
cases are the most expansive in terms of SQL and performance and if there
are any limitations as far as eager fetching is concerned
Thank you
AlexAlex,
Things only get complex if you have relations to the virtual class --
Party, in this case.
If you declare a field to be a relation to a subclass, Kodo won't
attempt to look in the other subclass tables.
If you query on Party, Kodo will issue three queries -- one for Person,
one for Post, and one for Organization. This is analgous to Kodo's
support for queries on interfaces.
Declaring a relation to Party will be the most expensive, as Kodo will
not be able to do the join on the database side, but will have to bring
the OID(s) into the JVM and then do the lookup from there.
-Patrick
Alex Roytman wrote:
Hello,
I have and Person, Post and Organization extending Party class. I map
Person, Post and Organization class each on its own table
Now Person and Organization have a bi-directional association with each
other (via inverted relation) - Organization has a collection of Persons
and Person references back to Organization
I would like to know how Kodo will fetch persons for a given organization.
Will Kodo optimize SQL to not to attempts to query all tables of
implementations of Party when fetching relation expressed on specific
subclasses - Organization and Person in this case
Could you please post some details on horizontal mapping rules and what
cases are the most expansive in terms of SQL and performance and if there
are any limitations as far as eager fetching is concerned
Thank you
Alex -
Transformation in BI 7.0 - vertical to horizontal mapping
Hi,
We are downloading infocube data to a flat file/excel file through infospoke functionality. As this file used in R/3 for upload using BDC. But the problem in file format, unable to map month fields in horizontal way (each month should be a column) here is situation:
We have infocube data
Mat1 Plant Month1 Qty1
Mat1 Plant Month2 Qty2
Mat1 Plant Month3 Qty3
Mat1 Plant Month36 qty36
Downloaded Excel file/Text file format should be:
Mat1 Plant Qty1 Qty2 Qty3 Qty4.......Qty36
Mat2 Plant2 Qty1 Qty2 Qty3 .............Qty36
Qty1 column is month1 etc.
Is there way to map infocube data this way. Any pointer are helpful
Thanks,
BKNHi BKN,
try the below pseudocode in expert routine of your transformation....
data: it_res type table of result_package,
wa_res type result_package.
loop at source_package.
read table it_res into wa_res with key mat eq source_package-mat
plant eq source_package-plant.
if sy-subrc eq 0.
if source_package-month eq 1.
wa_res-k1 = source_package-qty.
else if source_package-month eq 2.
wa_res-k2 = source_package-qty.
........ continue this based on ur req and the no of fields u have.
endif.
modify it_res from wa_res.
else.
clear wa_res.
wa_res-mat = source_pacakge-mat.
wa_res-plant = source_pacakge-plant.
if source_package-month eq 1.
wa_res-k1 = source_package-qty.
else if source_package-month eq 2.
wa_res-k2 = source_package-qty.
........ continue this based on ur req and the no of fields u have.
endif.
append wa_res to it_res.
endif.
endloop.
move it_res[] to result_package.
Regards,
Matt
Edited by: Matt Prior on Dec 4, 2008 10:41 PM -
Horizontal mapping & mapping tool
Hi,
Can MappingTool populate mapping data, given only jdo metadata?
Example follows:
<jdo>
<package name="com.bear.fi.tradehub.domain.test">
<class name="BaseJDO" identity-type="datastore">
<extension vendor-name="kodo" key="jdbc-class-map"
value="horizontal"/>
<field name="a" persistence-modifier="persistent"/>
</class>
</package>
</jdo>
// subclass SubOneJDO extends BaseJDO
<jdo>
<package name="com.bear.fi.tradehub.domain.test">
<class name="SubOneJDO" identity-type="datastore"
persistence-capable-superclass="com.bear.fi.tradehub.domain.test.BaseJDO">
<extension vendor-name="kodo" key="jdbc-class-map" value="base"/>
<field name="b" persistence-modifier="persistent"/>
</class>
</package>
</jdo>
When i run mapping tool on this metadata, i get table for SubOne created
and it has columns for a and b, as expected
However, mapping tool itself crashes with a null pointer exception and
fails to update mapping information in metadata.
kodo.util.FatalException: java.lang.NullPointerException
NestedThrowables:
java.lang.NullPointerException
at kodo.jdbc.meta.MappingTool.record(MappingTool.java:518)
at kodo.jdbc.meta.MappingTool.run(MappingTool.java:912)
at kodo.jdbc.meta.MappingTool.run(MappingTool.java:850)
at kodo.jdbc.meta.MappingTool.main(MappingTool.java:783)
Caused by: java.lang.NullPointerException
at
kodo.jdbc.meta.MetaDataMappingFactory.addExtensions(MetaDataMappingFactory.java:253)
at
kodo.jdbc.meta.MetaDataMappingFactory.addMappingExtensions(MetaDataMappingFactory.java:219)
at
kodo.jdbc.meta.MetaDataMappingFactory.storeMappings(MetaDataMappingFactory.java:162)
at kodo.jdbc.meta.MappingTool.record(MappingTool.java:481)
... 3 more
NestedThrowablesStackTrace:
java.lang.NullPointerException
at
kodo.jdbc.meta.MetaDataMappingFactory.addExtensions(MetaDataMappingFactory.java:253)
at
kodo.jdbc.meta.MetaDataMappingFactory.addMappingExtensions(MetaDataMappingFactory.java:219)
at
kodo.jdbc.meta.MetaDataMappingFactory.storeMappings(MetaDataMappingFactory.java:162)
at kodo.jdbc.meta.MappingTool.record(MappingTool.java:481)
at kodo.jdbc.meta.MappingTool.run(MappingTool.java:912)
at kodo.jdbc.meta.MappingTool.run(MappingTool.java:850)
at kodo.jdbc.meta.MappingTool.main(MappingTool.java:783)
Exception in thread "main"
Kodo being used is 3.1.0
Thanks,
EgidijusA stringified object ID is the reference of an object that has been converted to a string so that it may be stored in a text file. It is used for detached instances of persistent classes using datastore id.
Laurent -
HI,
I would like to ask for some solution in one of my objects. I need to map values to the target field in horizontal (left to right) positioning. The sample output would be like this..
Material QTY1 QTY2 QTY3 QTY4 QTY5
MAT1 5 6 5 8 9
MAT2 7 8 5 10 6
Input file would be look like this.
<Purchase_Order_Message>
<FUNCTIONAL_LOOP>
<LOOP_34>
<Item_Identifier_010>MAT1</Item_Identifier_010>
</LOOP_34>
<LOOP_37>
<Quantity_020>5</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>6</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>5</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>8</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>9</Quantity_020>
</LOOP_37>
</FUNCTIONAL_LOOP>
<FUNCTIONAL_LOOP>
<LOOP_34>
<Item_Identifier_010>MAT2</Item_Identifier_010>
</LOOP_34>
<LOOP_37>
<Quantity_020>7</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>8</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>5</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>10</Quantity_020>
</LOOP_37>
<LOOP_37>
<Quantity_020>6</Quantity_020>
</LOOP_37>
</FUNCTIONAL_LOOP>
</PURCHASE_ORDER_MESSAGE>
Could you help me to find ways to solve this issue. I am a bit running out of logic of ways what I can do for this mapping since it is using only one field from the selection and needs to be mapped horizontally.
Hope to hear from you gurus.
Thanks!Hi,
You target structure should look like
<root>
-<Details>
--<Materials>
--<QTY1>
--<QTY2>
--<QTY3>
--<QTY4>
--<QTY5>
--<QTY6>
Now duplicate Details once and map the constant values Material QTY1 QTY2 QTY3 QTY4 QTY5 to respective nodes and mapp Details to a constant.
Now to the duplicated Details do a one to one mapping between source fields and target fields.
In receiver side use File content Conversion and you will get the desired output
Regards
Suraj -
MappingInfoNotFoundException with one-many mapping to horizontal PC subclass
Hi,
I have a nasty niggling problem with a one-many mapping where the many
side is a horizontally-mapped persistent subclass:
kodo.util.FatalUserException: kodo.jdbc.meta.MappingInfoNotFoundException:
The reference mappings for one-to-many field "Invoice.openTrades" are not
in the table of the field's related persistent element
type.[Invoice.openTrades [kodo.jdbc.meta.OneToManyFieldMapping]]
at
kodo.runtime.PersistenceManagerImpl.attach(PersistenceManagerImpl.java:4363)...
NestedThrowablesStackTrace:
kodo.jdbc.meta.MappingInfoNotFoundException: The reference mappings for
one-to-many field "Invoice.openTrades" are not in the table of the field's
related persistent element type.[Invoice.openTrades
[kodo.jdbc.meta.OneToManyFieldMapping]]
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:134)
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:120)
at
kodo.jdbc.meta.OneToManyFieldMapping.fromMappingInfo(OneToManyFieldMapping.java:94)
at
kodo.jdbc.meta.RuntimeMappingProvider.getFieldMapping(RuntimeMappingProvider.java:198)
at
kodo.jdbc.meta.MappingRepository.getFieldMapping(MappingRepository.java:470)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapping.java:991)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapping.java:971)
at
kodo.jdbc.meta.AbstractClassMapping.getMappings(AbstractClassMapping.java:934)
at
kodo.jdbc.meta.AbstractClassMapping.getDeclaredFieldMappings(AbstractClassMapping.java:654)
at
kodo.jdbc.meta.AbstractClassMapping.resolve(AbstractClassMapping.java:796)
at kodo.jdbc.meta.MappingRepository.resolve(MappingRepository.java:431)
at kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:349)
at kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:177)
at
kodo.jdbc.meta.MappingRepository.getMetaData(MappingRepository.java:165)
at
kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:2423)
at
kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:2375)
at kodo.runtime.AttachManager.makePersistent(AttachManager.java:410)
at kodo.runtime.AttachManager.attach(AttachManager.java:279)
at kodo.runtime.AttachManager.attach(AttachManager.java:56)
at
kodo.runtime.PersistenceManagerImpl.attach(PersistenceManagerImpl.java:4349)
I have another one-many mapping on the "one" class which is fine and is
almost identical to the invalid mapping - it joins on the same
columns/foreign key. The only real difference is that my invalid "many"
side is a horizontally mapped subclass (parent class mapped to different
table). When I took that class out of its hierarchy and mapped it as base,
it works. I don't know why Kodo is saying the mapping for the join is not
found, as the "many" side has an invoice field mapped as one-one. The
superclass does not have a relation to invoice mapped. A slight
complication is that Invoice itself has a persistent superclass persisted
in the same table, but nothing refers to that so I don't think it is
relevant.
Class diagram is roughly like this:
BaseTrade
|
Invoice 1-* Trade
BaseReceipt
|
Invoice 1-* Receipt
Invoice mapped to Invoice table; Trade mapped to Trade table but its
superclass mapped to diff BaseTrade table; Receipt and its superclass
BaseReceipt mapped to Receipt table.
I saw an earlier posting on the same exception that mentioned "collection
element-type" - mine is specified as "Trade", ie the subclass.
Is there any reason why this should not work?
I can provide you with .jdo and .mapping files if necessary.
Many thanks,
AlexAlex-
Can you post your mapping? I just ran a test with a one-many relation to
a subclass of a horizontally mapped class, and it worked fine.
FYI, the example mapping I was using was:
<?xml version="1.0" encoding="UTF-8"?>
<mapping>
<package name="horizmany">
<class name="HorizManyOwner">
<jdbc-class-map type="base" pk-column="JDOID"
table="BUG1174OWNER"/>
<jdbc-version-ind type="version-number"
column="JDOVERSION"/>
<jdbc-class-ind type="in-class-name" column="JDOCLASS"/>
<field name="relation">
<jdbc-field-map type="one-many"
ref-column.JDOID="OWNER_JDOID" table="BUG1174RELATIONSUB"/>
</field>
</class>
<class name="HorizManyRelationSub">
<jdbc-class-map type="base" pk-column="JDOID"
table="BUG1174RELATIONSUB"/>
<jdbc-version-ind type="version-number"
column="JDOVERSION"/>
<jdbc-class-ind type="in-class-name" column="JDOCLASS"/>
<field name="horizmany.HorizManyRelationSuper.superString">
<jdbc-field-map type="value" column="SUPERSTRING"/>
</field>
<field name="owner">
<jdbc-field-map type="one-one"
column.JDOID="OWNER_JDOID"/>
</field>
<field name="subString">
<jdbc-field-map type="value" column="SUBSTRING0"/>
</field>
</class>
<class name="HorizManyRelationSuper">
<jdbc-class-map type="horizontal"/>
</class>
</package>
</mapping>
In article <[email protected]>, Alex Robbins wrote:
Hi,
I have a nasty niggling problem with a one-many mapping where the many
side is a horizontally-mapped persistent subclass:
kodo.util.FatalUserException: kodo.jdbc.meta.MappingInfoNotFoundException:
The reference mappings for one-to-many field "Invoice.openTrades" are not
in the table of the field's related persistent element
type.[Invoice.openTrades [kodo.jdbc.meta.OneToManyFieldMapping]]
at
kodo.runtime.PersistenceManagerImpl.attach(PersistenceManagerImpl.java:4363)...
NestedThrowablesStackTrace:
kodo.jdbc.meta.MappingInfoNotFoundException: The reference mappings for
one-to-many field "Invoice.openTrades" are not in the table of the field's
related persistent element type.[Invoice.openTrades
[kodo.jdbc.meta.OneToManyFieldMapping]]
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:134)
at kodo.jdbc.meta.Mappings.invalidMapping(Mappings.java:120)
at
kodo.jdbc.meta.OneToManyFieldMapping.fromMappingInfo(OneToManyFieldMapping.java:94)
at
kodo.jdbc.meta.RuntimeMappingProvider.getFieldMapping(RuntimeMappingProvider.java:198)
at
kodo.jdbc.meta.MappingRepository.getFieldMapping(MappingRepository.java:470)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapping.java:991)
at
kodo.jdbc.meta.AbstractClassMapping.getFieldMapping(AbstractClassMapping.java:971)
at
kodo.jdbc.meta.AbstractClassMapping.getMappings(AbstractClassMapping.java:934)
at
kodo.jdbc.meta.AbstractClassMapping.getDeclaredFieldMappings(AbstractClassMapping.java:654)
at
kodo.jdbc.meta.AbstractClassMapping.resolve(AbstractClassMapping.java:796)
at kodo.jdbc.meta.MappingRepository.resolve(MappingRepository.java:431)
at kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:349)
at kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:177)
at
kodo.jdbc.meta.MappingRepository.getMetaData(MappingRepository.java:165)
at
kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:2423)
at
kodo.runtime.PersistenceManagerImpl.makePersistent(PersistenceManagerImpl.java:2375)
at kodo.runtime.AttachManager.makePersistent(AttachManager.java:410)
at kodo.runtime.AttachManager.attach(AttachManager.java:279)
at kodo.runtime.AttachManager.attach(AttachManager.java:56)
at
kodo.runtime.PersistenceManagerImpl.attach(PersistenceManagerImpl.java:4349)
I have another one-many mapping on the "one" class which is fine and is
almost identical to the invalid mapping - it joins on the same
columns/foreign key. The only real difference is that my invalid "many"
side is a horizontally mapped subclass (parent class mapped to different
table). When I took that class out of its hierarchy and mapped it as base,
it works. I don't know why Kodo is saying the mapping for the join is not
found, as the "many" side has an invoice field mapped as one-one. The
superclass does not have a relation to invoice mapped. A slight
complication is that Invoice itself has a persistent superclass persisted
in the same table, but nothing refers to that so I don't think it is
relevant.
Class diagram is roughly like this:
BaseTrade
|
Invoice 1-* Trade
BaseReceipt
|
Invoice 1-* Receipt
Invoice mapped to Invoice table; Trade mapped to Trade table but its
superclass mapped to diff BaseTrade table; Receipt and its superclass
BaseReceipt mapped to Receipt table.
I saw an earlier posting on the same exception that mentioned "collection
element-type" - mine is specified as "Trade", ie the subclass.
Is there any reason why this should not work?
I can provide you with .jdo and .mapping files if necessary.
Many thanks,
Alex
Marc Prud'hommeaux
SolarMetric Inc. -
Character movement according to map?
hi guys
in my game there is a player(Actor) and the player is standing on a horizontally mapped tile...
my problem is i just want to move the player according to the tiles . the player is a set of frames using drawRegion i am drawing that player ..when i press right key he has to move right in a position wise manner
any pls give me a solution
***********here is my code***************
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class ExampleGameCanvas extends GameCanvas implements Runnable
private boolean isPlay; // Game Loop runs when isPlay is true
private long delay=8; // To give thread consistency
private int k;
private int counter=0;
private int xpos=50;
private int ypos=60;
private byte ROTATE_NONE = Sprite.TRANS_NONE;
private byte ROTATE_90 = Sprite.TRANS_ROT90;
private byte ROTATE_180= Sprite.TRANS_ROT180;
private byte ROTATE_270= Sprite.TRANS_ROT270;
private byte CURRENT_ROTATE=ROTATE_NONE;
private Image clwalk;
private Image tilesImg,bottomboard,clownIdle; //Image varibale declaration-kris
private int clwalkXstart=0;
private int clnX=0;
private int tileXPos = 0;
private int tileYPos = 150;
private byte tileWidth = 21;
private byte tileHeight = 21;
private int tileStartXPosition = 0;
private int tileStartYPosition = 0;
private int numberOfRows = 12;
private int numberOfColumns = 11;
private int tileStartY = 39;
private int sampleMap[][] = {
//1, 2, 3, 4, 5, 6, 7, 8, 9,10,11
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, //11x12
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1, 1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, //-1 for empty space
{0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0} //0 for square tile
private int current_Map[][] = new int[numberOfRows][numberOfColumns]; //this will store the current level
// Constructor and initialization
public ExampleGameCanvas()
super(true);
try
tilesImg = Image.createImage("/tiles_240x320.png");
bottomboard = Image.createImage("/bottomboard_240x320.png");
clwalk = Image.createImage("/cl_walk_240x320.png");
}catch(Exception ee){}
// Automatically start thread for game loop
public void start()
isPlay = true;
Thread t = new Thread(this);
t.start();
// Main Game Loop
public void run()
Graphics g = getGraphics();
while (isPlay == true)
input();
drawMap(g);
drawPlayer(g);
try { Thread.sleep(delay); }
catch (InterruptedException ie) {}
// Method to Handle User Inputs
private void input()
int keyStates = getKeyStates();
// Right
if ((keyStates & RIGHT_PRESSED) !=0 )
System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbb");
clnX=clnX+2;
else if ((keyStates & LEFT_PRESSED) !=0 )
System.out.println("1111111111111111111111111111111111");
clnX=clnX-2;
private void drawMap(Graphics g)
System.out.println("jjjjjjjjjjjjjjjjjjjjjjj");
System.out.println("oooooooooooooooooooo");
g.setClip(0, 0, getWidth(), getHeight());
g.drawImage(bottomboard, 0, getHeight()-bottomboard.getHeight(), 0);
current_Map=sampleMap;
for(byte row = 0; row < numberOfRows; row++)
for(byte col =0; col < numberOfColumns; col++)
switch(current_Map[row][col])
case 0:
g.drawRegion(tilesImg, tileStartXPosition, tileStartYPosition, tileWidth, tileHeight, ROTATE_NONE, tileXPos,220, Graphics.TOP|Graphics.LEFT);
break;
if(tileXPos < 215)
tileXPos += tileWidth;
else
tileXPos = 5;
if(row >= 11)
tileYPos = tileStartY;
else
tileYPos += tileHeight;
// repaint();
// flushGraphics();
private void drawPlayer(Graphics g)
g.setColor(0xffffff);
g.fillRect(0,0,getWidth(),155+clwalk.getHeight());
g.drawRegion(clwalk,clwalkXstart, 0, 26, 41, ROTATE_NONE, clnX,180, Graphics.TOP|Graphics.LEFT);
clwalkXstart=clwalkXstart+26;
if(clwalkXstart==390)
clwalkXstart=0;
flushGraphics();
repaint();
thanks in advanceSo, do you want to make a walking character that is not allowed to run through walls, or do you want the character to move automatically, so that it chooses an empty space that is on the side at an arbitrary height ?
If the first thing is what you mean, then this is how I do it: before I try and move a character, I first check if the position it should move into is free. If it is, that is, if no tile is in the way, the motion is granted/allowed.
Pseudocode:
If Key(LEFT)
If (Character can move to left) { Move character to left }
If (Character can move to right) { Move character to right }
}As for gravity and jumping, I use this:
Pseudocode:
If (jump > 0)
jump = jump - 1
*Move character upwards, if allowed*
Else
If (*Character can move downwards*)
*Move character downwards*
ElseIf Key(SPACE)
jump = 150
}
Maybe you are looking for
-
Is it possible to update a 10.6.3 installation DVD to 10.6.8?
Hello Everyone, I work with a variety of clients and businesses that have need to reinstall their OS on a semi-regular basis. While I can use the original installation DVD, it's (much) faster to reinstall via a hard drive-based disc image of the appr
-
Hi i can not connect with face time when i am out and about adice wanted please.
-
Friends, I have googled a lot and searched a lot in internet regarding my problem. Hope here I get some clue to recover my database. I have one test database which I am using from few month. Unfortunately I have dumped the database contents on same H
-
Create DIM,Fact,Measure cube & OLAP catalog 4 SOLVED LEVEL-BASED Hierarchy
Is thre any complete example available which explains how to create SOLVED LEVEL-BASED hierarchy and catalog for that? I have example mentioned in 9204 ref guide chapter CWM2_OLAP_PC_TRANSFORM. But I want complete exaple with script so I can work fas
-
Can u tell me any bapi to create the purchase req with sales order as refer
can u tell me any bapi to create the purchase req with sales order as reference?