Multi Table mapping support in EJB 3

Hi,
I wanted to get some inputs regarding the @SecondaryTables / @SecondaryTable annotation support in JSR 220 ..
As per my understanding its to be used to map the logical Entity(in java) to physically different Datasources ??
Basically the requirement is that given a POJO Entity in java , one can map the various properties to the columns of different Table's.
Say I have defined multiple datasources viz. MySql, Oracle, HSQL etc..
I should be able to map my Java entity to some of the columns of these DB's tables !!!
As per my experiments, I have been able to define multiple Persistence Units..
Say .PAR archives which has the persistence.xml file.
However I haven't been able to achieve the above requiement ..
It seems that one can only use the same physical DB & the different schema tables for mapping the Entity ?
Can someone elaborate more on this Annotation ?

Hi,
I wanted to get some inputs regarding the @SecondaryTables / @SecondaryTable annotation support in JSR 220 ..
As per my understanding its to be used to map the logical Entity(in java) to physically different Datasources ??
Basically the requirement is that given a POJO Entity in java , one can map the various properties to the columns of different Table's.
Say I have defined multiple datasources viz. MySql, Oracle, HSQL etc..
I should be able to map my Java entity to some of the columns of these DB's tables !!!
As per my experiments, I have been able to define multiple Persistence Units..
Say .PAR archives which has the persistence.xml file.
However I haven't been able to achieve the above requiement ..
It seems that one can only use the same physical DB & the different schema tables for mapping the Entity ?
Can someone elaborate more on this Annotation ?

Similar Messages

  • Multi-table mapping is not inserting into the primary table first.

    I have an inheritance mapping where the children are mapped to the parent table oids with the "Multi-Table Info" tab.
    One of children is not inserting properly. Its insert is attempting to insert into one of the tables from the "Additional Tables" of "Multi-Table Info" instead of the primary table that it is mapped to.
    The other children insert correctly. This child is not much different from those.
    I looked through the forums, but found nothing similiar.

    I would expect the Children to be inserted into both the primary table and the Additional Table? Is the object in question inserted into the primary table at all? Is the problem that it is being inserted into the Additional Table first? If it is, are the primary key names different? Is it a foreign key relationship?
    If the object in question has no fields in the additional table is it mapped to the additional table? (it should not be)
    Perhaps providing the deployment XML will help determine the problem,
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help with multi-table mapping for one-to-many object inheritance

    Hi,
    I have posted on here before regarding this (Toplink mapping for one-to-many object inheritance but I am still having problems mapping my object model to my schema.
    Object model
    The Person and Organisation objects contain base information and have the primary keys person_id and organisation_id. It is important that there is no duplication of person and organisation records, no matter how many times they are saved in different roles.
    There are two types of licenceholder in the problem domain, and the ILicenceHolder interface defines information and methods that are common to both. The PersonalLicenceHolder object represents one of these types of licenceholder, and is always a person, so this class extends Person and implements ILicenceHolder.
    The additional information and methods that are required by the second type of licenceholder are defined in the interface IPremisesLicenceHolder, which extends ILicenceHolder. Premises licence holders can either be people or organisations, so I have two objects to represent these - PremisesLicenceHolderPerson which implements IPremisesLicenceHolder and extends Person, and PremisesLicenceHolderOrganisation which implements IPremisesLicenceHolder and extends Organisation.
    The model is further complicated by the fact that any single Person may be both a PersonalLicenceHolder and a PremisesLicenceHolderPerson, and may be so several times over. In this case, the same basic Person information needs to be linked to several different sets of licenceholder information. In the same way, any single Organisation may be a PremisesLicenceHolderOrganisation several times over.
    Sorry this is complicated!
    Schema
    I have Person and Organisation tables containing the basic information with the primary keys person_id and organisation_id.
    I have tried to follow Donald Smith's advice and have created a Role table to record the specialised information for the different types of licence holder. I want the foreign keys in this table to be licenceholder_id and licence_id. Licenceholder_id will reference either organisation_id or person_id, and licence_id will reference the primary key of the Licence table to link the licenceholder to the licence. Because I am struggling with the mapping, I have changed licenceholder_id to person_id in an attempt to get it working with the Person object before I try the Organisation.
    Then, when a new licenceholder is added, if the person/organisation is already in the database, a new record is created in the Role table linking the existing person/organisation to the existing licence rather than duplicating the person/organisation information.
    Mapping
    I am trying to use the toplink mapping workbench to map my PremisesLicenceHolderPerson object to my schema. I have mapped all inherited attributes to superclass (Person). The primary table that the attributes are mapped to is Person, and I have used the multi-table info tab to add Roles as an additional table and map the remaining attributes to that.
    I have created the references PERSON_ROLES which maps person.person_id to roles.person_id, ROLES_PERSON which maps roles.person_id to person.person_id and ROLES_LICENCE which maps roles.licence_id to licence.licence_id.
    I think I have put in all the relationships, but I cannot get rid of the error message "The following primary key fields are unmapped: PERSON_ID".
    Please can somebody tell me how to map this properly?
    Thank you.

    I'm not positive about your mappings, but it looks like the Person object should really have a 1:M or M:M mapping to the Licenceholder table. This then means that your object model should be similar, in that Person object could have many Licenses, instead of being LicenceHolders. From the looks of it, you have it set up from the LicenceHolder perspective. What could be done instead if a LicenceHolder could have a 1:1 reference to a person data object, rather than actually be a Person. This would allow the person data to be easily shared among licences.
    LicenceHolder1 has an entry in the LicenceHolder table and Person table. LicenceHolder2 also has entries in these tables, but uses the same entry in the Person table- essentially it is the same person/person_ID. If both are new objects, TopLink would try to insert the same person object into the Person table twice. I'm not sure how you have gotten around or are planning to get around this problem.
    Since you are using inheritance, it means that LicenceHolder needs a writable mapping to the person.person_id field- most commonly done through a direct to field mapping. From the description, it looks like roles.person_id is a foreign key in the multiple table mapping, meaning it would be set based on the value in the person.person_id field, but the person.person_id isn't actually mapped in the object. Check to make sure that the ID attribute LicenceHolder is inheriting from person hasn't been remapped in the LicenceHolder descriptor to a different field.
    Best Regards,
    Chris

  • Deleting with multi-table mapping

    I have an object that is mapped to two tables, i.e., one object is split across two tables. When I do a deleteallquery it only executes a delete for one of the tables:
    DELETE FROM DIRECT2TABLESPART1
    Inserts, selects, and updates all work correctly and manipulate both tables. Is there something explicit I have to do to get it to execute the delete for the other table?

    The class DeleteAllQuery should only be used internally by TopLink, it is not for external use. It is only used in TopLink from a 1-m mapping and only in the case where multiple tables and private relations do not exist such that the delete of all of the objects can be optimized.
    TopLink does not currently provide delete-all/update-all style of queries, you must either delete the objects one by one, or issue custom SQL to delete a set of objects.

  • Can esb DVM(Domain-value mapping ) support multi-language  ?

    I create a dvm , and add some rows in Chinese , but when I restart the soa service , all the DVM that I created disappeared.
    Can esb DVM(Domain-value mapping ) support multi-language ?
    Edited by: user10732687 on 2009-8-23 下午7:39

    DVM is designed to use in English only and not intended to support Multi language. It is the job of consumer application to convert from English to native language(Chinese in your case).
    Thanks,
    Vamsee.

  • Can't drop database table objects on a EJB Diagram.

    JDeveloper 10.1.3 EA.
    When I drop a database table object on a EJB Diagram the error below occurs. Also dropping components from the Component Palette doesn't work. A wizard opens, but after completing that, nothing is on the EJB Diagram.
    However, after dropping a table and a restart of JDeveloper, there is an empty 'tablename EJB' on the EJB Diagram, but a click with the mouse on it generates the same error as the drop did.
    Simular errors occur with JDeveloper 10.1.2, so writing this I realize that this might be a database version problem. I'm using 9i! I'll try 10g and see what happens.
    Message
    BME-99003: An error occurred, so processing could not continue.
    Cause
    The application has tried to de-reference an invalid pointer. This exception should have been dealt with programmatically. The current activity may fail and the system may have been left in an unstable state. The following is a stack trace.
    java.lang.NullPointerException
         at oracle.jdevimpl.xml.DescriptorNode.getWhitespaceHandler(DescriptorNode.java:349)
         at oracle.jdevimpl.xml.DescriptorNodeDomIO.load(DescriptorNodeDomIO.java:164)
         at oracle.jdeveloper.xml.BindingIO.load(BindingIO.java:43)
         at oracle.jdevimpl.xml.DescriptorNode.getNewDescriptorImpl(DescriptorNode.java:506)
         at oracle.jdevimpl.xml.DescriptorNode.getDescriptor(DescriptorNode.java:140)
         at oracle.jdeveloper.xml.oc4j.ejb.OrionEjbJarNode.getOrionEjbJar(OrionEjbJarNode.java:145)
         at oracle.jdeveloper.ejb.BaseEjbModuleContainer.getOrionEjbJar(BaseEjbModuleContainer.java:476)
         at oracle.jdeveloper.ejb.modeler.diagram.dropHandler.TableDropEJB21Handler.isAvailable(Unknown Source)
         at oracle.bm.diagrammer.ui.DropChooserPanel.populateOptions(Unknown Source)
         at oracle.bm.diagrammer.ui.DropChooserPanel.createComponents(Unknown Source)
         at oracle.bm.diagrammer.ui.DropChooserPanel.<init>(Unknown Source)
         at oracle.bm.diagrammer.dropHandler.AbstractChooserDropHandler.createPanel(Unknown Source)
         at oracle.bm.diagrammer.dropHandler.AbstractChooserDropHandler.processObjects(Unknown Source)
         at oracle.bm.addinUtil.IDEAppContext$4.performAction(Unknown Source)
         at oracle.bm.diagrammer.LockMonitor.performLockedAction(Unknown Source)
         at oracle.bm.diagrammer.BaseDiagram.performDiagramLockedAction(Unknown Source)
         at oracle.bm.addinUtil.IDEAppContext.dropNavigatorNodeLater(Unknown Source)
         at oracle.bm.addinUtil.IDEAppContext$5.run(Unknown Source)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Action
    If further errors occur, you should restart the application.
    Also, report the problem on the JDeveloper forum on otn.oracle.com, or contact Oracle support, giving the information from this message.
    ________________________________________________________________________________

    Hi lisa, you've said that the problem does not occur in the 10.1.3 build but I have almost the same problem with the BME-99003 error message.
    I used the same workaround "changing the regional settings from BE to US" and the BME-99003 problem disappears :-)
    Here is the error message that I receive while I add a table into the EJBDiagram. I'm using
    windows XP SP2
    ADF Business Components     10.1.3.34.12
    Java™ Platform     1.5.0_04
    Oracle IDE     10.1.3.34.12
    Struts Modeler Version     10.1.3.34.12
    UML Modelers Version     10.1.3.34.12
    Versioning Support     10.1.3.34.12
    Abdelkrim BOUJRAF
    Message
    BME-99003: An error occurred, so processing could not continue.
    Cause
    The application has tried to de-reference an invalid pointer. This exception should have been dealt with programmatically. The current activity may fail and the system may have been left in an unstable state. The following is a stack trace.
    java.lang.NullPointerException
    at oracle.jdevimpl.xml.DescriptorNode.getWhitespaceHandler(DescriptorNode.java:349)
    at oracle.jdevimpl.xml.DescriptorNodeDomIO.load(DescriptorNodeDomIO.java:164)
    at oracle.jdeveloper.xml.BindingIO.load(BindingIO.java:43)
    at oracle.jdevimpl.xml.DescriptorNode.getNewDescriptorImpl(DescriptorNode.java:506)
    at oracle.jdevimpl.xml.DescriptorNode.getDescriptor(DescriptorNode.java:140)
    at oracle.jdeveloper.xml.oc4j.ejb.OrionEjbJarNode.getOrionEjbJar(OrionEjbJarNode.java:145)
    at oracle.jdeveloper.xml.oc4j.ejb.OrionEjbJarHelper.findOrionEjbJar(OrionEjbJarHelper.java:82)
    at oracle.jdeveloper.xml.oc4j.ejb.OrionEjbJarHelper.findOrCreateOrionEjbJar(OrionEjbJarHelper.java:73)
    at oracle.jdeveloper.ejb.modeler.diagram.dropHandler.TableDropEJBCommonHandler.processTableNodes(Unknown Source)
    at oracle.jdeveloper.ejb.modeler.diagram.dropHandler.TableDropEJB21Handler.processTableNodes(Unknown Source)
    at oracle.bm.typemodel.dropHandler.TableDropSubHandler.processDBObjectNodes(Unknown Source)
    at oracle.bm.typemodel.dropHandler.DBObjectDropSubHandler.processObjects(Unknown Source)
    at oracle.bm.diagrammer.dropHandler.AbstractChooserDropHandler.processObjectsImpl(Unknown Source)
    at oracle.bm.diagrammer.dropHandler.AbstractChooserDropHandler.processObjects(Unknown Source)
    at oracle.bm.addinUtil.IDEAppContext$4.performAction(Unknown Source)
    at oracle.bm.diagrammer.LockMonitor.performLockedAction(Unknown Source)
    at oracle.bm.diagrammer.BaseDiagram.performDiagramLockedAction(Unknown Source)
    at oracle.bm.addinUtil.IDEAppContext.dropNavigatorNodeLater(Unknown Source)
    at oracle.bm.addinUtil.IDEAppContext$5.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Action
    If further errors occur, you should restart the application.
    Also, report the problem on the JDeveloper forum on otn.oracle.com, or contact Oracle support, giving the information from this message.

  • VLD-1119: Unable to generate Multi-table Insert statement for some or all t

    Hi All -
    I have a map in OWB 10.2.0.4 which is ending with following error: -
    VLD-1119: Unable to generate Multi-table Insert statement for some or all targets.*
    Multi-table insert statement cannot be generated for some or all of the targets due to upstream graphs of those targets are not identical on "active operators" such as "join".*
    The map is created with following logic in mind. Let me know if you need more info. Any directions are highly appreciated and many thanks for your inputs in advance: -
    I have two source tables say T1 and T2. There are full outer joined in a joiner and output of this joined is passed to an expression to evaluate values of columns based on
    business logic i.e. If T1 is available than take T1.C1 else take T2.C1 so on.
    A flag is also evaluated in the expression because these intermediate results needs to be joined to third source table say T3 with different condition.
    Based on value taken a flag is being set in the expression which is used in a splitter to get results in three intermediate tables based on flag value evaluated earlier.
    These three intermediate tables are all truncate insert and these are unioned to fill a final target table.
    Visually it is something like this: -
    T1 -- T3 -- JOINER1
    | -->Join1 (FULL OUTER) --> Expression -->SPLITTER -- JOINER2 UNION --> Target Table
    | JOINER3
    T2 --
    Please suggest.

    I verified that their is a limitation with the splitter operator which will not let you generate a multi split having more than 999 columns in all.
    I had to use two separate splitters to achieve what I was trying to do.
    So the situation is now: -
    Siource -> Split -> Split 1 -> Insert into table -> Union1---------Final tableA
    Siource -> Split -> Split 2 -> Insert into table -> Union1

  • Remove multi table property defined in Parent descriptor

    I tried to remove a multi table property(which is defined in a parent descriptor) in a child, but it does not get removed.
    <!-- Parent descr -->
    <item-descriptor name="parent" ...>
         <table name="testTable" type="multi" id-column-name="id" multi-column-name="seq_num">
              <property name="testProperty" column-name="property1_id" data-type="map" component-data-type="string">
              </property>
         </table>
    </item-descriptor>
    <!-- Child descr -->
    <item-descriptor name="child" super-type="parent" sub-type-value="child" xml-combine="append">
         <table name="testTable" type="multi" id-column-name="id" multi-column-name="seq_num">
              <property name="testProperty" xml-combine="remove">
              </property>
         </table>
    </item-descriptor>
    Above code does not remove the property "testProperty" in child descriptor.
    If i have a auxiliary table type, rather than multi table type, then it is working fine. Not sure why it is not working in multi table property.
    Does anyone have any idea?
    Thanks!!!

    Hi,
    xml-combine is applicable when combining two or more xml definition files.
    When you say it worked for you for a table of type auxiliary, the properties are in same xml or in different xml files?
    In your case, you are actually trying to override a property from parent item descriptor in a child item descriptor.
    I would suggest to have the testProperty removed from the parent item descriptor and let the children item descriptors define the testProperty.
    Hope this helps.
    Keep posting the updates / questions.
    Thanks,
    Gopinath Ramasamy

  • Mat. for Initial Download: Table not supported by function "C_"

    Hi All,
    We are in SRM 5.0 & ECC 6.0 with Classic scenario. While uploading the MATERIAL through R3AS, we have the "Mat. for Initial Download: Table not supported by function C_" & "No product ID determined for material number ... of logical system" error in SMW01.
    In SMQ2 in SRM, Queue is blocked with "Error in Mapping (Details: transaction SMW01)"
    For your information RFC Users at both the ends have SAP_ALL authorisation. SAP Notes 720819, 420980 & 432339 are implemented.
    Please guide me to resolve this issue.
    Regards
    Ashutosh

    hi,
    How was the issue resolved , i am having the same problem.
    can somebody provide with clue
    regards

  • Splitter operator doesnt use multi table inserts in OWB...very very urgent

    Hi,
    I am using OWB 9i to carry out tranformations. I want to copy the same seuence numbers to the two target tables.
    Scenario:
    I have a source table source_table, which is connected to a splitter and the splitter is used to dump the records in two target tables namely target1_table and target2_table. I have a sequence which is also an input to the splitter, so that I can have the same sequence number in the the two output groups of he splitter. I then map the sequence number from the two output groups to the two target tables expecting to have the same sequence number in the target tables. But when I see the generated code it creates two procedures and effectively inserts sequencing numbers in the target tables which are not consistent. Please help me so that I have the same sequencing numbers in the target tables which are consistent.
    Well the above example works in row based operating mode but not in set based mode. Please give me a valid explanation.
    OWB pdf says that splitter uses multi table inserts for multiple targets. After seeing the generated code for set based operations I dont agree to this.
    Its very urgent.
    thanks a lot in advance.
    -Sharat

    Hi Mark,
    You got me wrong, let me explain you the problem again.
    RDBMS oracle 9.2.0.4
    OWB 9.2.0.2.8
    I have three tables T1,T2 and T3.
    T1 is the source table and the remaining two tables T2 and T3 are target tables.
    Following are the contents of table T1 -
    SQl>select * from T1;
    DEPTNAME LOCATIO?N
    COMP PUNE
    MECH BOMBAY
    ELEC A.P
    Now I want to populate the two destination tables T2 and T3 with the records in T1.
    For this I am using splitter operator in OWB which is suppose to generate multi table inserts, but unfortunately its not doing so when I generate the SQL. There si no "insert all" command in the sql it generates.
    What I want is, when I populate T2 and T3 I use a sequence generator and I want the same sequences for T2 and T3 eg.
    SQl>select * from T2;
    NEXT_VAL DEPTNAME LOCATIO?N
    1 COMP PUNE
    2 MECH BOMBAY
    3 ELEC A.P
    SQl>select * from T3;
    NEXT_VAL DEPTNAME LOCATIO?N
    1 COMP PUNE
    2 MECH BOMBAY
    3 ELEC A.P
    I am able to achieve this when I set the operating mode to ROW BASED. I am not geting the same result when I set the operating mode to SET BASED.
    Help me....
    -Sharat

  • TopLink Question - Mutliple Object to Single Table mapping

    Just a short question,
    Does toplink support mapping feature as such that it can map two distinct objects with single table that when in insertion or selection those two objects can be manipulated, selected in single operation? I know that TopLink mapping supports single object from multiple table mapping, but I'm not sure about multiple objects being associated with single table.
    Secondly, does Hibernate has something like what I described above?
    Howard.

    Hi Howard,
    You can map two objects to a single table if the objects are related by aggregation.
    In TopLink, two objects–a source (parent or owning) object and a target (child or owned) object–are related by aggregation if there is a strict one-to-one relationship between them, and all the attributes of the target object can be retrieved from the same data source representation as the source object. This means that if the source object exists, then the target object must also exist, and if the source object is destroyed, then the target object is also destroyed.
    http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/tutbuild004.htm#sthref2325
    -Blaise

  • Multiple Table Mapping To Single Entity in Workshop 8.1

    I've taken a test run on creating entity beans with workshop 8.1, although mapping
    an CMP entity to a single database table looks to be relatively straightforward,
    I can't seem to find a way to map multiple database tables to a single CMP entity
    (at least not via workshop). Do I have to manually modify the deployment descriptors
    after building with workshop?

    Thanks, John.
    Jingwei
    "John Reynolds" <[email protected]> wrote:
    >
    Jingwei Zhang <[email protected]> wrote:
    Is there any example of using ejbgen to map single EJB to multiple tables?
    Jingwei... I found this at: http://www.beust.com/cedric/ejbgen/#multiple-table-mapping
    By default, Entity beans are mapped to one table, with the attribute
    table-name
    on the tag @ejbgen:entity. If you want to map your Entity bean to more
    than one
    table, you can use the table-name attribute on individual @ejbgen:cmp-fields.
    All the CMP fields that do not have a table-name attribute will use the
    table
    specified on @ejbgen:entity (which can therefore be considered as the
    "default"
    table).
    If you want to map an Entity bean to several tables, you need to specify
    a comma-separated
    list of tables in the table-name attribute (and also on column). For
    example:
    * @ejbgen:cmp-field
    * column = "bal1, bal2"
    * table-name = "Table1, Table2"
    Make sure that the number of tables matches the number of columns, and
    that the
    columns exist in the corresponding table (for example, in the example
    above, Table1
    must contain column bal1, and Table2, bal2).

  • Multi table insert in ODI

    Hello,
    Does ODI allow using multi table insert feature? For example
    INSERT FIRST
    WHEN expr THEN
    INTO ...
    WHEN expr THEN
    INTO ..
    SELECT ..
    FROM ...
    WHERE ...
    I could build my own LKM but I can't define appropriate Meta Model. In an interface ODI allows single Target Datastore only.

    Hi simonova,
    I guess you can do this by ODI procedure,( write the Plsql code for it).
    But Interface supports only one target data store.So you couldnt do with available KMs.
    Thanks,
    Madha

  • Table mapping (KODO 3.4) using XDoclet

    Hi,
    I need to map an Object to a differntly named table via XDoclet. That is described in the [url http://edocs.bea.com/kodo/docs303/ref_guide_integration_xdoclet.html]Docs here.
    When I use the foloowing class it will produce a different looking JDO file and KODO simply ignores it. Can you tell me, what I'm doing wrong?
    Java Code:
    * @jdo.persistence-capable
    * identity-type="application"
    * objectid-class="MyClassId"
    * @jdo.class-vendor-extension
    * vendor-name="kodo" key="detachable" value="true"
    * @jdo.class-vendor-extension
    * vendor-name="kodo" key="jdbc-class-map" value="base"
    * @jdo.class-vendor-extension
    * vendor-name="kodo" key="jdbc-class-map/table" value="MyTableName"
    public class MyClass {...}
    JDO file:
    <class name="MyClass" identity-type="application" objectid-class="MyClassId" requires-extent="true">
    <extension vendor-name="kodo" key="detachable" value="true">
    </extension>
    <extension vendor-name="kodo" key="jdbc-class-map" value="base">
    </extension>
    <extension vendor-name="kodo" key="jdbc-class-map/table" value="MyTableName">
    </extension>
    <field name="xxx" persistence-modifier="persistent" primary-key="false" null-value="none">
    </field>
    Update:
    I also tried:
    * @jdo.persistence-capable
    * identity-type="application"
    * objectid-class="MyClassId"
    * table="MyTable"
    public class MyClass {...}
    But it seems, Kodo does not support the table attribute!
    Update 2:
    The upper solution should be the right one. It seems in the kodo.properties must be set the attribute "kodo.jdbc.MappingFactory: metadata"
    Is anyone using such a table mapping that is working? I'm still struggeling to get this working!
    Edited by jdeluxe at 05/16/2008 4:32 AM

    Wow, I didn't expect almost 100 people watching this thread without any hint!
    Here it is:
    Ant Task
              <jdomappingtool action="refresh" sqlfile="XXX">
                   <fileset dir="YYY" >
                        <include name="**/*.jdo" />
                   </fileset>
                   <config propertiesFile="D:/kodo-jdo-3.4.1/kodo.properties" />
    EntityClass:
    * @jdo.persistence-capable
    *           identity-type="application"
    *      objectid-class="foo.MyClassId"
    *      name="myClass"
    * @jdo.class-vendor-extension
    *           vendor-name="kodo" key="jdbc-class-map" value="base"
    * @jdo.class-vendor-extension
    *           vendor-name="kodo" key="jdbc-class-map/table" value="MYTABLENAME"
    * @jdo.class-vendor-extension
    *           vendor-name="kodo" key="jdbc-class-map/pk-column" value="ID"
    public class MyClass {
    * description
    * @jdo.field persistence-modifier="persistent"
    * @jdo.field-vendor-extension vendor-name="kodo"
    * key="jdbc-field-map" value="value"
    * @jdo.field-vendor-extension vendor-name="kodo"
    * key="jdbc-field-map/column" value="description"
    private String description;
    Note that when not using the explicit column mapping I experienced a strange behaviour: Kodo did not map to the existing table column, but wanted to add new fields postfixed with "1" (e.g. ALTER TABLE MYTABLENAME ADD COLUMN "description1").
    Also the setting
    kodo.jdbc.MappingFactory: metadata
    in the kodo.properties file is mandatory !!!!!

  • Multi table inheritance and performance

    I really like the idea of multi-table inheritance, since a have a main
    class and three subclasses which just add one integer to the main class.
    It would be a waste to spend 4 tables on this, so I decided to put them
    all into one.
    My problem now is, that when I query for a specific class, kodo will build
    SQL like:
    select ... from table where
    JDOCLASSX='de.mycompany.myprojectname.mysubpack.classname'
    this is pretty slow, when the table grows because string comparisons are
    awefull - and even worse: the database has to compare nearly the whole
    string because it differs only in the last letters.
    indexing would help a bit but wouldn't outperforming integer comparisons.
    Is it possible to get kodo to do one more step of normalization ?
    Having an extra table containing all classnames und id's for them (and
    references in the original table) would improve performance of
    multi-tables quite a lot !
    Even with standard classes it would save a lot memory not having the full
    classname in each row.

    Stefan-
    Thanks for the feedback. Note that 3.0 does make this simpler: we have
    extensions that allow you to define the mechanism for subclass
    identification purely in the metadata file(s). See:
    http://solarmetric.com/Software/Documentation/3.0.0RC1/docs/manual.html#ref_guide_mapping_classind
    The idea for having a separate table mapping numbers to class names is
    good, but we prefer to have as few Kodo-managed tables as possible. It
    is just as easy to do this in the metadata file.
    In article <[email protected]>, Stefan wrote:
    First of all: thx for the fast help, this one (IntegerProvider) helped and
    solves my problem.
    kodo is really amazing with all it's places where customization can be
    done !
    Anyway as a wish for future releases: exactly this technique - using
    integer as class-identifiers rather than the full class names is what I
    meant with "normalization".
    The only thing missing, is a table containing information of how classIDs
    are mapped to classnames (which is now contained as an explicit statement
    in the jdo-File). This table is not mapped to the primary key of the main
    table (as you suggested), but to the classID-Integer wich acts as a
    foreign key.
    A query for a specific class would be solved with a query like:
    select * from classValues, classMapping where
    classValues.JDOCLASSX=classmapping.IDX and
    classmapping.CLASSNAMEX='de.company.whatever'
    This table should be managed by kodo of course !
    Imagine a table with 300.000 rows containing only 3 different derived
    classes.
    You would have an extra table with 4 rows (base class + 3 derived types).
    Searching for the classID is done in that 4row table, while searching the
    actual class instances than would be done over an indexed integer-classID
    field.
    This is much faster than having the database doing 300.000 String
    comparisons (even when indexed).
    (By the way - it would save a lot memory as well, even on classes which
    are not derived)
    If this technique is done by kodo transparently, maybe turned on with an
    extra option ... that would be great, since you wouldn't need to take care
    for different "subclass-indicator-values", can go on as everytime and have
    a far better performance ...
    Stephen Kim wrote:
    You could push off fields to seperate tables (as long as the pk column
    is the same), however, I doubt that would add much performance benefit
    in this case, since we'd simply add a join (e.g. select data.name,
    info.jdoclassx, info.jdoidx where data.jdoidx = info.jdoidx where
    info.jdoclassx = 'foo'). One could turn off default fetch group for
    fields stored in data, but now you're adding a second select to load one
    "row" of data.
    However, we DO provide an integer subclass provider which can speed
    these sorts of queries a lot if you need to constrain your queries by
    class, esp. with indexing, at the expense of simple legibility:
    http://solarmetric.com/Software/Documentation/2.5.3/docs/ref_guide_meta_class.html#meta-class-subclass-provider
    Stefan wrote:
    I really like the idea of multi-table inheritance, since a have a main
    class and three subclasses which just add one integer to the main class.
    It would be a waste to spend 4 tables on this, so I decided to put them
    all into one.
    My problem now is, that when I query for a specific class, kodo will build
    SQL like:
    select ... from table where
    JDOCLASSX='de.mycompany.myprojectname.mysubpack.classname'
    this is pretty slow, when the table grows because string comparisons are
    awefull - and even worse: the database has to compare nearly the whole
    string because it differs only in the last letters.
    indexing would help a bit but wouldn't outperforming integer comparisons.
    Is it possible to get kodo to do one more step of normalization ?
    Having an extra table containing all classnames und id's for them (and
    references in the original table) would improve performance of
    multi-tables quite a lot !
    Even with standard classes it would save a lot memory not having the full
    classname in each row.
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

Maybe you are looking for