Inheritance mapping to table

Hello,
I am trying to create a project in Toplink with the following classes (getters and setters ommited):
class GenericPerson {
int id;
String email;
Vector phoneNumbers;
class Employee extends GenericPerson {
String name;
Date birthday;
class Enterprise extends GenericPerson {
String enterpriseName;
int cnpj;
class PhoneNumber {
int id;
int areaCode;
String number;
GenericPerson contact;
In my model, the PhoneNumber can be mapped to an Employee or to an Enterprise, so I map it to the superclass.
But my superclass is not mapped to a table, I chose to map the inherited attributes to the leaf classes.
So, how can I map the attribute "contact" in the class PhoneNumber to a database field? I think I am having a conceptual problem here...
[]s

Impedence mismatch...
What would you like the schema to look like? What you're looking for is to have a foreign key in PHONE_NUMBER table that points to EITHER the ENTERPRISE or EMPLOYEE table... Any DBA will have a heart attack if you suggest to have a FK that points to one of 2 tables... So, you need to consider having an association table for each relationship and mapping as a M-M (it's still a 1-M in your java model, but M-M in the mapping by virtue of having a relationship table to store it), then you don't need the back reference... Or, you can map the root table.
My recommendation is to create relation tables and use M-M mapping.
- Don

Similar Messages

  • What inheritance mapping strategy would you use here, if any?

    [Scenario]
    I have a somewhat unusual problem. I have a set of entities, like Movie, Book etc. that all inherit Item class and that are perfectly identical in their structure (as none of them has any specific fields on it's own). They all have Id, Name, Description and Image fields, nothing else. The only difference between them is that some, obviously, represent movies, some of them books etc. If I didn't need to know their type, I wouldn't need inheritance at all.
    [SINGLE_TABLE]
    Obviously, all these entities could be easily persisted into the same table with a discriminator column (and entities themselves would have a @DiscriminatorValue) i.e using SINGLE_TABLE strategy. But, I would avoid this approach as there will be a lot of persisted entities, like, tens of thousands of each type (which means tables that map M-M relations could have millions or tens of millions of rows), so I'm guessing this approach would kill the performance.
    [JOINED]
    JOINED strategy has the same problems as SINGLE_TABLE.
    [TABLE_PER_CLASS]
    My opinion here, is that TABLE_PER_CLASS strategy would be the best approach, as I will rarely, if ever, query across multiple types. Item (the supertype) has only unidirectional 1:M relations, so , if I get this right, this is OK as well, as it avoids UNION when queried (please confirm or correct me on this), e.g. the query to fetch books and their votes (1:M) would resolve to SELECT * FROM Book b JOIN Vote v ON b.id = v.item_id, so no UNION... right?
    But maybe I don't need inheritance mapping at all then...
    What is your opinion here? Any shared thoughts are appreciated.

    The disadvantage of using table_per_class would be that you have to duplicate the field structure many times (e.g. code duplication). If you ever want to change certain fields you (or the db-administrator) would have to do that a few times. Since in eventually you always have to use direct sql one time or another, making the database design as clear as the java code (where you wouldn't want code duplication either). Direct SQL you'd often need for optimilazition or because certain operations can be done in one SQL query, while requiring a lot of code if done in java.
    You could use a single table, without losing performance. If you add an index to the discriminator type, a modern database will optimize queries and won't to full table scan. That way you have a clean database design, without losing performance.
    If you ever need extra fields for say movie that you don't need for book (like duration in minutes, director), you can then create an extra table movie that contains only the fields that are extra. Retrieving movie then requires a join of item and movie, but since movie would be a smaller table and the join will be on indexed field, that wouldn't hurt performance.The database design keeps being clear and readable, as well as your java code.
    If you really don't care about your relational database design, don't use a relation database but rather an object database. Object database are optimized for retrieving object graphs (retrieving a graph of objects won't require joins and table scans). The only disadvantage, aggragation of data is usually slower.

  • Value Mapping through Tables in R/3 from XI

    Hi All,
    I'm new to XI and got a scenario as "Value Mapping through Tables in R/3 from XI". Kindly do tell me the steps which I should follow to complete this scenario. I'm from ABAP so table creation is known to me, what next should I do after table creation?
    Thanks in Advance to all of you,
    Sreedhar

    sree,
    value mapping are done using message mapping. In message mapping you have to make a RFC call to query the db and get the response. were you have to write a java function in mapping program.
    check this blog, it speaks on value mapping
    /people/jayakrishnan.nair/blog/2005/06/20/dynamic-file-name-using-xi-30-sp12-part--i

  • Is Mapping Lookup table possible with IDOC to FIle scenario

    Hi all,
    Need suggestion, I am using SP16
    My sceanrio is IDOC to FIles, and have to use a Mapping Lookup tables for some of the fields within the mapping...
    'Crossref:  PlantLoc_to_WhseComDiv.  Value mapping lookup to take two fields from SAP and convert to WMS 3-digit value'
    How to go with this, since i have checked in SAP library that it is for only RFC,JDBC,SOAP adapters ...
    Need u r valuable inputs,
    Regards,
    sridhar

    You can use RFC or SOAP or JDBC lookup in your mapping.Why not?..It does not mean that we use the lookups only in RFC secnarios.You can use them in any scenario.

  • How to map 2 tables together into a new one, like an Union?

    Hi.
    I am new in Oracle Data Warehouse Builder and what I'm wanting to do could be simple.
    My question is: How to map 2 tables into a new one? That is, what I need is to do a Union.
    See the following tables:
    What I have is:
    ---------------+ ---------------+
    | A | B | | A | B |
    |--------------- |---------------
    | 10 | 34 | | 13 | 39 |
    ---------------+ ---------------+
    Table 1 Table 2
    What I wish is:
    ---------------+ ----------------------+
    | A | B | Original table |
    |--------------- ----------------------+
    | 10 | 34 | 1 |
    |--------------- ----------------------+
    | 13 | 39 | 2 |
    |--------------- ----------------------+
    Then, I need put all data together into a new table and this new table should has a new column showing the original source of data to each record.
    Can I do such thing?
    I'm using the Oracle Warehouse Builder and trying to do a map in this way.
    Any hint will be very helpful. I also will appreciate an indication of some document which can show how to do it.
    Thanks .
    Rodrigo Pimenta.
    Brazil.

    Use the SET OPERATOR. That should help i guess.

  • How can I see in what maps some table is used?

    Hi,
    Anyone can tell me how can I see in what maps some table is used, without open all of then?
    Thanks,
    Gustavo.

    Good morning Gustavo,
    OWB has some public views defined which can provide you with this information. Check Appendix D (Warehouse Builder Public Views) of the OWB User Guide for all info.
    Log in as the owner of the design time repository, if you run the following query you'll have a basic overview of whic table is used in which mapping:SELECT MAP_NAME         MAPPING_NAME
    ,      DATA_ENTITY_NAME TABLE_NAME
    ,      BUSINESS_NAME    TABLE_OPERATOR_ALIAS
    ,      DESCRIPTION      TABLE_OPERATOR_DESCRIPTION
    FROM   ALL_IV_XFORM_MAP_COMPONENTS
    WHERE  DATA_ENTITY_TYPE = 'TABLE'Good luck, Patrick

  • How to copy FDM setting (import format, dimension mapping, control table)

    Dear All,
    How to copy FDM setting (import format, dimension mapping, control table) from application to another application.
    I found that only dimension mapping can be imported. Is there any way to copy FDM application quickly?
    Thanks your help

    If you get a chance try the following script, it's so simple and easy to extract all the map data to XML and will help in to import back through Import script.
    Sub MapExtractor()
    'UpStream WebLink Custom Script:
    'Created By:      SatyaK
    'Date Created:      12/08/09
    'Purpose: This Script will produce a Account Map File for
    '                         the current location.
    'Execute the export
    strFilePath = API.IntBlockMgr.InterfaceMgr.fExportMapToXML("File Path", PPOVPeriod)
    End Sub
    -------------

  • How to do hibernate mapping for table or view without a primary key

    Hi,
    Anyone knows how to do hibernate mapping for table or view without a primary key?
    thanks.
    cc

    or you can make all column primary key .Anybody seriously considering that as a good idea should understand the implications:
    1. this requires that each row be unique - that's a minor issue normally, but can be a significant problem in some cases
    2. in practically all databases, a primary key constraint creates a unique index - this has many implications:
    a) in most databases, the index stores a copy of the column data that is indexed - this suggestion therefore more than doubles the data storage required for the data
    b) whenever an indexed column is changed, the index has to be maintained - this suggestion then more than doubles the work that each UPDATE statement has to do, since both the table and the index have to be maintained for any UPDATE at all
    This might work OK for toy projects, but it doesn't scale well at all...

  • Where to set Mapped Primary Table

    I am using sunOne studio 4 update 1, EE.
    I have created a schema by doing New->Database->Database Schema, all OK.
    I have then created related ejbs by doing New->J2EE->Related CMP Entity EJBs, all OK.
    Now I want to view the mapping information so
    I look at the CMP bean entry properties under the EJB module but I see no mapping information in Sun ONE AS Mappings tab. !!!
    When I try to edit the protected field I get warning indicating that bean must have a valid Mapped primary table. It tells me to set a Mapped Primary Table in the main properties sheet for this bean.
    My problem is I can not find this sheet
    Please help before I go crazy
    Thanks in advance
    Tex...

    OK I know where to set these fields now.
    It is set in the Sun ONE AS tab pane.
    However, here comes the next problem.
    The Wizard generated schema does not recognise the primary key fields so I can not map CMP to any table :-)
    I think this is a bug because I have generated schemas from 3 different databases (IBM, MySWL, SAP) and the tables have primary key fields.
    When I get a connection in Runtime Pane under Database node, I can see the primary fields are highlighted with red color.
    However, when I obtain the schema using, New->Database->Database Schema, there are no key fields generated.
    Anyone have any ideas, work around?
    Thanks
    Tex...

  • Collection MAP HASh map hash table

    Hi
    i wan to be familiar with Collection MAP API hasp map & hash table
    please guide me...
    tell me resource link where i can get more information about it.
    Bunty

    Thanks Jos
    it is more theortical You just skimmed through it for at most eleven minutes. How can you
    tell it's 'more theoretical'? It is a tutorial you know ...
    kind regards,
    Jos

  • Sql for  inheritance mapping looks for inherited attributes in base table

    i don't know if it is my mistake but....
    with inherited attributes (that worked OK in 10.1.3DP3) we are experiencing strange behavoir in that: the sql generated to retrieve implementors of a base class from a base table with additional attributes for subclasses read from joined tables is not valid.
    in 10.1.3DP3, the sql is correctly generated such that the attributes for subclasses are selected from the appropriate joined tables
    in 10.1.3DP4, the sql is generated such that all fields are selected from the base table, regardless whether these fields are mapped to the base class (base table) or subclasses (joined tables).
    what i expect to see is that the base table (usually aliased as t0) AND the joined table for reading subclasses (usually aliased as t1) are used in the sql statement.
    instead, all fields are selected from t0.
    i have included the generated descriptor code
    thank you very much in advance of any help here
    regards
    paul
    base class descriptor: 10.1.3DP3
    public ClassDescriptor buildAbstractEnrichmentRuleDescriptor() {
         RelationalDescriptor descriptor = new RelationalDescriptor();
         descriptor.setJavaClass(com.aon.amp.beans.enrichment.AbstractEnrichmentRule.class);
         descriptor.addTableName("ENRICHMENT_RULE");
         descriptor.addPrimaryKeyFieldName("ENRICHMENT_RULE.ENRICHMENT_RULE_ID");
         // Inheritance Properties.
         descriptor.getInheritancePolicy().setClassIndicatorFieldName("ENRICHMENT_RULE.DROP_DOWN_IND");
         descriptor.getInheritancePolicy().addClassIndicator(com.aon.amp.beans.enrichment.TextEnrichmentRule.class, "N");
         descriptor.getInheritancePolicy().addClassIndicator(com.aon.amp.beans.enrichment.DropDownEnrichmentRule.class, "Y");
         descriptor.getInheritancePolicy().dontReadSubclassesOnQueries();
    base class descriptor: 10.1.3DP4
    public ClassDescriptor buildAbstractEnrichmentRuleDescriptor() {
         RelationalDescriptor descriptor = new RelationalDescriptor();
         descriptor.setJavaClass(com.aon.amp.beans.enrichment.AbstractEnrichmentRule.class);
         descriptor.addTableName("ENRICHMENT_RULE");
         descriptor.addPrimaryKeyFieldName("ENRICHMENT_RULE.ENRICHMENT_RULE_ID");
         // Inheritance Properties.
         descriptor.getInheritancePolicy().setClassIndicatorFieldName("ENRICHMENT_RULE.DROP_DOWN_IND");
         descriptor.getInheritancePolicy().setReadAllSubclassesViewName("ENRICHMENT_RULE");
         descriptor.getInheritancePolicy().addClassIndicator(com.aon.amp.beans.enrichment.TextEnrichmentRule.class, "N");
         descriptor.getInheritancePolicy().addClassIndicator(com.aon.amp.beans.enrichment.DropDownEnrichmentRule.class, "Y");
         // Descriptor Properties.
         descriptor.useNoIdentityMap();
         descriptor.setIdentityMapSize(100);
         descriptor.useRemoteNoIdentityMap();
         descriptor.setRemoteIdentityMapSize(100);
         descriptor.setIsIsolated(true);
         descriptor.setAlias("AbstractEnrichmentRule");
    sub class descriptor:
    public ClassDescriptor buildDropDownEnrichmentRuleDescriptor() {
         RelationalDescriptor descriptor = new RelationalDescriptor();
         descriptor.setJavaClass(com.aon.amp.beans.enrichment.DropDownEnrichmentRule.class);
         descriptor.addTableName("DROP_DOWN_ENRICHMENT_RULE");
         // Inheritance Properties.
         descriptor.getInheritancePolicy().setParentClass(com.aon.amp.beans.enrichment.AbstractEnrichmentRule.class);
         descriptor.getInheritancePolicy().dontReadSubclassesOnQueries();
         // Descriptor Properties.
         descriptor.setIsIsolated(true);
         descriptor.setAlias("DropDownEnrichmentRule");
         descriptor.setCacheSynchronizationType(ClassDescriptor.DO_NOT_SEND_CHANGES);
    ...and the exception/ SQL
    Problem details
    Internal Exception: java.sql.SQLException: ORA-00904: "T0"."DROP_DOWN_SQL": invalid identifier Error Code: 904 Call:SELECT t0.ENRICHMENT_RULE_ID, t0.DROP_DOWN_IND, t0.LABEL_EXPRESSION, t0.COLUMN_NUM, t0.ORDER_PRIORITY, t0.LABEL_NAME, t0.VALUE_EXPRESSION, t0.ENRICHMENT_RULE_TYPE_ID, t0.ENRICHMENT_RULE_ID, t0.DROP_DOWN_SQL FROM ENRICHMENT_RULE t0 WHERE (t0.ENRICHMENT_BASE_ID = ?) bind => [1] Query:ReadAllQuery(com.aon.amp.beans.enrichment.AbstractEnrichmentRule)

    Hello Paul,
    There is a difference in your descriptors that is causing the problem. In the DP3 descriptor, you have selected dontReadSubclassesOnQueries() option, meaning that queries to the base class will only return base class implementations.
    The DP4 descriptor instead has setReadAllSubclassesViewName("ENRICHMENT_RULE"), which is telling it that when a query is performed on the base class that TopLink should also return subclasses. It is also telling TopLink to do this in 1 query using the ENRICHMENT_RULE view table - this allows you to specify a view that joins all the inheritance tables. This option is good when you are using cursors and the like but still need to query on the base class to get the subclasses.
    Best Regards,
    Chris Delahunt

  • Embedded mapping (one table - two classes)

    I any using ebedded fileds (one table but two related classes like company-adress example in Developer Guide):
    <class name="StyleCoreImpl" detachable="true">
                   <field name="createdBy">
                        <embedded null-indicator-column="CREATEDBY_USER">
    <field name="date" column="CREATEDBY_DATE"/>
                        </embedded>
                   </field>
         </class>
    <class name="MadeByStatusImpl" detachable="true">
         <field name="date"/>
         <field name="user"/>
    </class>
    but get at runtime an error "No table was given for persistent type":
    <4|true|4.0.0> kodo.util.MetaDataException: No table was given for persistent type "com.ottogroup.buying.b2b.assortmentprep.domain.object.style.impl.MadeByStatusImpl".
         at kodo.jdbc.meta.MappingInfo.createTable(MappingInfo.java:479)
         at kodo.jdbc.meta.ClassMappingInfo.getTable(ClassMappingInfo.java:215)
         at kodo.jdbc.meta.strats.FullClassStrategy.map(FullClassStrategy.java:52)
         at kodo.jdbc.meta.ClassMapping.setStrategy(ClassMapping.java:349)
    Question:
    How should we map an embedded class which does not have any table in DB ?
    thanks
    Andre Teshler

    Hi Abe, we have following problem with proposed solution:
    Two embedded instances of the same type pointing to the sametarget
    · Problem
    We have an entity that holds date and user of creation and date and user of last change. The
    information is encapsulated in a state object which is mapped as an embedded object. The table
    holds both dates and the ids of the user. The user information is held in a separate user table. If
    we load the entity, the entity table is only joined once against the user table, even if the user ids for
    create and lastchange are different. In consequence, the user objects of the created and
    lastchange state are always the same.
    Question:
    Why is the fact that t0.createdby_user may differ from t0.lasteditedby_user ignored
    and t0 not joined twice against dbldapusermapping?
    Entities:
    public class MadeByStatusImpl {
    private UserImpl user = null;
    private Date date;
    /* getter and setter */
    public final class UserImpl {
    private long id;
    private String givenName = null;
    private String surname = null;
    /* getter and setter */
    public class StyleApprovalCheckImpl {
    private long id;
    private MadeByStatusImpl created = null;
    private MadeByStatusImpl lastChanged = null;
    private String comment = null;
    /* getter and setter */
    Mapping:
    <class name="MadeByStatusImpl" embedded-only="true">
    <field name="date"/>
    <field name="user"/>
    </class>
    <class name="UserImpl" table="DBLDAPUSERMAPPING" identitytype="
    application" detachable="true">
    <field name="id" primary-key="true" column="LDAPUSERMAPPINGID"/>
    <field name="givenName" column="GIVENNAME"/>
    <field name="surname" column="SURNAME"/>
    </class>
    <class name="StyleApprovalCheckImpl" table="DBSMAPPROVALCHECKENTRY"
    identity-type="application" detachable="true">
    <inheritance>
    <discriminator strategy="final"/>
    </inheritance>
    <field name="id" primary-key="true" sequence="Seq" column="ID"/>
    <field name="comment" column="APPROVALCOMMENT"/>
    <field name="created" default-fetch-group="true">
    <embedded>
    <field name="date" column="CREATEDBY_DATE"/>
    <field name="user" default-fetch-group="true"
    column="CREATEDBY_USER">
    <foreign-key/>
    </field>
    </embedded>
    </field>
    <field name="lastChanged" default-fetch-group="true">
    <embedded>
    <field name="date" column="LASTEDITEDBY_DATE"/>
    <field name="user" default-fetch-group="true"
    column="LASTEDITEDBY_USER">
    <foreign-key/>
    </field>
    </embedded>
    </field>
    </class>
    SQL:
    SELECT t0.smapprovalcheckentryid, t0.approvalcomment,
    t0.createdby_date, t1.ldapusermappingid, t1.givenname,
    t1.surname, t1.ldapuid, t0.lasteditedby_date
    FROM dbsmapprovalcheckentry t0,
    dbldapusermapping t1
    WHERE (t0.smstylesupplierid = 1)
    AND t0.createdby_user = t1.ldapusermappingid(+)
    thanks
    Andre Teshler

  • Mapping dimension table to fact table in admin tool 10g

    Hi
    I have a criteria when it is run uses fact 1 as fact table and gives result, and when I add new column to this criteria an extra dimension(dim1) gets added to query backend and fact 1 changes to fact2.
    The problem I am facing over here is both should result same amount for records. but due to new column from dim1 and new fact table fact2the amount varies and inaccruate results have come.
    When I have checked the sources for Fact in logical layer i can find these facts(fact1,fact2) where fact 1 is not mapped with dim 1 and fact 2 is mapped with dim1.
    Will mapping dim1 to fact1 will solve my problem.. And what would be the steps to add/map dim1 to fact1.
    Please suggest.

    I just checked back the setting and here are the changed details again.
    I have a criteria where when it is run, the backend query is formed with f1 fact table.
    And for the same criteria when I add a column c1, the backedn query is formed with f2 fact table and f1 is no more here and one new dimension d1 consisting c1 is getting added.
    In both the cases results are different..the expected thing is same results.
    Note:
    d1 is connected to f2 checked in physical diagram
    d1 is not connected to f1 checked in physical diagram.
    when I checked the connection between three table in physical diagram. Only d1 and f2 are connected and f1 is not connected to either of table. How to go about this issue.
    Please suggest.

  • Issue in Mapping Qualified Table in Import Manager

    Hi Experts
    I have extracted Customer data from R/3 ECC, I could successfully loaded reference data, but when trying to load Main table data (Using DEBMDM06 MAP) I am getting mapping issues with Qualified table (Sales Data and Bank Details).
    Error Messages
    Map 'Sales Data' field to import qualifier(s)
    Map 'Bank Detals' field to import qualifier(s)
    I have checked and found that all the field and value mapping is in place, If i remove mapping for the qualified table fields then the data is ready to import.
    What is the issue, and how do I import Qualified Table data.
    Appreciate your inputs
    Gaurav.

    Hi vickey ,
    Kindly go through the below link it will help you understand better the mapping the workinga nd importing of Qualified tables:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/00a15239-684e-2b10-b8ae-b936b7d1c1fe
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c03240fa-cc3e-2b10-aa9a-a5798e319a6e(Qualified importing with main table)
    Hope It Helped
    Thanks & Regards
    Simona Pinto

  • Error while mapping fact table to LOWEST LEVEL

    Hi
    While Iam mapping my fact table using cwm2_olap_table_map, map_facttbl_levelkey , Iam mentioning it has the lowest level of dimension table , it is throwing error . Will it only work for ET not for LOWEST LEVEL?. Infact Iam not storing the embedded total any where in my fact tables .
    Can anyone help me in mapping the lowest level of dimension to fact table????

    Hi
    Are you sure you are using the correct mapping tools. It sounds as if you have a relational schema which reauires a CWM mapping procedure? To map a relational schema it is best to use OEM which has wizards to guide you through the mapping process.
    CWM2 metadata is used to map 9iR2 Analytical Workspace objects. These typically involve fully summarised variables within the AW.
    Hope this helps
    Keith Laker
    Product Manager
    Oracle Business Intelligence Beans

Maybe you are looking for

  • To restrict a object to a particular Group at the Universe level

    Hi, I have a object which should be restricted only to a particular group at the universe level.So when i define the universe we have to have explicit security that will restrict access to this object information from reports and from ad-hoc queries.

  • Sender mail to ERP

    Hello Experts, i have a scenario were i need to pick attachment( pdf or file or text or excell) using mail adapter and send it to ERP ( ECC or SRM ). no need to convert the data into XML, just pass the attachment to ERP, but condition is not to AL11.

  • Changing brush size while erasing with adjustment brush.

    I have search around and have been unable to locate the short cut keys to increase and decrease the brush size while erasing. I use the bracket keys to change the brush size for the brush itself, but when I press the alt key to switch to the eraser,

  • Billing Due list data is not appearing

    We have created Service Contract. After releasing this Service Contract, Billing data is not appearing in Billing due list. Please provide info on how to make it appear.

  • ADF: Passing parameters from one page to another using setPropertyListener

    Hi, I'm trying to find a simple way to pass a parameter from one page to another. On the first page I have a table, the second page is a history page, showing the change history of rows from the table on the first page. In the table on the first page