@ManyToMany using Composite Key

I have searched this forum concerning this issue. While I see others with a similar question, I see very little on a possible solution. Here is my problem statement.
Class 1: Document.java
Class 2: Collection.java
Class 3: CollectionType.java
XRef Table: Document_Collection
Relationships:
A DocumentID may be inside many collections.
A CollectionID may have many documents.
The owner of the relationship is document.java.
The collection table uses 3 fields for defining a Primary Key--Site, Name, and Date. The three fields are Strings.
I am using a SEQUENCE table for generating the unique Ids for each of the primary keys, except the Collection Table. This table is using a CompositePK Class for the Primary Key for the Collection Table.
Document.java:
@ManyToMany(cascade={CascadeType.ALL})
@JoinTable(name="DOCUMENT_COLLECTION",
                  joinColumns=@JoinColumn(name="DC_DOCUMENT_ID",           referencedColumnName="DOCUMENT_ID"),
       inverseJoinColumns={@JoinColumn(name="DC_COLLECTION_ID", referencedColumnName="SITE_ID"),
                                    @JoinColumn(name="DC_COLLECTION_ID", referencedColumnName="NAME"),
              @JoinColumn(name="DC_COLLECTION_ID", referencedColumnName="GROUP_DATE")}
public Set<Collection> getCollectionSet() {
          return collectionSet;
}Collection.java
@ManyToMany(mappedBy="collectionSet")
public Set<Document> getDocumentSet() {
     return documentSet;
}In the Collection Class it holds a reference to a Collection type.
CollectionType.java
@Id
@TableGenerator(name="COLLECTION_TYPE_TBL_GEN",
               table="SEQUENCE",
               pkColumnName="SEQ_NAME",
               valueColumnName="SEQ_COUNT",
               pkColumnValue="COLLECTION_TYPE_SEQ")
@GeneratedValue(strategy=GenerationType.TABLE,     generator="COLLECTION_TYPE_TBL_GEN")
@Column(name="COLLECTION_TYPE_ID", nullable=false)
public Long getCollectionTypeId() {
     return collectionTypeId;
}My test application builds the relationship for all the tables, and then attempts to persist the information to the database. When I look at at the log files, I see no errors, but the data is not being populated in the database. When I look at the SEQUENCE Table, I see all entries in the table are being incremented correctly except the Collection_Type sequence--still set to 1. I surmised the Collection Set for the Document_Collection table is not being populated correctly.
My intent is to let TopLink generate the PK, Ids for the objects. This appears to be happening for the one-to-one relationships but not for the ManyToMany relationships. When I build the relationships, I create the collection and CollectionType and add it to a set. This set is added to the Document class. Lastly, I call the persist method on the Entity Manager. The log file shows the sequence number is being generated except for the Collection_Type Sequence. This may not be the correct way, but I did not see the correct steps for accomplishing this operation.
[#|2007-08-27T16:52:03.899-0500|FINE|sun-appserver-pe9.0|oracle.toplink.essentials.file:/C:/glassfish/domains/domain1/applications/j2ee-apps/MyProject/MyEJB_jar/-MYEJBPU.sql|_ThreadID=12;_ThreadName=httpWorkerThread-8080-0;ClassName=null;MethodName=null;_RequestID=22dc7e71-9cef-4824-920f-5b3a2464c1d9;|SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = ?
     bind => [URGENCY_SEQ]|#]This is how I build the Document Entity.
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public Document addDocument(Document docVO) {
          entityManager.joinTransaction();
          Document doc = new Document();
          DataType dataType = getDataType(docVO.getDataType().getDescription());
          UrgencyIndicator urgency  = getUrgencyIndicator(docVO.getUrgencyIndicator().getCode());
          DocMetaData metadata = getDocMetadata(docVO.getDocMetadata().getStoragePath());
          WeaponsSystem weaponsSys = getWeaponsSystem(docVO.getWeaponsSystem().getCode());
          FileType fileType = getFileType(docVO.getFileType().getExtension());
          Date sqlDate = new Date(new java.util.Date().getTime());
          Set<Collection> collectSet = getDocumentCollection("Site", "Name", sqlDate.toString());
          doc.setUrgencyIndicator(urgency);
          doc.setDocMetadata(metadata);
          doc.setFileType(fileType);
          doc.setWeaponsSystem(weaponsSys);
          doc.setDataType(dataType);
          doc.setCollectionSet(collectSet);
          entityManager.persist(doc);
          return doc;
}Any suggestions would be greatly appreciated.
Russ

Okay I figured out one of my problems. When you search using the EntityManager's find method, a null is returned should JPA not be able to find an entity. This led to not populating the Collection Type and Collection incorrectly....... Now all Sequence generators are working correctly....... However, I am still not storing information in the database. Grrrrrr

Similar Messages

  • Using Composite keys in Entity Beans

    Hi, I am trying to develop a test application with two entity beans, (1) OrderBean (key is a string called order_no) and (2) LineBean (key is order_no and an integer line_no) using CMP 2.0. Relationship between OrderBean to LineBean is 1 to many. I created a primary key class for LineBean called, LinePK with both order_no and line_no as the public members. My home interface for LineBean has the following three finder methods:
    public java.lang.Object findByPrimaryKey(LinePK lkey);
    public Collection findByOrder(String order_no);
    public Collection findByProduct(String product_id);
    I could provide sql for the OrderBean which has only one field(order_no) as primary key, but I don't know how to code appropriate SQL for the finder methods of LineBean involving a user defined primary key class (in my case LinePK with order_no and line_no). I am trying to deploy this application in J2EE RI server, but getting deployment errors saying invalid return types for the finder methods. In the deploytool I provided the primary key class for LineBean as java.lang.Object with no primary key field name. Any help in this matter with sample sql code is greatly appreciated. Thanks !!!

    Some things to consider:
    - Your findByPrimaryKey in the Remote interface needs to have the remote interface as return type
    - The implementation of the finder needs to have your primary key class as return type
    - If you're using CMP 2.0, you need to specify the search criteria as EJB QL
    Using CMP 2.0, you don't code findByPrimaryKey at all, all you need is the EJB QL for findByOrder/findByProduct in the deployment descriptor. The EJB QL for findByOrder would look like:
    select Object o from Line where o.order_no = ?1If you use BMP, you would code the findByPrimaryKey implementation like this:
    public LinePK ejbFindByPrimaryKey(LinePK pk) throws FinderException {
      String sql = "select order_no from line_table where line_no=? and order_no=?";
      InitialContext ic = new InitialContext();
      Object obj = ic.lookup("datasourcename");
      DataSource ds = (DataSource)PortableRemoteObject.narrow(obj, DataSource.class);
      Connection conn = ds.getConnection();
      try {
        PreparedStatement stmt = conn.prepareStatement(sql);
        try {
          stmt.setInteger(1, pk.line_no);
          stmt.setInteger(2, pk.order_no);
          ResultSet rs = stmt.executeQuery();
          if (!rs.next())
            throw new ObjectNotFoundException("not found: " + order_no + "." + line_no);
          return pk;
        finally {
          stmt.close();
      finally {
        conn.close();

  • HowTo: construct Composite key using other composite key?

    Hello. I don' undestand how is it possible to do.
    Please, see my code:
    @Entity
    @Table(name = "Person", schema = SCHEMA)
    public class Person {
         @Id
         @GeneratedValue
         @Column(name = "id")
         private int id;
         private String medialogyUid;
         private String firstName;
         private String lastName;
         private String patronymic;
         private String biography;
    @Entity
    @IdClass(Convocation.PK.class)
    @Table(name = "Convocation", schema = SCHEMA)
    public class Convocation {
         @Id
         private int number;
         @Id
         @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
         private Institution institution;
         private Date beginDate;
         private Date endDate;
         public Convocation(){
         public Convocation(Institution inst, int number, Date beginDate, Date endDate){
              this.institution = inst;
              this.number = number;
              this.beginDate = beginDate;
              this.endDate = endDate;
         public static final class PK implements Serializable {
              public int number;
              public int institution;
              public PK(){
              /**@param number is convocation,number
               * @param institution is convocation.institution.id
              public PK(int number, int institution){
                   this.number = number;
                   this.institution = institution;
              @Override
              public boolean equals(Object o) {
                   if (!(o instanceof PK))
                        return false;
                   PK oPK = (PK)o;
                   return this.number == oPK.number && this.institution  == oPK.institution;
              @Override
              public int hashCode() {
                   return ((number == 0) ? 0 : new Integer(number).hashCode()) ^ ((institution == 0) ? 0 : new Integer(institution).hashCode());
    //And finally the last class:
    @Entity
    @IdClass(DeputyMandate.PK.class)
    @Table(name = "DeputyMandate", schema = SCHEMA)
    public class DeputyMandate {
         @Id
        @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
         private Person person;
         @Id
         @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST})
         private Convocation convocation;
         private Date dateIn;
         private Date dateOut;
         public static final class PK implements Serializable {
                   //don't know what to use @Embeddable or what?
        }I want DeputyMandate to use composite key. This composite key is based on Person with simple key +(int id)+ and Convocation PK.
    Please, tell me how can I make composite key DeputyMandate.PK using simple key from Person and composite key from Convocation.
    Edited by: Holod on 27.08.2008 15:52

    And
    CONSTRAINT FK_CONFIG_OPTION_ID FOREIGN KEY (CONFIG_ITEM_ID,CONFIG_OPTION_ID) REFERENCES PRODUCT_CONFIG_OPTION(CONFIG_ITEM_ID,CONFIG_OPTION_ID)
    ?

  • Access key to  use Composite Application Services

    I am using Sap Net Weaver Developer Studio version 7.0.Its prompting me for an
    access key to use composite application framework  perspective.Its not downloaded from sdn.
    regards,
    ms.

    Hi mythri,
       Better to use Net Weaver Developer 7.0.6 and make sure that you have to use
    Netweaver 2004s.
    Regards
    Srikanth

  • Delete Reconciliation fails when a Composite Key is used

    Hi Guys ,
    Problem Statement :-
    I am facing problem in performing delete reconciliation when a composite key is used.It fails whenever we have more than one attribute as key
    in reconciliation field mappings.
    I am using prepareDeleteReconData() ..etc Api's to perform delete reconciliation. I am not using CreateDeleteReconciliationEvent() as i dont know which users are deleted.
    UseCase
    For eg . Consider Oracle DataBase UM connector , where you have composite key defined as (UserID and ITResource), it fails to generate a delete reconciliation event.
    Have anybody faced this ?? Any workarounds ?
    Thanks
    Surendra Singh

    Hey Surendra,
    This is what you can do to get rid of this problem. I kow you cannot use the 'createDeleetReconciliationEvent' API, but just to let you know that this works absolutely fine. Now The approach which you might be using has the following flow-
    - provideDeletionDetectionData()
    - getMissingAccounts()
    - deleteDetectedAccounts()
    Now you must be aware that getMissingAccounts() returns a ResultSet for all the instances which needs to be revoked in OIM. If you see the contents of this ResultSet, here is what it contains (4 columns):
    Objects.Key, Objects.Name, Structure Utility.Table Name, Process Instance.Key
    Now what I suggest is do not use the deleteDetectedAccounts API as of now. And Revoke the object instance using API call. Follow the following steps:
    1) Just iterate through the ResultSet *(deletedUsers)* obtained from 'getMissingAccounts()' to fetch the value 'Process Instance.Key' and store it in an Array.
    2) You must be passing the Object Name as a Task Attribute. Use this attribute to fetch the 'Object Key'. Once you get this value, use the 'getAssociatedUsers' API of objectOperationsIntf to find all the users associated with this object. This API will return a ResultSet. Let's name it as *'AssoUsers'*.
    3) Iterate the above ResultSet(AssoUsers) and fetch the *'Process Instance.Key'* column from its rows. Compare this value to the already created Array in step-1. If there is a match then you will know that this resource instance needs to be revoked.
    4) Now fetch the following two values from the ResultSet(AssoUsers):
    - Users.Key
    - Object Instance.Key
    5) Once you get the User Key, you will have to find its corresponding resources. Do it by using *'getObjects'* API of userOperationsIntf. This will again return a resultSet *(userObjects)*.
    6) Iterate through all the rows and check the value of column *'Objects.Name'*. If this value equals to your resource, then fetch the value of column- Users-Object Instance For User.Key from this row.
    7) This will give you the 'Object instnace for User key'.
    8) Call the revokeObject API of userOperationsIntf interface.
    Below is a sample code snippet for your reference.
              Array DeletedUsers = {Your Deleted User List Array};
              String ObjectName = "Your Object Name as it comes from Task Attribute";
              long ObjectKey = 1; // Fetch it from Object Name above using API
              HashMap dummy = new HashMap();
              tcResultSet AssoUsers = objectOperationsIntf.getAssociatedUsers(ObjectKey, dummy);
              for (int i=0 ; i<AssoUsers.getRowCount() ; i++) {
                   AssoUsers.goToRow(i);               
                   String piKey = AssoUsers.getStringValue("Process Instance.Key");
                   if("Your Array DeletedUsers contains piKey"){
                        long userKey = AssoUsers.getLongValue("Users.Key");
                        long obiKey = AssoUsers.getLongValue("Object Instance.Key");
                        logger.debug("userKey extracted is : " + userKey);
                        logger.debug("obiKey extracted is : " + obiKey);                    
                        tcResultSet userObjects = userOperationsIntf.getObjects(userKey);
                        for(int j=0 ; j<userObjects.getRowCount() ; j++) {
                             userObjects.goToRow(j);
                             if(ObjectName.equalsIgnoreCase(userObjects.getStringValue("Objects.Name"))) {                              
                                  long obiuKey = userObjects.getLongValue("Users-Object Instance For User.Key");
                                  userOperationsIntf.revokeObject(userKey, obiuKey);
                                  logger.debug("Resource has been revoked");
    This should work. I know this looks quiet complex but have to do it. Give it a try.
    Thanks
    Sunny

  • Composite key field is not a simple type or enum

    According to the docs here - http://www.oracle.com/technology/documentation/berkeley-db/je/java/index.html?com/sleepycat/persist/model/PrimaryKey.html - you can use "A composite key class containing one or more simple type or enum fields" as a key field. When we try that we get "java.lang.IllegalArgumentException: Composite key field is not a simple type or enum: Result$Key.recordId". Am I misreading the docs?
    Thanks,
    Trevor
    @Persistent
    public final class RecordKey {
    @KeyField(1)
    private final String name;
    @KeyField(2)
    private final int duplicateNumber;
    RecordKey(final String name, final int duplicateNumber) {
    this.name = name;
    this.duplicateNumber = duplicateNumber;
    RecordKey() {
    this.name = null;
    this.duplicateNumber = -1;
    @Persistent
    static final class Key {
    @KeyField(1)
    private final RecordKey recordId;
    @KeyField(2)
    private final String key;
    Key(final RecordKey recordId, final String key) {
    this.recordId = recordId;
    this.key = key;
    Key() {
    this.recordId = null;
    this.key = null;
    }

    Hi Trevor,
    You're nesting one key class inside another. All fields of a key class must be simple types or enums, which is what the exception message is trying to say. If you want all those fields in your key class, you'll have to include them in a single flattened class.
    Neither nesting of key classes nor inheritance of key classes is supported. We have enhancements filed to support these in the future, but no concrete plans.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Setting composite key in Container Managed Entity Bean

    In my database table i set primary key to two columns making them as composite key. how do i set that in my container managed entity bean home interface findByPrimaryKey() method and in deployment descriptor file.

    1. create another class (say CompositePK) that will embed the two fields keyA and keyB corresponding to the two pk of your table (declare them public) .
    2. in your Bean declare keyA and keyB public.
    3. in the dd declare your bean primary-key-class as CompositePK and the primary-key-field as keyA and keyB.
    this is the method i use (with BAS) even if the key is simple (such as Integer).

  • Trouble with a composite key & unique violation

    Hi all
    as mentioned yesterday I'm a novice so apologies in advance for any lack of clarity in my question:
    I'm doing the standard student estate agent database and I have come across an issue with a composite key.
    the table in question follows:
    CREATE TABLE Offer
    buyer_id CHAR(5) not null references buyer (buyer_id),
    property_id CHAR(5) not null references property (property_id),
    primary key (BUYER_ID, PROPERTY_ID),
    offer_date DATE not null,
    offer_time NUMBER(4) not null,
    offer_amount NUMBER(10,2) not null
    and I have all the other tables in position with data loaded. However, when I try to load data into this table the buyer_id & property_id can be duplicated (it makes sense a buyer could make several offers on the same property).
    I'm not sure how to get around it. When I simply remove the primary key line the the next line offer_date.... is not recognized. I'm I missing something obvious? I am not allowed to changed the structure of the table. Do I need another identifier for the composite key?
    thanks Jo

    If you want to stick with natural primary keys, you would probably need to use the combination of (buyer_id, property_id, offer_date), assuming that the same buyer wouldn't make simultaneous offers on the same property. Given that this creates a rather unwieldy key for any child tables to reference, and given that the BUYER and PROPERTY tables appear to have synthetic foreign keys, you would probably want to add an OFFER_ID column to your table that is the primary key for the table and is populated via a sequence.
    Justin

  • (EJB-3) Can a many-to-one/one-to-may join field be part of a composite key?

    I've been setting up my first set of EJB-3 entites and I'm hitting an error I can't see the reason for. I don't have the code with me here- I'll add it to the thread tomorrow if there isn't a simple answer in the meantime.
    Two entity classes, Invoice and VatTotal. Invoice has a synthetic key, VatTotal is keyed on invoive id and vat code. VatTotals are children of the Invoice.
    So I code a Key class for the VatTotal entity, with Invoice and VatCode fields (VatCode is just a String). I define a ManyToOne property called invoice in VatCode and mark it @Id and a OneToMany field in Invoice called totals with type List<VatCode>
    Netbeans seems to accept it, but when I try and create the EntityManagerFactory (using Hibernate) it rejects the mappedBy=invoice on the OneToMany in Invoice.
    Does Hibernate accept ManyToOne properties as part of a composite key? Is there a problem using such a property in a OneToMany? Maybe I've done something dumb, but I can't see it.

    I don't think so. And I've seen some anomolies in the print preview (parts of messages getting cut off or munged up).

  • DATE Field in composite key

    Hi experts.
    I have a small query.
    Is there any performance impact of having a date field along with four other fields as part of a composite key.

    When you add an index, there is definitely some overhead to get the index synchronized with newly added/updated data (so whether you have indexed NUMBER, CHARs or DATEs does not matter - but I could be wrong in saying this).
    Concerning your SELECTs, if your existing queries were using this index then they may or may not use the new index (due to cardinality and other factors); so you need to test this first.

  • Primary Key in DW and indexes - composite key of all dimensional FKs?

    Hi guys,
    I have a DW and indexing question. Our metadata DW and physical DW are the same (star schema, no snowflakes). Should all dimensional FKs (such as TIME_KEY, ORG_KEY) be included as a part of a fact table's PK (a composite key becomes a combination of the TIME_KEY, ORG_KEY, etc.) in the database. Second question is, should we create just 1 composite index per fact table (resembling fact table's PK) or should we build several indexes (1 per dimension) ? Also, does it pay to build indexes on dimension tables?
    I'm mostly worried about fact table with a few hundred million records that has 7 dimensional-FK columns(only numeric codes), 1 value column, and several ETL-related date columns. I wonder what's the best course scenario be for that one.
    Thank you.

    You can use bitmap indexes on foreign keys to enable star transformations to be carried out. There are full details in the Datawarehouse documentation. Unfortunately I can't access it at the moment to show you where!
    As with anything you can check your performance using oracle trace events (10046) to ensure its performing as you want.
    http://www.dwoptimize.com/2007/06/101010-answer-to-life-universe-and.html
    Edited by: Matt T on Oct 22, 2008 4:50 PM

  • Composite key in Time dimension

    Hi All,
    I would like to know Time dimension with Composite key. I have a requirement where I want to store 2 Calendars in Time dimension table. for e.g :
    for one calendar Weekstarts from SUN-SAT and for another it is from MON-TUE
    DateKey   Type WeekStart   WeekEnd
    20140101   1       Sun               Sat      
    20140101   2       Mon               Tue
    ..................etc
    I have a measure group which is related to Time dimension (DateKey and Type used a Composite key). This implementation has no issues for additive measures but there are few issues with semi-additive measures (last non-empty,...).
    Will composite Key have any effect on semi-additive measures ?
    what if i use surrogate key instead of composite key.
    Please suggest if the approach has any issue with Time intelligence. Advise if there is any better approach for the same.
    Ram MSBI Developer

    Hey.. Thanks!
    I am clear about the concept about defining annotation based composite key. Also, I read in the documentation that I'll be needing to define as direct, aggregate or one-to-one. But, I am not able to define and run the same in the project mapping xml of toplink.
    It would be great if you can share some sample code for defining the same. For e.g. in my mentioned example, there is TestEntity POJO having 'id' as the attribute which gets populated with the testEntityCode of the TestEntityKey POJO. Please suggest the same for the same:
    <opm:primary-key>
    <opm:attribute-name>id</opm:attribute-name>
    <opm:field table="TEST_ENTITY_B" name="TEST_ENT_CODE" xsi:type="opm:column"/>
    </opm:primary-key>
    Thanks!

  • Composite key constraint in SSIS

    Hi All,
    I have created one SSIS package to move data from one table to another table in same database using oledb connection.Now I want to enforce composite key constraint while moving data as follows:
    Table A has following contents :                                                 
    Col1   col2  col3
    1         a        b
    2         c        d
    3         a        b
    So,while moving data, i want to verify the contents of col2 and col3(col2+col3) ie,composite key made of col2 and col3.In this case i want to move data of row 2 only and data of row 1 and 3 will go to error log file.
    I am trying to use lookup here but no luck yet. Can anybody help me to achieve this .
    Thanks in advance,
    Sanket 

    Hi Sanket, 
    I do agree with Visakh approach if table reside on same server, why go for the SSIS. But If you still want to do it, here are steps(It bit complex for simple operation like this, i didn't find
    any other approach).  I am using same table structure as mentioned above: 
    create table sampletest
     col1 int ,
     col2 varchar(10),
     col3 varchar(10)
    GO
    insert into sampletest
    values (1,'a','b'),(2,'c','d'),(3,'a','b')
    1.)   Load the
    Data from source with all columns.
    2.)   Place an Aggregate
    Task .Here is configuration:
    Column
    Operation
    Col1
    Max/Min
    Col2
    Group by
    Col3
    Group by
     (*)  - Output Alias (say cnt)
    Count All
    Figure 1: 
    3.)  Place a condition split. With expression
    (DT_I4)Cnt == 1
    2.)   
    Move case1 to destination table and other conditional split to error table.
    Full Diagram:
    Regards Harsh

  • Composite Key Validation in EOImpl

    Hello,
    Please anyone can give example of how to validate composite key validation?
    I have tried by following in EOImpl code but its not working:
    OADBTransaction transaction = getOADBTransaction();
    Object[] ItemKey = {getOrganizationId(),getUserId(),getProcess()};
    EntityDefImpl def = XxEOImpl.getDefinitionObject();
    XxEOImpl item_name = (XxEOImpl)def.findByPrimaryKey(getOADBTransaction(),new Key(ItemKey));
    if (item_name != null)
    throw new OAException("Erorr duplicate");
    Please suggest its urgent..
    Thanks,
    Swati Thakkar

    Hello Gurus,
    Can you please suggest the following way of validation is correct or not!?
    We have defined primary key on 3 attributes as a composite key, created EO and VO.
    Now to add new row we are asking values from user using LOV values.
    is the handling of unique value constraint using TooManyObjects Exception valid approach to handle error?
    EOImpl Code:
    try {
    setAttributeInternal(PROCESSTYPE, value);
    } catch (TooManyObjectsException toomany) {
    throw new OAException("Value is already exist.");
    Please suggest the right approach to handling Composite key validation..
    Thanks,
    Swati

  • Composite key by @IdClass

    hello, discuss the style of composite key by @IdClass. take the Category as example. this class use the name and createDate as comp. key. the entity part looks like:
    *@Entity*
    *@IdClass(CategoryPK.class)*
    *public class Category {*
    public Category() {}
    *@Id*
    protected String name;
    *@Id*
    protected Date createDate;
    *public String getName(){.............}*
    *public Date getCreateDate(){..............}*
    *public void setName(){.............}*
    *public void setCreateDate(){.........}*
    but somebody add the @Id on getter method like:
    *@Entity*
    *@IdClass(CategoryPK.class)*
    *public class Category {*
    public Category() {}
    protected String name;
    protected Date createDate;
    *@Id*
    *public String getName(){return this.name}*
    *@Id*
    *public Date getCreateDate(){return this.createDate}*
    *public void setName(){.............}*
    *public void setCreateDate(){.........}*
    it seem like both work after trying. but i have referred to at least three books, all of them just mention the first style. one of book even emphasize we must add the @id on the properties. so i am confused what's the different between them, and why the second style is not mentioned?
    Thanks

    I think for the real ORM expertise in Oracle, try the TopLink/JPA forum here on OTN.
    -steve-

Maybe you are looking for

  • How does a family member accept family share without iOs8?

    I want to add a member of my family to join me in family share.  They have the latest version of itunes on their Windows computer.  They have an iPhone 4 (so can't load ios8).  Is there a way for them to accept so we can start sharing our itu

  • Every time I try watch a quicktime video in any browser, it says that Quicktime plugin has crashed?

    It's been happening for quite some time, even before I upgraded to Lion. I have quicktime pro purchased, and I tried removing unnessary plugins, but it happens across chrome/safari/firefox. "The following plug-in has crashed: QuickTime Plug-in 7.7.1"

  • Reverting to old software

    I just connected my iPhone1 to itunes after a long time and updated it. Now my phone no longer works, saying that my SIM card is not supported. How can I revert back to the old software?

  • Compressing Archivelog

    Hi Everyone, I'm using "BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 0" and "LEVEL 1" for full and incremental backups. I also use "BACKUP ARCHIVELOG ALL", is there a way to compress the archivelog backups as well. I do know when the archivelogs

  • Open source, object-oriented embedded database for J2ME

    For J2ME-based devices that require embedded data management, there is now an open source, object-oriented embedded database for J2ME called Perst Lite. Perst Lite can be downloaded as part of the Perst open source embedded database package, at http: