Composite Primary Key in M:N CMP Entity Bean Relationship

Dear Sir/Madam,
     We are creating an Enterprise Application for our institute using EJB 2.0 specifiactions. In the course of developement, we are facing a problem in writing the CMP Entity Beans with EJB Relationships.
     We are having many to many relationship between two beans such that the primary key of one Entity Bean (let's call it A), serves as the foreign key of another Entity Bean (let's call it B). Further, this primary key of A as foreign key in B, participates in the composite key of B.
     The EJB Specifications require that the primary key field(s) of any bean (B, in our case) declared in the Primary Key class should be the subset of the 'cmp-field' declared in the deployment descriptor for that bean. As I said earlier, we have many to many relationship at play. Hence, we require to keep the foerign key in the 'cmr-field' in lieu of 'cmp-field'. In short, the component of primary key is in 'cmr-field' while, it is needed in both 'cmp-field' and 'cmr-field'. That's perfect from Database point of view but illogical from CMP Entity Bean's view.
     How can we write the deployment descriptor for such a CMP (BMP is working fine for above scenario) Entity Bean? Also, how can we write the Primary Key class? The problem is not just to find the solution, but find under the hood of EJB 2.0 specifications.
     Please help.

I think you should realise that it would not be convenient to use CMP for everything. It is difficult to define complex relations using CMP. Mostly BMP os preferd since it gives the flexibility for the bean developer.
Regards
xH4x0r

Similar Messages

  • Value string (primary key) could not pass to entity bean

    database server 3.23.57
    application server Jboss 3.07
    ide jbuilder8
    i am using session bean to wrap entity bean where it calls for entity bean to lookup the databse.
    value entered in client application could not be passed from session bean to entity bean.
    it is a jtextfield thta capture string as input which is the customer id. it is also the primary key. session bean managed to get the value but it was then became null when i pass to entity bean.
    may i know wat could be the problem that is causing this?
    application server not suporting this feature???? or it is th elogic problem .. or i have miss ot some code somewhere.?

    Sounds like a code problem.

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • Composite Primary Key using  cmp

    How can an Entity Bean with Composite Primary Key using Container Managed Persistance (CMP) be Deployed using in WebLogic Server 8.1
    pls help me

    Your text is a bit confusing, but I think the answer is yes (it can be used).  However, it would help to see the DDL that you are using (or that you propose to use) to avoid any misunderstandings. And please be specific about whether you are referring
    to COLUMNS that are part of a primary key versus the primary key itself (whether it is composed of one column or multiple columns).
    Lastly, why not just try it and see.

  • Creation of CMP bean for a Composite Primary key????

    Hi
    i am having a composite primary keys in one of my table in the database.
    I am trying to create a new entity bean for this table but i don't know how to create one in case when there is a composite primary key for a table.
    Can anybody let me know is it possible to do it.
    what is the procedure to be followed for the creation of the Entity bean in case of a composite primary key.
    I am using MySql as the database .Creating CMP type of Entity bean.
    Any help in this regard will be greatly useful to me as this is very urgent.
    Thanks & Regards
    Vikram K

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • CMP entity bean with compound primary key

    I'm trying to use a compound primary key in a CMP entity bean. I've created the custom primary key class okay, and I have the prim-key-class set in ejb-jar.xml. My client app gets the home reference okay, but when it tries to find an entity, I get the exception "SQLException: Incorrect syntax near '/'."
    I think I'm having trouble deploying this in OC4J. Is there a sample orion-ejb-jar.xml deployment for a custom, compound primary key somewhere?
    Many thanks for any help.
    Ernie

    Never mind. I solved my problem. Thanks.

  • CMP Entity Bean With Primary Key of int

    Is it valid to have a CMP Entity Bean (v1.1) where the primary key is defined as the primitive 'int' instead of a true Java class?
    Thanks in advance,
    Marc

    Hi,
    Ur primary key in the EJB cant be a primitive data type. If the primary key in the table is a int,
    then u will hv [bold] java.lang.Integer [bold] as the datatype in Entity Bean. If u hv further queries write me at [email protected]
    Kesavan.

  • How to persist an entity with Composite primary key

    Problem Statement:-
    Entity A have many to one relation with Entity C
    Entity B have many to one relation with Entity C
    Entity C have a composite primary key of (Entity A PK & Entity B PK)
    A --< C
    B --< C
    the entites are automatic generated by Dali tool
    @Entity
    public class C implements Serializable
         @EmbeddedId
         private C.PK pk;
         private int attribute;
         //Code
         @Embeddable
         public static class PK implements Serializable
              public int A_Id;
              public int B_Id;
              //Code
    @Entity
    public class A implements Serializable
         @Id
         private int AId;
         @OneToMany
         private Set<C> C_Collection;
         //Code
    @Entity
    public class B implements Serializable
         @Id
         private int BId;
         @OneToMany
         private Set<C> C_Collection;
         //Code
    i made a session Bean which add a new entity C
    Session
         A a = em.find(A.class, AId);
         B b = em.find(B.class, BId);
         C c = new C();
         C.PK pk = new C.PK();
         pk.AId(a.getID());
         pk.BId(b.getID());
         c.setPk(pk);
         c.setA(a);
         c.setB(b);
         c.setAttribute(12);
         em.persist(c);
    when running this code an exception is raised
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'A_ID' in 'field list'Error Code: 1054
    Call:INSERT INTO C (attribute, Aid, A_ID, B_ID, Bid) VALUES (?, ?, ?, ?, ?)
         bind => [2, 6, 6, 1, 1]
    this is logic as Table "C" has only 3 coloumns only "attribute" , "Aid" , "Bid"
    but the mapping is different as it adds the composite PK attributes to the insert statement
    if there is a sample code or how to solve this issue it would be great

    Hello Juwen,
    The problem is you are registering an object, assigning it a null pk, and then commiting the uow/transaction. TopLink uses registered objects to keep track of changes you make inorder to persist those changes on commit. So the simple fix is to not commit the UnitOfWork - call release() on it instead.
    Another solution is to use the session copyObject api. The simple form that only takes an object will work similar to registering the object as it will copy all persistent attributes but it will leave the primary key null. You can also use this method to specify a copyPolicy to customize the process. Using this method will be a bit more efficient, since a UOW makes both a working copy and a back up copy of objects registered, inorder to keep track of changes. Using the copyObject api will only make a single copy.
    Best Regards,
    Chris

  • Composite Primary Key Error

    I am using Sun One App Server PE8.
    I have a class with a composite primary key field. When I place the following method in my Home interface:
    public MyEjb findByPrimaryKey(MyEjbPrimaryKey pk) throws FinderException, RemoteException;I get the following error when deploying:
    ejbFindByPrimaryKey(EjbPrimaryKey) is already defined in MyEjb1368202910_ConcreteImpl
        public MyEjbPrimaryKey ejbFindByPrimaryKey (MyEjbPrimaryKey key)However, If i remove this method from the Home interface, i get the following error when running the verification tool:
    Error: No single arg findByPrimaryKey(PrimaryKeyClass) method was found in home interface class [ MyEjb ].However, I can still deploy the EAR successfully.
    Another related symptom of this problem, is if I include the following method in my Home interface:
    public MyEjb findByPrimaryKey(String pkField1, String pkField2) throws FinderException, RemoteException;And call this method, I get the following exception at runtime:
    java.rmi.RemoteException: Bean class for ejb [MyEjb] does not define a method corresponding to [Home] interface method [public abstract MyEjb MyEjbHome.findByPrimaryKey(java.lang.String,java
    .lang.String) throws javax.ejb.FinderException,java.rmi.RemoteException]I get these same problems with all EJB's that use composite keys. Has anyone else had this problem?
    Thanks
    toby

    This is a CMP bean, with no ejbFindByPrimaryKey in the Bean class. Below, i have included the Home interface and the Bean class (with unneccessary code removed)
    Thanks for looking at this for me.
    BEAN CLASS
    package lands.mc.bus.prod;
    import java.rmi.*;
    import java.util.*;
    import javax.ejb.*;
    public abstract class TopoMapBean implements EntityBean
      private EntityContext entity;
      public TopoMapBean()
      public void setEntityContext(EntityContext ctx)
        entity = ctx;
      public void unsetEntityContext()
        entity = null;
      public TopoMapPrimaryKey ejbCreate(String mapName, String mapNumber, String mnemonic,String edition, String scale)
      throws CreateException
        // call setters...
        return null;
      public void ejbPostCreate( String mapName,
                                                   String mapNumber,
                                             String mnemonic,
                                             String edition,
                                             String scale )
      removed set/get methods
      public void ejbStore() {}
      public void ejbLoad() {}
      public void ejbActivate() {}
      public void ejbPassivate() {}
      public void ejbRemove() {}
    }HOME INTERFACE
    package lands.mc.bus.prod;
    import java.rmi.*;
    import java.util.*;
    import javax.ejb.*;
    public interface TopoMapHome extends EJBHome
      public TopoMap create(String mapName,
                            String mapNumber,
                            String mnemonic,
                            String edition,
                            String scale
      throws CreateException, RemoteException;
      public TopoMap findByPrimaryKey(String mapNumber, String edition) throws FinderException, RemoteException;
    // doesnt deploy with this signature
    //  public TopoMap findByPrimaryKey(TopoMapPrimaryKey pkey) throws FinderException;
    // have to use this method instead of findByPrimaryKey(String, String) above
      public TopoMap findTopoMap(String mapNumber, String edition) throws FinderException, RemoteException;

  • OC4J 9.0.4 Deadlock: CMR with composite primary key

    Hi,
    I just encountered a Deadlock in a CMR/CMP application involving a session bean and two entity beans, one of which (Item) has a composite primary key, comprising a foreign key to the second entity bean. The exception is thrown after ejbPostCreate() completes succesfully and the new row is committed to the ITEM table. I have provided the trace (verbosity = 10) below. The EJB Dev Guide does not offer too much detail on Deadlock conditions, so any input and suggestions are most welcome.
    regards and thanks
    George
    javax.ejb.EJBException: Deadlock detected: thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    is waiting for resource entity Item server.ItemPK@bdc9b3 held by thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    at com.evermind.server.ejb.AbstractEJBObject.startCallLocal(AbstractEJBObject.java:110)
    at ItemLocal_EntityBeanWrapper18.setNomen(ItemLocal_EntityBeanWrapper18.java:1912)
    at server.OrderSBBean.addItems(OrderSBBean.java:380)
    at OrderSB_StatelessSessionBeanWrapper2.addItems(OrderSB_StatelessSessionBeanWrapper2.java:1983)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:536)

    Hi,
    I just encountered a Deadlock in a CMR/CMP application involving a session bean and two entity beans, one of which (Item) has a composite primary key, comprising a foreign key to the second entity bean. The exception is thrown after ejbPostCreate() completes succesfully and the new row is committed to the ITEM table. I have provided the trace (verbosity = 10) below. The EJB Dev Guide does not offer too much detail on Deadlock conditions, so any input and suggestions are most welcome.
    regards and thanks
    George
    javax.ejb.EJBException: Deadlock detected: thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    is waiting for resource entity Item server.ItemPK@bdc9b3 held by thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    at com.evermind.server.ejb.AbstractEJBObject.startCallLocal(AbstractEJBObject.java:110)
    at ItemLocal_EntityBeanWrapper18.setNomen(ItemLocal_EntityBeanWrapper18.java:1912)
    at server.OrderSBBean.addItems(OrderSBBean.java:380)
    at OrderSB_StatelessSessionBeanWrapper2.addItems(OrderSB_StatelessSessionBeanWrapper2.java:1983)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:536)

  • Null in Composite Primary Key and "Primary keys must not contain null"

    Hello all.
    I'm a newbie concerning to JPA/EJB3, but I was wondering if toplinks doesn't support composite primary keys with null in some field (something perfectly right in any RDBMS).
    I used JDeveloper (I'm using Oracle 10g database and JDeveloper 10.1.3.2.) wizards to generate JPA classes and I checked out generated files (with annotations), so they should be right (by the way, other O-R mappings for my model are working right, but this one).
    I'm getting the next error:
    Exception Description: The primary key read from the row [DatabaseRecord(
         TSUBGRUPOSLDI.CD_GRUP => 01
         TSUBGRUPOSLDI.CD_SUBGRUP => null
         TSUBGRUPOSLDI.CG_POBL => 058
         TSUBGRUPOSLDI.CG_PROV => 28
         TSUBGRUPOSLDI.DSCR => Sanidad)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Compound primary key is (CD_GRUP, CD_SUBGRUP). No foreign keys, no joins (only a NamedQuery: "select o from ..."). It's the simplest case!
    I checked out that everything runs ok if there's no "null" value in CD_SUBGRUP.
    After some research (this and other forums) I'm beginning to believe that it's not supported, but not sure.
    Am I doing sth wrong? If not, what is the reason to not support this? Will it be supported in the future?
    Thanks in advance.

    Null is a special value and in many databases is not comparable to another null value (hence the isNull operator) and may pose problems when used to uniquely identify an Entity. TopLink does not support null values within a composite PK. As the nullable column is most likely not designated as a PK within your database table (many databases do not allow this) I recommend updating the Entity PKs to match that of the database.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Deployment Tool Problem (J2EE -Composite primary Key Class)

    Hi !!
    e.g. I have an entiybean which has composite primary key class. So while deploying in J2EE tool u need to specify the Primary key class and the primary key field. well in case of a composite primary key class(if u have more than one field)...how do u declare all the fields for primary key class....
    if u r not getting me please tell me... See in J2EE deployment tool there is on section called Entity..in that see the Primary Key class (there u specify the Primary key class) and the Primary Key Field Name (the field name) Here u can just give only one Field name..if you have mulitple fields, then where you will specify... Please let me know..
    if anybody wants the code I will give the code...Please try to help..(how to deploy this kind of entity bean in J2EE deployment tool)
    -Bhumika

    Hi Bhumika,
    in case you have more than one field you need to write a Primary key class where the fields you want to be the key are member variables.
    your p.key class could look like this (it has to implement hash() and equals() ):
    public class PersonPK implements java.io.Serializable
    public int person_ID;
    public PersonPK()
    public PersonPK(int aPersonId)
    person_ID = aPersonId;
    public int hashCode()
    return person_ID;
    public boolean equals(Object ob)
    if (ob == this) return true;
    if (!(ob instanceof PersonPK)) return false;
    PersonPK other = (PersonPK) ob;
    if (person_ID != other.person_ID) return false;
    return true;
    -Hope this helps a bit,
    Anke

  • How to Work with Composite Primary Key

    Hi All,
    I'm working with Toplink JPA. Here I have A problem with inserting into database table which have composite Primary Key.
    What I'm doing is, I have two tables. to maintain many to many relation between these two tables I created another intermediate table which consists of foreign Keys (reference) of above two tables.
    Now these two foreign Keys in the Intermediate table made as composite Primary Keys.
    When I'm trying to the data in the Intermediate table I'm getting the foreign Keys values are null..
    could anyone suggest me how to work with composite Primary Keys
    Thanks,
    Satish

    I have the same problem, I have 3 tables with a join table joining them all. I have created an intermediate table entity. When I go to create a an entry, it says that I cannot enter null into "ID". Here is the SQl toplink generates:
    INSERT INTO Z_AUTH_USER_AUTHORIZATION (CONTEXT_ID, AUTHORIZATION_ID, USER_ID) VALUES (?, ?, ?)
    bind => [null, null, null]
    Here are the classes:
    -----------------------Join Table-----------------------------------------------
    @Entity()
    @Table(name = "Z_AUTH_USER_AUTHORIZATION")
    public class AuthUserAuthorization implements Serializable{
    @EmbeddedId
    private AuthUserAuthorizationPK compId;
    // bi-directional many-to-one association to AuthAuthorization
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "AUTHORIZATION_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    private AuthAuthorization authAuthorization;
    // bi-directional many-to-one association to AuthContext
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "CONTEXT_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    private AuthContext authContext;
    // bi-directional many-to-one association to AuthUser
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "USER_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
    private AuthUser authUser;
    ---------------------------------------User table--------------------------------------------------------------
    @Entity()
    @Table(name = "Z_AUTH_USER")
    public class AuthUser implements Serializable, IUser{
    @Id()
    @SequenceGenerator(name = "AUTH_USER_ID_SEQ", sequenceName = "Z_AUTH_USER_ID_SEQ")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_USER_ID_SEQ")
    @Column(name = "ID", unique = true, nullable = false, precision = 10)
    private Integer id;
    // bi-directional many-to-one association to AuthUserAuthorization
    @OneToMany(mappedBy = "authUser", fetch = FetchType.EAGER)
    private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
    -----------------------------------Context table-----------------------------------------------------------------
    @Entity()
    @Table(name = "Z_AUTH_CONTEXT")
    public class AuthContext implements Serializable, IContext{
    @Id()
    @SequenceGenerator(name = "AUTH_CONTEXT_ID_SEQ", sequenceName = "Z_AUTH_CONTEXT_ID_SEQ")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_CONTEXT_ID_SEQ")
    @Column(name = "ID", unique = true, nullable = false, precision = 8)
    private Integer id;
    // bi-directional many-to-one association to AuthUserAuthorization
    @OneToMany(mappedBy = "authContext", fetch = FetchType.EAGER)
    private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
    ----------------------------Authorization table-------------------------------------------------
    @Entity()
    @Table(name = "Z_AUTH_AUTHORIZATION")
    public class AuthAuthorization implements Serializable, IAuthorization{
    @Id()
    @SequenceGenerator(name = "AUTH_AUTHORIZATION_ID_SEQ", sequenceName = "Z_AUTH_AUTHORIZATION_ID_SEQ")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_AUTHORIZATION_ID_SEQ")
    @Column(name = "ID", unique = true, nullable = false, precision = 8)
    private Integer id;
    // bi-directional many-to-one association to AuthUserAuthorization
    @OneToMany(mappedBy = "authAuthorization", fetch = FetchType.EAGER)
    private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
    I have tried to create the new entity several ways. I have tried to create one with the default constructor then set this entity on each of the other entities, I have also tried to pass in the entities to the join entity and set them there, but this doesn't work. Any help would be very appreciated!
    Thanks,
    Bill

  • Problem in a composite  primary key

    I have a CMP Entity Bean which has two dependent objects which have siple primary keys, but that EntityBean needs the primary key of that objects to be referenced and identify. What is the way to perform it?
    any help pleased.
    Thank you.

    Hi,
    I understand your question as follows. You have 3 entity beans eb1, eb2 and eb3. You have primary key pk1 for eb1 and primary key pk2 for eb2. These two keys are part of eb3, and together they should be the primary key for eb3.
    What I always do in those cases is to add an additional field to eb3 and concatenate pk1 and pk2. This is specifically easy when pk1 and pk2 are Strings. Perhaps this is not the best way, but I find it very useful, as it is very easy when your primary key is stored in only one field.
    Hope this helps, Sponiza

  • Composite Primary Key Mapping error

    I have the following code:
    public class PreviousStepEJB3PK implements Serializable {
    private static final long serialVersionUID = 3024775815042084864L;
    public Long id;
    public Long previousId;
    public PreviousStepEJB3PK() {
    public PreviousStepEJB3PK(Long id, Long previousId) {
    this.id = id;
    this.previousId = previousId;
    public boolean equals(Object other) {
    if (other instanceof PreviousStepEJB3PK) {
    final PreviousStepEJB3PK otherPreviousStepPK = (PreviousStepEJB3PK) other;
    final boolean areEqual = (otherPreviousStepPK.id.equals(id) && otherPreviousStepPK.previousId.equals(previousId));
    return areEqual;
    return false;
    public int hashCode() {
    return super.hashCode();
    @Entity
    @Table(name = "OS_CURRENTSTEP_PREV")
    @NamedQuery(name = "findById",
         query = "select object(o) from PreviousCurrentStepEJB3 o where o.id = ?1")
    @IdClass(PreviousStepEJB3PK.class)
    public class PreviousCurrentStepEJB3 implements Serializable {
    private static final long serialVersionUID = 1717698904412346878L;
    @Id
    @Column(name = "ID", nullable = false)
    private Long id;
    @Id
    @Column(name = "PREVIOUS_ID", nullable = false)
    private Long previousId;
    public PreviousCurrentStepEJB3() {
    I´m using eclipse to deploy my application over an OC4J. When I launch the deploy I have the following error:
    07/07/05 11:42:47 Caused by: Exception [TOPLINK-7150] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [ar.com.eds.mcd.fawkes.model.PreviousStepEJB3PK] and those of the entity bean class [class ar.com.eds.mcd.fawkes.model.PreviousCurrentStepEJB3] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.
    07/07/05 11:42:47      at oracle.toplink.essentials.exceptions.ValidationException.invalidCompositePKSpecification(ValidationException.java:995)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwInvalidCompositePKSpecification(MetadataValidator.java:119)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.validatePrimaryKey(ClassAccessor.java:1463)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.process(ClassAccessor.java:463)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:196)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.processORMetadata(EntityManagerSetupImpl.java:993)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:501)
    07/07/05 11:42:47      at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:152)

    I ran into a similar problem. I was able to work around it by putting the @Id annotations on the accessors for the primary key fields rather than on the fields themselves. This seems like a bug to me.

Maybe you are looking for

  • Can you permanently disable a device?

    I am a police officer and embarrassed to say that after leaving my iTouch in the patrol car a couple years ago it was taken by another employee and never returned.  Recently, I received a couple Email requests to obtain or change my password.  I logg

  • Clone to multiple hard drives

    Trying to duplicate the contents of one laptop's hard drive to another. I'm doing volunteer tech support for a local school, which has about 30 Satellite (C650D) and netbook (NB505).  I would like to update software on one laptop (new anti-virus, upd

  • Make non-global zone svcs persistant accross reboots

    Q: Solaris 10 services such as telnet will need to be enabled after installation of non-glabal zones. Command "svcs enable telnet" did not leave telnet enabled after rebooting a non-global zone. Any suggestions? Thanks.

  • Wireless connection to iPad air

    Unable to connect to my new iPad air to my HP J 4680 office jet all in one

  • Can ichat act as a softphone?

    I'm thinking of adding a VoIP service to my small business. Can ichat be setup to be a VoIP softphone? I looked at Skype and GIZmo project but they dont offer an inbound calling number for my area code .. Ottawa Canada. I found a VoIP provider that w