JPA compound keys in entities

Hi, just a small question on how the compound keys work.
I'm developing an app using EclipseLink2.0. If I try to build an entity with a compound key composed by primitive types (such as String, int, java.sql.Date...) all is fine, but when I put in it a user-made Entity i get this error:
Exception [EclipseLink-7149] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The composite primary key attribute [idnomeCategoria] of type [null] on entity class [class entities.Sottocategoria] should be of the same type as defined on its primary key class [entities.SottocategoriaPK]. That is, it should be of type [entities.Categoria].where the entities are the following:
@Entity
@IdClass(SottocategoriaPK.class)
@Table(name = "sottocategoria")
public class Sottocategoria implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    private Categoria idnomeCategoria;
    @Id
    private String nomeSottocategoria;
    public Sottocategoria() {
    public Sottocategoria(Categoria idnomeCategoria, String nomeSottocategoria) {
        this.idnomeCategoria = idnomeCategoria;
        this.nomeSottocategoria = nomeSottocategoria;
    public Categoria getIdnomeCategoria() {
        return idnomeCategoria;
    public void setIdnomeCategoria(Categoria idnomeCategoria) {
        this.idnomeCategoria = idnomeCategoria;
    public String getNomeSottocategoria() {
        return nomeSottocategoria;
    public void setNomeSottocategoria(String nomeSottocategoria) {
        this.nomeSottocategoria = nomeSottocategoria;
public class SottocategoriaPK implements Serializable {
    private Categoria idnomeCategoria;
    private String nomeSottocategoria;
    public SottocategoriaPK() {
    public SottocategoriaPK(Categoria idnomeCategoria, String nomeSottocategoria) {
        this.idnomeCategoria = idnomeCategoria;
        this.nomeSottocategoria = nomeSottocategoria;
    public Categoria getIdnomeCategoria() {
        return idnomeCategoria;
    public void setIdnomeCategoria(Categoria idnomeCategoria) {
        this.idnomeCategoria = idnomeCategoria;
    public String getNomeSottocategoria() {
        return nomeSottocategoria;
    public void setNomeSottocategoria(String nomeSottocategoria) {
        this.nomeSottocategoria = nomeSottocategoria;
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idnomeCategoria != null ? idnomeCategoria.hashCode() : 0);
        hash += (nomeSottocategoria != null ? nomeSottocategoria.hashCode() : 0);
        return hash;
    @Override
    public boolean equals(Object object) {
        if (!(object instanceof SottocategoriaPK)) {
            return false;
        SottocategoriaPK other = (SottocategoriaPK) object;
        if ((this.idnomeCategoria == null && other.idnomeCategoria != null) || (this.idnomeCategoria != null && !this.idnomeCategoria.equals(other.idnomeCategoria))) {
            return false;
        if ((this.nomeSottocategoria == null && other.nomeSottocategoria != null) || (this.nomeSottocategoria != null && !this.nomeSottocategoria.equals(other.nomeSottocategoria))) {
            return false;
        return true;
    @Override
    public String toString() {
        return "entities.SottocategoriaPK[idnomeCategoria=" + idnomeCategoria + ", nomeSottocategoria=" + nomeSottocategoria + "]";
@Entity
@Table(name = "categoria")
public class Categoria implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "nomeCategoria", nullable = false, length = 70)
    private String nomeCategoria;
    public Categoria() {
    public Categoria(String nomeCategoria) {
        this.nomeCategoria = nomeCategoria;
    public String getNomeCategoria() {
        return nomeCategoria;
    public void setNomeCategoria(String nomeCategoria) {
        this.nomeCategoria = nomeCategoria;
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nomeCategoria != null ? nomeCategoria.hashCode() : 0);
        return hash;
    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Categoria)) {
            return false;
        Categoria other = (Categoria) object;
        if ((this.nomeCategoria == null && other.nomeCategoria != null) || (this.nomeCategoria != null && !this.nomeCategoria.equals(other.nomeCategoria))) {
            return false;
        return true;
    @Override
    public String toString() {
        return "entities.Categoria[nomeCategoria=" + nomeCategoria + "]";
EntityManagerFactory emf=Persistence.createEntityManagerFactory("tryPU");
EntityManager em = emf.createEntityManager();
Categoria c = new Categoria("prova");
Sottocategoria s = new Sottocategoria(c,"riprova");
em.getTransaction().begin();
em.persist(c);
em.persist(s);
em.getTransaction().commit();
em.close();If, instead of Categoria entity as part of the compound class, I put
String nomeCategoria;all is fine.
I wasn't able to figure out why... or where's the error.
Any suggestion on how to proceed?
My provvisional solution then is to use simple keys by putting an extra field as key of the entity (Sottocategoria in this case). Is that fine?
Thanks for the answers!
Edited by: muganz on Feb 25, 2010 10:37 PM

The JPA specification does not allow the use of Entities as PKs. In the specification the PKs must be primitive values or PK classes derived from related entites.
--Gordon                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Crystal Report with Compound Key

    Hi,
    I have Characteristic with Compound Key in SAP BW 7.0. This Characteristic use to store the Purchase Order Item Line. The Compound Key is the Purchase Order Document.
    So I will have the following fields created for this Characteristic:
    Compound Key (Purchase Order Document) 5600001982, Purchase Order Item Line 10
    I created a Query for this Characteristic and I have the following as result:
    10 ...
    20 ...
    30 ...
    All works fine.
    Now I created the Crystal Report from this Query. When I display this Characteristic in Crystal Report, I have the following:
    5600001982/10
    5600001982/20
    5600001982/30
    Is this a bug or Crystal not support the Compound Key?
    Please advise, thank you.

    Hello,
    Did you get this resolved.
    Were you able to display characteristics in Crystal without the compounding characteristic.
    Thanks.

  • Crystal Report and InfoObject with Compound Key

    Hi,
    I have Characteristic with Compound Key in SAP BW 7.0. This Characteristic use to store the Purchase Order Item Line. The Compound Key is the Purchase Order Document.
    So I will have the following fields created for this Characteristic:
    Compound Key (Purchase Order Document) 5600001982, Purchase Order Item Line 10
    I created a Query for this Characteristic and I have the following as result:
    10 ...
    20 ...
    30 ...
    All works fine.
    Now I created the Crystal Report from this Query. When I display this Characteristic in Crystal Report, I have the following:
    5600001982/10
    5600001982/20
    5600001982/30
    Is this a bug or Crystal not support the Compound Key?
    Please advise, thank you.

    a

  • How to use the Compounding Key in BPC10NW like BW info objects?

    Hi experts.
    We are longing the suitable solution in BPC-NW 10.0 to deal with compounding key like BW info objects.
    We want to define the dimension with compounding key MATERIAL and PLANT, but BPC-NW 10.0 doesn't support it. Therefore we just defined the dimension "PLANT" as entity and "MATERIAL" as user-defined dimension with concatinated key "Material code-Plant code" as ID.
    For instance:
    -[Dimension PLANT] as type-E (entity)
    ID
    1000
    2000
    3000
    -[Dimension MATERIAL] as type-U (user-defined)
    ID        ENTITY MATNR
    1000-AAAA 1000   AAAA
    1000-BBBB 1000   BBBB
    2000-AAAA 2000   AAAA
    2000-CCCC 2000   CCCC
    3000-BBBB 3000   BBBB
    3000-CCCC 3000   CCCC
    (ENTITY and MATNR were defined as properties, and ENTITY filled the each member including dimension Plant)
    Now we built a input form with following conditions:
    -Page axis : ACCOUNT=Revenue, etc...
    -Row axis : ENTITY=1000 or 2000, MATERIAL=all
    -Column axis : TIME=Jan, Feb, Mar...
    The result report came out as follows:
    Revenue
    PLANT  MATERIAL   Jan Feb Mar ...
    1000   1000-AAAA  0   0   0   ...
    1000   1000-BBBB  0   0   0   ...
    1000   2000-AAAA  0   0   0   ...
    1000   2000-CCCC  0   0   0   ...
    1000   3000-BBBB  0   0   0   ...
    1000   3000-CCCC  0   0   0   ...
    2000   1000-AAAA  0   0   0   ...
    2000   1000-BBBB  0   0   0   ...
    2000   2000-AAAA  0   0   0   ...
    2000   2000-CCCC  0   0   0   ...
    2000   3000-BBBB  0   0   0   ...
    2000   3000-CCCC  0   0   0   ...
    But we expected to have a report restricted MATERIAL with their property on specified PLANT in member selector such as:
    Revenue
    PLANT  MATERIAL   Jan Feb Mar ...
    1000   1000-AAAA  0   0   0   ...
    1000   1000-BBBB  0   0   0   ...
    2000   2000-AAAA  0   0   0   ...
    2000   2000-CCCC  0   0   0   ...
    How do we obtain the expected result? Please give us the good solution!
    Best regards,
    Masa

    Hi Vadim.
    GREAT! Our requirement is fulfilled by that way you described. Special thanks for your help!!!
    Best regards,
    Masa

  • How to write hasCode() & equals(0) methods in Compound Key Class

    Hi Java Helpdesk,
    I am wondering how to write the hashCode() and equals() methods that is mandatory when creating composite
    @IdClass. Below is the combination of primary @Id keys that I would like to make up in a compound key class:
    public final class PatientKey implements java.io.Serializable
        private String firstnameId;
        private String SurnameId;
        private String DateOfBirthID;
        private String Sex;
        public int hashCode()
        public boolean equals(Object otherOb)
    }The Order application in Java EE 5 Tutorial (page 841) is made up of only 2 primary keys.
    Thanks,
    Jack

    Hi,
    Thanks for your very brief response and I had a look at both EqualsBuilder and HashCodeBuilder from the URL links you have provided. These methods may improve the comparison accuracy but I was more interested on how to implement the equals() and hashCode methods when comparing 3 or more primary keys in order to make up a primary key class. Below is my first attempt to compose the PatientPK primary key class:
    1. public class PatientPK implements java.io.Serializable {
    2.
    3.     private String firstName;
    4.     private String lastName;
    5.     private String dateOfBirth;
    6.     private Char sex;
    7.
    8.     public PatientPK() {}
    9.
    10.   public PatientPK(String firstName, String lastName, Date dateOfBirth, Char sex)
    11.   {
    12.       this.firstName = firstName;
    13.       this.lastName = lastName;
    14.       this.dateOfBirth = dateOfBirth;
    15.       this.sex = sex;
    16.   }
    17.
    18.   public String getFirstName() { return this.firstName; }
    19.   public void setFirstName(String firstname) { this.firstName = firstName; }
    20.
    21.   public String getlastName() { return this.lastName; }
    22.   public void setLastname(String lastName) { this.lastName = lastName; }
    23.
    24.   public String getDateOfBirth() { return this.dateOfBirth; }
    25.   public void setDateOfBirth(String dateOfBirth) { this.dateOfBirth = dateOfBirth; }
    26.
    27.   public Char getSex() { return this.sex; }
    28.   public void setSex(String sex) { this.sex = sex; }
    29.
    30.   public boolean equals(Object obj)
    31.   {
    32.       if (obj == this) return true;
    33.       if (!(obj instanceof PatientPK)) return false;
    34.       PatientPK pk = (PatientPK) obj;
    35.       if (!firstName.equals(pk.firstName)) return false;
    36.       if (!lastName.equals(pk.lastName)) return false;
    37.       if (!dateOfBirth.equals(pk.dateOfBirth)) return false;
    38.       if (!sex.equals(pk.sex)) return false;
    39.       return true;
    40.   }
    41.
    42.   public hashCode()
    43.   {
    44.       return firstName.hashCode() + lastName.hashCode() + dateOfBirth.hashCode() + sex.hashCode();
    45.   }
    46.}Please advice whether both these equals() and hashCode() implementations are correct.
    Thanks in advance,
    Jack

  • Compound key value

    Hi,
    I define "Order No" as Master data InfoObject and compounding as "ORDTYPE"
    In my query when i select ORDER NO i am also seeing ORDTYPE VALUE
    For Example:  Order No: 12345, Order Type : S4
    When I select Order no in my report the output I am getting : 12345/S4
    But I only want :12345
    How can we achvive this

    I can not filter ORDTYPE because If I do I can't see ordertype.
    I want ORDERTYPE is diplaying as "S4" that is correct.
    when i select ORDERNO i am getting 12345/S4 because of compounding key.
    Example:
    ORDERNO                   ORDERTYPE
    12345/S4                            S4
    I want like this
    ORDERNO                   ORDERTYPE
    12345                                 S4
    How can we achive this result?

  • CMR 1:M with compound keys?

    Pardon a possible repost, my original post disappeared.
    I've got two tables with compound PKs. Does OC4J 9.0.3 support CMR for CMP beans with compound keys?
    Thanks!

    April,
    I built a simple CMR Employee -> TimeCards (empno, timecardno as composite PK)
    Here is the orion-ejb-jar.xml that demonstrates the ampping:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
    <orion-ejb-jar>
    <enterprise-beans>
    <entity-deployment name="Employee" data-source="jdbc/OracleDS" table="EMP">
    <primkey-mapping>
    <cmp-field-mapping name="empno" persistence-name="EMPNO" persistence-type="NUMBER(4)"/>
    </primkey-mapping>
    <cmp-field-mapping name="empno" persistence-name="EMPNO" persistence-type="NUMBER(4)"/>
    <cmp-field-mapping name="ename" persistence-name="ENAME" persistence-type="VARCHAR2(10)"/>
    <cmp-field-mapping name="job" persistence-name="JOB" persistence-type="VARCHAR2(9)"/>
    <cmp-field-mapping name="mgr" persistence-name="MGR" persistence-type="NUMBER(4)"/>
    <cmp-field-mapping name="hiredate" persistence-name="HIREDATE" persistence-type="DATE"/>
    <cmp-field-mapping name="sal" persistence-name="SAL" persistence-type="NUMBER(7,2)"/>
    <cmp-field-mapping name="comm" persistence-name="COMM" persistence-type="NUMBER(7,2)"/>
    <cmp-field-mapping name="deptno" persistence-name="DEPTNO" persistence-type="NUMBER(2)"/>
    <cmp-field-mapping name="timecard_empno">
    <collection-mapping table="TIMECARDS">
    <primkey-mapping>
    <cmp-field-mapping>
    <entity-ref home="Employee">
    <cmp-field-mapping persistence-name="EMPNO" persistence-type="NUMBER(4)"/>
    </entity-ref>
    </cmp-field-mapping>
    </primkey-mapping>
    <value-mapping type="debu.cmr3.TimecardLocal">
    <cmp-field-mapping>
    <entity-ref home="Timecard">
    <cmp-field-mapping>
    <fields>
    <cmp-field-mapping name="empno" persistence-name="EMPNO" persistence-type="NUMBER(4)"/>
    <cmp-field-mapping name="timecardno" persistence-name="TIMECARDNO" persistence-type="NUMBER(10)"/>
    </fields>
    </cmp-field-mapping>
    </entity-ref>
    </cmp-field-mapping>
    </value-mapping>
    </collection-mapping>
    </cmp-field-mapping>
    </entity-deployment>
    <entity-deployment name="Timecard" data-source="jdbc/OracleDS" table="TIMECARDS">
    <primkey-mapping>
    <cmp-field-mapping>
    <fields>
    <cmp-field-mapping name="empno" persistence-name="EMPNO" persistence-type="NUMBER(4)"/>
    <cmp-field-mapping name="timecardno" persistence-name="TIMECARDNO" persistence-type="NUMBER(10)"/>
    </fields>
    </cmp-field-mapping>
    </primkey-mapping>
    <cmp-field-mapping name="timecardno" persistence-name="TIMECARDNO" persistence-type="NUMBER(10)"/>
    <cmp-field-mapping name="workhours" persistence-name="WORKHOURS" persistence-type="NUMBER(4,2)"/>
    <cmp-field-mapping name="timecarddate" persistence-name="TIMECARDDATE" persistence-type="DATE"/>
    <cmp-field-mapping name="employee_empno">
    <entity-ref home="Employee">
    <cmp-field-mapping persistence-name="EMPNO" persistence-type="NUMBER(4)"/>
    </entity-ref>
    </cmp-field-mapping>
    </entity-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping impliesAll="true" name="&lt;default-ejb-caller-role>"/>
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>

  • BroadcastOutputAdapter: monotonic compound keys - possible?

    I'm trying to architect my app to use BroadcastOutputAdapter.
    I'd like to use compound keys to be able to identify events based on timestamp and a custom property. I'm also trying to use monotonic approach as my key is based on a timestamp and have only a custom value to differentiate one from the other (like the accountId sample from the cep developer guide).
    However, when implementing the key based on the "Example 21–25" of CEP Dev Guide, I got an error saying my compound key class must implement Comparable.
    That's where my doubt is: how can I implement comparable and still take into account the custom property in the comparison as the comparable is just about bigger, smaller, and equal? Seems that if I use only the timestamp value, my custom property would be ingored and I would compare just based on the timestamp and I could end up comparing timestamp from key of accountId = A with timestamp from key of accountid = B.
    Thanks,
    Daniel

    Hi Junger,
    The point is that I may have the following events being output:
    ID TS
    A 9
    A 10
    B 7
    B 8
    In this case, I'm interested in all messages for A and B however, seems to me (please, correct me if I'm wrong) that if I compare only the timestamp, I'll consider timestamps 7 and 8 to be smaller than the timestamps 9 and 10, however they are output for different IDs and the events for ID B would be pruned and I can't afford that.
    Am I right?
    Thanks
    Daniel

  • CMR with Compound Keys

    Is it possible in S1AS7 to have a CMR with two entity beans that are each composed of compound keys?
    For example:
    Bean A:
    Primary key: variable1 & variable2
    Bean B:
    Primary key: variable1 & variable2 & variable3
    CMR is 1-N (Bean A has many of Bean B) and associated on variable1 and variable2.
    Any help would be grateful.
    Matt

    Hi Matt,
    You can map your beans like:
    <entity-mapping>
    <ejb-name>Schedule</ejb-name>
    <table-name>SCHEDULE</table-name>
    <cmp-field-mapping>
    <field-name>runner</field-name>
    <column-name>SCHEDULE.RUNNER</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>scheduleName</field-name>
    <column-name>SCHEDULE.SCHEDULENAME</column-name>
    </cmp-field-mapping>
    <cmr-field-mapping>
    <cmr-field-name>scheduleRunDefinitions</cmr-field-name>
    <column-pair>
    <column-name>SCHEDULE.RUNNER</column-name>
    <column-name>SCHEDULERUNDEFINITION.RUNNER</column-name>
    </column-pair>
    <column-pair>
    <column-name>SCHEDULE.SCHEDULENAME</column-name>
    <column-name>SCHEDULERUNDEFINITION.SCHEDULENAME</column-name>
    </column-pair>
    </cmr-field-mapping>
    </entity-mapping>
    <entity-mapping>
    <ejb-name>ScheduleRunDefinition</ejb-name>
    <table-name>SCHEDULERUNDEFINITION</table-name>
    <cmp-field-mapping>
    <field-name>runner</field-name>
    <column-name>SCHEDULERUNDEFINITION.RUNNER</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>scheduleName</field-name>
    <column-name>SCHEDULERUNDEFINITION.SCHEDULENAME</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>runDay</field-name>
    <column-name>SCHEDULERUNDEFINITION.RUNDAY</column-name>
    </cmp-field-mapping>
    <cmp-field-mapping>
    <field-name>runNumber</field-name>
    <column-name>SCHEDULERUNDEFINITION.RUNNUMBER</column-name>
    </cmp-field-mapping>
    <cmr-field-mapping>
    <cmr-field-name>schedule</cmr-field-name>
    <column-pair>
    <column-name>SCHEDULERUNDEFINITION.RUNNER</column-name>
    <column-name>SCHEDULE.RUNNER</column-name>
    </column-pair>
    <column-pair>
    <column-name>SCHEDULERUNDEFINITION.SCHEDULENAME</column-name>
    <column-name>SCHEDULE.SCHEDULENAME</column-name>
    </column-pair>
    </cmr-field-mapping>
    </entity-mapping>
    Please let me know, if you have further questions!
    -- markus.

  • Compound key values

    Hi,
    I define ITEM NO as main infoobject and compound key fields as Branch, Location, lotno, and fiscal year. When I select ITEM NO in the report I am getting all key field values.For example sample data: BRAN1/LOC1/LOT1/200604/ITEM01 but I want only ITEM01 as output. What I did I put the Branch, Location, Lot no, fiscal year under Filter still its giving whole key values when I select ITEMNO. Can anybody have any idea?
    Thanks in advance
    Randy

    Hi,
    this is the usual behaviour for compunded characteristics.
    If you drilldown the coumpounding chars of your ITEM, they will disappear from the display.
    One nice way to avoid this behaviour in to add a navigational attr in your char which you'll populate with the same value then the value populating your ITEM.
    By doing this you'll be able to see your ITEM value "detached" of its coumpounding characteristics values...
    hope this helps...
    Olivier.

  • User Exit  for Compounded Key

    I have written a FM that was included in a user exit.  The purpose of my user exit is to restrict  certain  Accounts that my Query uses.  The problem that I run into is that the  Account is a numerical value which is NOT a key.  For example, I could have one  account that exists in two different reporting divisions such as Africa and Asia and might not want to restrict Africa.  If I don't take into consideration the divison, then I will be eliminating required  Accounts.  I thought about creating a seperate user exit for the reporting division but then I might run into the problem of eliminating certain  Accounts that are associated with that division.  I'm thinking that If I create another user exit for the division, then I will somehow have to link the two(not sure how this would work). Secondly, the divison and account is a compounded key in my InfoCube.  There is not InfoObject that holds the compounded key so I can not create a variable of this type.
    I'm not sure what would be the best way to solve this problem so any input you can give is greatly appreciated.
    Thanks,
    Nyrvole

    Hi Reddy,
    This user exit can creating & activating in project by using CMOD Transaction code.
    AFAR0002 is Enhanc for external determination of depreciation.
    Thank you
    Anil

  • Compound Key

    Creating a master list that selects an update/insert form is quite simple if the tables have a primary key which is one column. I have many tables (doesn't everyone?), that are dependent tables and therefore require a compound key (i.e., parent key/child key), where there is one parent with many children.
    The ADDT Create Dynamic List Wizard has a place to specify the primary key; however, it is only one column. How do I tell it that it needs to pass both the parent and child keys to the form, and how do I specify in the form that it is to look at both URL parameters?

    Hi T A K
    Thanks for confirmation.
    So I would say all the Compound Keys is normally updated by the Attribute datasource, correct?
    I have another question, if I would like to put in the coding in the Routine like:
    If 0GL_Account is >= 100000 then
    Chart of Account = "EURO
    Else
    Chart of Account = "USTX"
    End if.
    I would like this coding to be place in the Routine of Transfer Structure of the 0GL_Datasource Attribute Datasource.
    Do you know if this possible?
    Can you please provide me real abap coding with correct syntax?

  • [JPA] Primary key = Foreign key = Failure.

    Hello:
    I've a question regarding the Java Persistence API and a DB design which I'm facing just now. I'm making JPA entities based on a DB schema which is already created. Although sometimes it's not a good idea, I'm going to use a simplified example so you can understand it easily and help me (if you want, of course).
    Let's suppose that I've a table of discs (called "disc", built into a class as "Disc.class") and another one of used discs (called "disc_used", built as "DiscUsed.class"). The first one employs a composite key formed by columns "key1" and "key2". The second one employs the same primary key (conceptually, not physically) which, at the same time, is foreign key respect to the first table.
    I've used the @EmbeddedId annotation on the first case and built a class for the composite key (called "DiscPK.class"). I've done the same task for the second table (calling it "DiscUsedPK.class"). I also have added the corresponding mappings between both classes (of type @OneToOne). This design pattern works fine when employing "Disc.class", but not "DiscUsed.class". I've came to the conclusion that it's because of using the same fields to make an @EmbeddedId and map the @OneToOne relation.
    I've been taking a deep look to the possible annotations which JPA offers, but I've not found anything useful.
    In the past I faced another problem with JPA and composite keys, which made me come to the conclusion that it was my DB design what was faulty (I was combining an auto-numerical field with others to make a composite key, which helped me to understand the logic but was absurd and against the relational logic). May it be a similar misconception on the DB design? I mean, since both tables represent different concepts (discs and used discs), each one with their own attributes (columns), Should the second table use its own auto-numerical primary key instead of re-use the foreign key? Would it be the right approach according to the relational logic?
    Obviously, modifying the original DB by hand and adding its own primary key, it works flawless. However I still need to know the truth (other-way I won't be able to sleep :P ).
    Thank you for your help and interest.

    gimbal2: I'm really sorry, but I didn't get any e-mail notification about your message :S . After having looked for help on several places on the Internet I finally decided not to employ exactly the same columns for a primary key if they were already being employed by a foreign key. The answer from javaUserMuser has also left this matter clarified to me. Thanks for your time also ;) .
    javaUserMuser: I thought that was a problem from my implementation. If it's a common case, then I guess that I did right choosing the easy "path" for one time :) . I agree with you, it's a big frustration. But since I depend on the JPA for my projects, I'll try to set my mind to avoid always this match and employ another primary key instead. Thank you a lot for your explanation :D .

  • How to make 0datefrom a compounding key to master data having single key ?

    Dear Experts,
    I am trying to add 0DateFrom to compound a master data object via RSD1.
    In the Compounding tab, i keyed in the 0DateFrom and tried to activate but system does not allow :
    Message :
    Characteristic ZCONxxx: InfoObject 0DATEFROM is not allowed in the compound
    Message no. R7596
    Diagnosis
    InfoObjects 0DATETO 'Valid to' and 0DATEFROM 'Valid from' are not allowed in the compound.
    System Response
    Characteristic ZCONxxx can not be activated.
    Procedure
    Define attributes or the texts for the characteristic as time-dependent. The fields 'Valid from' and 'Valid to' will then be automatically included in the master data tables or text tables.
    I then followed the advise on from the message and ticked the DateFrom attribute in the master data. This attribute is existing one. But the system says :
    Characteristic ZCONxxx: Attribute 0DATETO cannot be used w. time-dependent attribte
    Please advise. I must compound the master data with datefrom. How can it be done when BI disallows?
    Thanks in advance.
    regards
    Pascal
    Edited by: Pascal Gabin on Aug 15, 2011 10:47 AM

    Hi
    In SAP standard reminders are triggered based on requirement type 103 (dunning). Instandard it is assigned to output type MAHN. You can create a new requirement by modifying requirement 103 which considers confirmation entered in PO. Then it can be assigned to the reminder output type in output schema.
    Regards
    Antony

  • How to get rid of compounded keys on WebI report

    Hello,
    I am (very) new to Business Objects and Web Intelligence, and have created a Universe on a BW multicube.<br />
    When I setup the WebI report doc, the Fiscal year (and Fiscal Period/year) are showing with the Fiscal Variant as a prefix (e.g. Z3/2009). <br /> <br />
    Using a formula to 'strip' the characteristic to 2009 confuses the data (as there is no 'key' of 2009, only Z3/2009).
    Filtering by Fiscal Variant (the Z3 part) doesn't seem to change things, or even putting the fiscal variant in as a column (these techniques used to work quite nicely in Bex and Web Bex).<br />
    Is there some magic I have missed in the Universe building process (which I have purposefully kept very simple, as there are plenty of these to build!!).<br /> <br />
    I am sure folks have seen (and sovled) this before, as Fiscal Year (and Fiscal Period/year) must be used often, and these are standard SAP time fields.<br />
    However, i can find nothing in help or even forums (perhaps I am not searching for correct key words).<br /> <br />
    I haven't tried building the universe off a Bex Query, and am kind of reluctant to do this, as it builds in another layer to maintain.<br /> <br />
    Anyone know how to get rid of the compounded part of the (fiscal year) objects?<br /> <br />
    Your help and comments are much appreciated.<br /> <br />
    Regards,<br />
    Martin.

    Hi Ingo,
    I am also facing the same problem.
    I have an object Showing (TR/1223xxxx). I was able to remove "TR/" in bex by dragging the compunded object in Rows section and supressing it to "No Display" but in Webi I am still getting (TR/1223xxxx).
    In Webi if I create a formula and trim the above value, i am getting "#UNAVAILABLE" in Key Figures, i.e. measures (smar Measures)
    Is there a way to get rid of this compunded value.
    One more requirement, in Bex Query, I am giving dislay as "Key and Text" but in Webi, i get only "Text" for that object. I have to explicitply drag and use the Object - key (detail object of that particular dimension). Is there a way to get both Key and Text in Webi using a single object.
    Kindly help. Thank You!
    Edited by: Aikansh on Mar 9, 2012 8:49 AM

Maybe you are looking for