ADF, EJB: "No primary key specified"

In jdeveloper 10.1.3.1, I am trying to create a very simple form: I have a table with a primary key. I create an application with a JSF page on which I create an input form, as described in "Developer’s Guide For Forms/4GL Developers", section "13.6 Creating an Input Form". Then I try to run it and get the following error:
Exception Description: Entity class [class orchids.datamodel.Objects] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass.
- so what am I doing wrong? Isn't it enough to have a primary key constraint on the table?

Hello,
You haven't mentioned which version of OC4J you are successfully deploying to. If it is not 10.1.3, then you might try upgrading your OAS server so that its version matches the OC4J version you are using. OAS 10.1.3 only had very limited JPA support, and so it is advisable to use OAS 10.1.3.3 anyway.
Best regards,
Chris

Similar Messages

  • Error: has no primary key specified. It should define either an @Id, @Embed

    I'm using toplink with JPA. it was able to deploy to OC4J succesfully. however, when I deploy to oracle application server 10.1.3, I got the following error:
    has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass.
    I do have @Id defined for id property. I tried to move @Id annotation to getId() method, instead of id property, the deployment succesfully.
    I have many entities need to be changed. i'm wndoring if there is configuration or if it is bug of OAS 10.1.3

    Hello,
    You haven't mentioned which version of OC4J you are successfully deploying to. If it is not 10.1.3, then you might try upgrading your OAS server so that its version matches the OC4J version you are using. OAS 10.1.3 only had very limited JPA support, and so it is advisable to use OAS 10.1.3.3 anyway.
    Best regards,
    Chris

  • Solved: ADF BC and primary keys - how to implement without using triggers

    Using the following OBE as an example:
    http://www.oracle.com/technology/obe/obe9051jdev/ADFWorkshop/BuildingADFApplicationsWorkshop.htm
    There is just one view that has CustomerId defined as a primary key, where the value for the primary key comes from the customer_seq sequence.
    How do you create the model using ADF BC entity to create an entity object that has a primary key that needs to be populated by a sequence table when inserted WITHOUT using a trigger?
    Basically I want to just use ADF BC instead of toplink in the OBE. We do not use triggers to insert primary keys, so this example is a good match for what I need.
    Can someone help me out. How do I adjust the model to use just ADF BC - how do I define the entity object to use a sequence. Do I just override the create method in the impl? Is it that simple? Or is there a way to do this point and click in the entity tool.
    Thanks!

    I'm not the dba (or one of several) - so don't shoot the messenger... the dba's do not like to use triggers in the code. I have been told that this has caused too many problems in application development.
    I don't ask why, just deal with the fallout.
    I did try using the following code in a create method:
    protected void create(AttributeList attributeList)
    super.create(attributeList);
    SequenceImpl s = new SequenceImpl("customers_seq", getDBTransaction());
    // this.setCustId(s.getSequenceNumber());
    this.createPrimaryKey(s.getSequenceNumber());
    When I run the test program for the module, I get a new entry with the id empty and greyed out. I was hoping that this would be filled in on the actual insert, but no joy. As soon as I try to commit, I get an error:
    (oracle.jbo.AttrValException) JBO-27014: Attribute CustId in CustomersWSView is required)
    So what needs to be done?
    Message was edited by:
    klee

  • EJB Postgres Primary Key Troubles

    I'm using Postgres 8.03 and have a table with a serial id (aka auto increment) as it's primary key.
    Is there an easy way to handle the auto increment field with an EJB? Currently I have to manually set the Primary key during an insert. Is there a way to do an insert and let the auto increment do it's job without me having to manually set it?
    Will I have to query to get the highest value in the primary key field?
    The only other way I could think of to handle this would be to make the primary key field a var char and create a GUID each time I do an insert.
    Thoughts on this would be great!
    Thank you!

    Hi
    Is there an easy way to handle the auto increment
    field with an EJB? Currently I have to manually set
    the Primary key during an insert. Is there a way to
    do an insert and let the auto increment do it's job
    without me having to manually set it?you mean ejb3?
    i used, when i migrated from hsqldb to postgresql, this kind of id generator
    @SequenceGenerator(name = "board_sequence", sequenceName = "board_id_seq")
    class Xyz....
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    getId() {
    .....EJB3 will create a sequence on his own, so you can use it.

  • Can't Deploy an EJB with primary key of Type BigDecimal to a WAS 6.20

    When using the DeployTool for the WAS 6.20, I get an error during creation of the archive, saying that the EJB's (CMP) primary key's class java.math.BigDecimal is not part of the JAR.
    Any idea what the mistake might be? any help is appreciated.
    Thx
    Michael

    Hello Howard,
    today I encountered the same problem.
    I'm writing an application with a couple of CMP EJB's in relation to each other, similar
    to the 'titan' sample application described by Richard Monson-Haefel - Enterpise JavaBeans.
    I followed exactly his description for using undefined primary keys (java.lang.Object)
    on page 291 (third edition).
    I'm still looking for the solution.
    I let you know if I find the reason for that.
    Regards
    Stephan

  • Can EJB 3.0 beans be used with tables that do not have a primary key?

    Can a EJB 3.0 persistence bean be used with tables that do not have a primary key defined? I am building a test application based on the HowTo - Building EJB 3.0 Faces App paper posted after Openworld (schalk). The issue I am running into when trying to run the application is: Exception Description: Entity class [class com.persistence.Rpthead] has no primary key specified. Note: I get a simular error when using toplink directly.
    The tables I am binding to do not have primary keys defined. They use unique constraints to manage the table integrity.
    Is it possible to use EJB 3.0 on tables without a primary key? If not, are there plans to support this in the future?

    The spec requires a primary key Id annotation. I will take your suggestion to EJB 3.0 expert group.
    Can you also send an email to [email protected] with your requirement?
    -Debu

  • Exception Description: Entity class [] has no primary key....

    Received the following error in jdeveloper - some info on how to fix would be greatly appreciated
    [EclipseLink/JPA Client] Adding Java options: -javaagent:C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\eclipselink.jar
    C:\Oracle\MiddlewareNew\jdk160_05\bin\javaw.exe -client -classpath C:\JDeveloper\mywork\APP_CM_AUTONUM_GEN\.adf;C:\JDeveloper\mywork\APP_CM_AUTONUM_GEN\SAM_CM_AUTONUM_GEN\classes;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\toplink.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\antlr.jar;C:\oracle\MiddlewareNew\modules\com.bea.core.antlr.runtime_2.7.7.jar;C:\oracle\MiddlewareNew\modules\javax.persistence_1.0.0.0_1-0.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\eclipselink.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.xdk_11.1.1\xmlparserv2.jar;C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.xdk_11.1.1\xml.jar;C:\oracle\MiddlewareNew\modules\javax.jsf_1.2.0.0.jar;C:\oracle\MiddlewareNew\modules\javax.ejb_3.0.1.jar;C:\oracle\MiddlewareNew\modules\javax.enterprise.deploy_1.2.jar;C:\oracle\MiddlewareNew\modules\javax.interceptor_1.0.jar;C:\oracle\MiddlewareNew\modules\javax.jms_1.1.1.jar;C:\oracle\MiddlewareNew\modules\javax.jsp_1.1.0.0_2-1.jar;C:\oracle\MiddlewareNew\modules\javax.jws_2.0.jar;C:\oracle\MiddlewareNew\modules\javax.activation_1.1.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.mail_1.1.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.soap_1.3.1.0.jar;C:\oracle\MiddlewareNew\modules\javax.xml.rpc_1.2.1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.ws_2.1.1.jar;C:\oracle\MiddlewareNew\modules\javax.management.j2ee_1.0.jar;C:\oracle\MiddlewareNew\modules\javax.resource_1.5.1.jar;C:\oracle\MiddlewareNew\modules\javax.servlet_1.0.0.0_2-5.jar;C:\oracle\MiddlewareNew\modules\javax.transaction_1.0.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.stream_1.1.1.0.jar;C:\oracle\MiddlewareNew\modules\javax.security.jacc_1.0.0.0_1-1.jar;C:\oracle\MiddlewareNew\modules\javax.xml.registry_1.0.0.0_1-0.jar;C:\oracle\MiddlewareNew\wlserver_10.3\server\lib\weblogic.jar -javaagent:C:\oracle\MiddlewareNew\jdeveloper\modules\oracle.toplink_11.1.1\eclipselink.jar SAM.CMAUTONUMGENClient
    java.lang.reflect.InvocationTargetException
         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:597)
         at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
         at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
    Caused by: java.lang.reflect.InvocationTargetException
         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:597)
         at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializerAgent.initializeFromAgent(JavaSECMPInitializerAgent.java:45)
         at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializerAgent.premain(JavaSECMPInitializerAgent.java:38)
         ... 6 more
    Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Predeployment of PersistenceUnit [SAM_CM_AUTONUM_GEN] failed.
    Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: Entity class [class oracle.SamCmAutonumGen] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then please make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
         at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:870)
         at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:101)
         at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initPersistenceUnits(JPAInitializer.java:149)
         at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.initialize(JPAInitializer.java:135)
         at org.eclipse.persistence.internal.jpa.deployment.JavaSECMPInitializer.initializeFromAgent(JavaSECMPInitializer.java:145)
         ... 12 more
    Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.EntityManagerSetupException
    Exception Description: Predeployment of PersistenceUnit [SAM_CM_AUTONUM_GEN] failed.
    Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: Entity class [class oracle.SamCmAutonumGen] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then please make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
         at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)
         ... 17 more
    Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.ValidationException
    Exception Description: Entity class [class oracle.SamCmAutonumGen] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then please make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
         at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1245)
         at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1173)
         at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:486)
         at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:443)
    FATAL ERROR in native method: processing of -javaagent failed
         at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:303)
         at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:830)
         ... 16 more
    Exception in thread "main" Process exited with exit code 1.

    Hi,
    you may want to try the J2EE forum here on OTN in case you don't get a sufficient answer to the problem.
    Frank

  • USE ROWID AS PRIMARY KEY OF ENTITY ON EJB3

    When we launch the Create Entities from Tables wizard, and create JPA (Java Persistence API) entities from existing database tables, if the table has no primary key and unique key field, you will get a warning. When you run, you will get the following information:
    Caused by: Exception [TOPLINK-7161] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Entity class [class model.Test] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass.
    Actually, every row of oracle table has a ROWID field , I think it is a good “primary key field”. Add it into Entity Java bean file as following:
    @Id
    private ROWID rowid;
    And generate accessors, ok, run……
    GOOD, No problem.
    But when you insert a new row, got an exception:
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-00928: missing SELECT keyword
    Error Code: 928
    Call:INSERT INTO TEST (ROWID, B, A) VALUES (?, ?, ?)
         bind => [null, 555, 555]
    Query:InsertObjectQuery(model.Test@40979b)
    555~~~, what happened?! Somebody builds a wrong SQL …
    Don’t worry! I know (…) where is the “bug”.
    Find out the class
    oracle.toplink.essentials.internal.expressions. SQLInsertStatement
    which is included in the toplink-essentials.jar,
    decompile… , fix…, compile, and jar it back.
    Fix
    if(field.getTable().equals(getTable()) || !field.hasTableName())
    to
    if((field.getTable().equals(getTable()) || !field.hasTableName()) && !field.getName().equalsIgnoreCase("ROWID"))
    OK, it is running well.
    I suggest ORACLE fix it into his next version. Do you think it is a good idea?

    Do you think it is a good idea? Not really, but that's just my two cents.

  • Toplink map: No primary keys defined for table, what can I do?

    I have the following DDL:
    CREATE TABLE CAM_CUSTINFO.CUSTOMERMASTER (
         CUSTID CHAR(15) NOT NULL,
         BILLTOCUSTID CHAR(15) NOT NULL,
         GROUPID NUMBER(11) NOT NULL,
         CUSTSTATUS CHAR(1) NOT NULL,
         CUSTSTATUSDT DATE,
         NAMESHORT CHAR(10) NOT NULL,
         SINCEDT DATE NOT NULL,
         ADDDT DATE NOT NULL,
         FIRSTNAME CHAR(20) NOT NULL,
         MIDDLENAME CHAR(15) NOT NULL,
         LASTNAME CHAR(30) NOT NULL,
         SUFFIXNAME CHAR(15) NOT NULL,
         NAMETYPECD CHAR(1) NOT NULL,
         TITLE CHAR(15) NOT NULL,
         SALUTATIONCD CHAR(6) NOT NULL,
         COMPANYNAME CHAR(40) NOT NULL,
         PRIMADDRSEQBILL NUMBER(5) NOT NULL,
         PRIMADDRSEQSOLD NUMBER(5) NOT NULL,
         PRIMADDRSEQSHIP NUMBER(5) NOT NULL,
         NAME2 CHAR(40) NOT NULL,
         CUSTLEVEL CHAR(1) NOT NULL,
         TAXABLECD CHAR(1) NOT NULL,
         TAXPAYERID CHAR(14) NOT NULL,
         CHGID CHAR(10) NOT NULL,
         CHGDT DATE,
         BILLCURRENCYCD CHAR(10) NOT NULL,
         BILLDAY NUMBER(5) NOT NULL,
         HOLDBILLINGIND CHAR(1) NOT NULL,
         PAYMENTTERMCD CHAR(10) NOT NULL,
         CANCELSTATUSIND CHAR(1) NOT NULL,
         CANCELSTATUSDT DATE,
         INDUSTRYCD CHAR(30));
    CREATE UNIQUE INDEX CAM_CUSTINFO.PK_CUSTOMERMASTER ON CAM_CUSTINFO.CUSTOMERMASTER (CUSTID);
    CREATE INDEX CAM_CUSTINFO.IX_CUSTOMERMASTERBILLTOCUSTID ON CAM_CUSTINFO.CUSTOMERMASTER (BILLTOCUSTID, CUSTID);
    CREATE INDEX CAM_CUSTINFO.IX_CUSTOMERMASTERCOMPNAME ON CAM_CUSTINFO.CUSTOMERMASTER (COMPANYNAME);
    CREATE INDEX CAM_CUSTINFO.IX_CUSTOMERMASTERGROUPID ON CAM_CUSTINFO.CUSTOMERMASTER (GROUPID);
    CREATE INDEX CAM_CUSTINFO.IX_CUSTOMERMASTERNAME ON CAM_CUSTINFO.CUSTOMERMASTER (LASTNAME, FIRSTNAME);
    CREATE INDEX CAM_CUSTINFO.IX_CUSTOMERMASTERBILLDAY ON CAM_CUSTINFO.CUSTOMERMASTER (BILLDAY, CUSTID);
    CREATE INDEX CAM_CUSTINFO.I_00_INDCD ON CAM_CUSTINFO.CUSTOMERMASTER (INDUSTRYCD);
    How do I add this to a Toplink Map? I always get the error:
    Descriptor Custaddr -> Some mappings are incomplete.
    Descriptor Custaddr -> No primary keys specified in CAM_CUSTINFO.CUSTOMERMASTER table.
    Descriptor Custaddr -> The following Query Keys do not have associated database fields: adddt, address1, address2, address3, address4, addressseqnum, billtoaddr, chgdt, chgid, city, country, county, custid, department, descr, effstatus, fax, fips, geocode, houseType, incitylimit, latitude, longitude, num1, num2, phone, phonecountry, phoneext, phonesecondary, postal, secondaryext, shiptoaddr, soldtoaddr, state, taxcd
    Mapping adddt -> No database field is selected.
    Mapping address1 -> No database field is selected.
    Mapping address2 -> No database field is selected.
    Mapping address3 -> No database field is selected.
    Mapping address4 -> No database field is selected.
    Mapping addressseqnum -> No database field is selected.
    Mapping billtoaddr -> No database field is selected.
    Mapping chgdt -> No database field is selected.
    Mapping chgid -> No database field is selected.
    Mapping city -> No database field is selected.
    Mapping country -> No database field is selected.
    Mapping county -> No database field is selected.
    Mapping custid -> No database field is selected.
    Mapping department -> No database field is selected.
    Mapping descr -> No database field is selected.
    Mapping effstatus -> No database field is selected.
    Mapping fax -> No database field is selected.
    Mapping fips -> No database field is selected.
    Mapping geocode -> No database field is selected.
    Mapping houseType -> No database field is selected.
    Mapping incitylimit -> No database field is selected.
    Mapping latitude -> No database field is selected.
    Mapping longitude -> No database field is selected.
    Mapping num1 -> No database field is selected.
    Mapping num2 -> No database field is selected.
    Mapping phone -> No database field is selected.
    Mapping phonecountry -> No database field is selected.
    Mapping phoneext -> No database field is selected.
    Mapping phonesecondary -> No database field is selected.
    Mapping postal -> No database field is selected.
    Mapping secondaryext -> No database field is selected.
    Mapping shiptoaddr -> No database field is selected.
    Mapping soldtoaddr -> No database field is selected.
    Mapping state -> No database field is selected.
    Mapping taxcd -> No database field is selected.
    This isn't in the Developer's guide?
    Detailed information would be greatly appreciated.
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Todd,
    Follow these steps.
    1. First map your CustomerMaster descriptor either manually or by using the automap wizard.
    2. Specify the primary key(s) (it does not have to be on the database) by checking appropriate fields listed under the "Primary Keys:" in "Descriptor Info" tab.
    3. Run the mapping status report to make sure you have no errors in mapping.
    Hope this helps.

  • Primary key issue in toplink workbench

    Hi All,
    I am getting No primary keys specified in (xxx is the table name) table error in workbench.
    I my table,don't have any primary keys,i try to do direct to field mapping for all the fields with the table.
    After mapping,was getting this warning.
    Is there any mandatory thing in toplink workbench that we need to have atleast one primary key defined in a table.
    Please let me know!!!!!!!!!!!!
    Appreciate your hekp............

    Yes, it needs to know how to uniquely identify the row to do deletes and updates, etc. If you have no PK, then actually every field is needed to uniquely identify the row, and therefore just slect every field in the MW as being the PK... Note that the PK specified in the MW doesn't have to actually be the PK on the database, it just has to be unique for when TL does update/delete, etc.
    - Don

  • Primary Key for Read Only Entity Beans In EJB 3.0

    Hi,
    I have checked the spec for ejb 3.0 which mentions that, there is no common standard for the vendor to implement the Read only Entity Beans.
    My question over here is how it is implemented in OC4J??
    Do we need to specify a primary key attribute in the read-only entity bean?
    w.r.t BC4J(ADF) i remember, we used to create a read-only View Object with out specifying a primary key.
    Just want to check is that the way it works in EJB 3.0 (Implemented by OC4J).
    Thanks for your help in advance.
    Shiva

    Hi,
    Try using the JBoss embedded container:
    http://docs.codehaus.org/display/MAVENUSER/How+to+use+the+JBoss+Embedded+EJB3+Container+for+Unit+testing
    /klejs

  • EJB Primary Key not found in lock manager - Container BUG?

    I have an EJB entity bean whose primary key class implementation is pretty simple, consisting of two strings. For the MOST part, it seems to work properly, but every so often I see the following message in my application server log.
    ####<Sep 17, 2008 10:03:27 AM EDT> <Warning> <JTA> <armantac22> <AdminServer> <[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1221660207187> <BEA-110401> <Ignoring error in afterCompletion. Object=weblogic.ejb.container.internal.TxManager$TxListener@1906466, Exception=javax.ejb.EJBException: [EJB:010108]The EJB Lock Manager has received an unlock request from EJB:PortfolioMetaData with primary key:[ObjectPK: type: PortMetaData name: PortMetaData]. However, this primary key could not be found in the Lock Manager. This indicates either an EJB container bug, or the equals and hashCode methods for the primary key class:com.armanta.ejb.ObjectPK are implemented incorrectly. Please check the equals and hashCode implementations.
    javax.ejb.EJBException: [EJB:010108]The EJB Lock Manager has received an unlock request from EJB:PortfolioMetaData with primary key:[ObjectPK: type: PortMetaData name: PortMetaData]. However, this primary key could not be found in the Lock Manager. This indicates either an EJB container bug, or the equals and hashCode methods for the primary key class:com.armanta.ejb.ObjectPK are implemented incorrectly. Please check the equals and hashCode implementations.
         at weblogic.ejb.container.locks.ExclusiveLockManager$LockBucket.unlock(ExclusiveLockManager.java:409)
         at weblogic.ejb.container.locks.ExclusiveLockManager.unlock(ExclusiveLockManager.java:170)
         at weblogic.ejb.container.manager.ExclusiveEntityManager.afterCompletion(ExclusiveEntityManager.java:723)
         at weblogic.ejb.container.manager.ExclusiveEntityManager.afterCompletion(ExclusiveEntityManager.java:667)
         at weblogic.ejb.container.internal.TxManager$TxListener.afterCompletion(TxManager.java:984)
         at weblogic.transaction.internal.ServerSCInfo.callAfterCompletions(ServerSCInfo.java:862)
         at weblogic.transaction.internal.ServerTransactionImpl.callAfterCompletions(ServerTransactionImpl.java:2913)
         at weblogic.transaction.internal.ServerTransactionImpl.afterCommittedStateHousekeeping(ServerTransactionImpl.java:2806)
         at weblogic.transaction.internal.ServerTransactionImpl.setCommitted(ServerTransactionImpl.java:2851)
         at weblogic.transaction.internal.ServerTransactionImpl.globalRetryCommit(ServerTransactionImpl.java:2650)
         at weblogic.transaction.internal.ServerTransactionImpl.globalCommit(ServerTransactionImpl.java:2570)
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:277)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:226)
         at weblogic.ejb.container.internal.BaseEJBHome.postHomeInvoke(BaseEJBHome.java:389)
         at weblogic.ejb.container.internal.EntityEJBHome.findByPrimaryKey(EntityEJBHome.java:408)
         at com.armanta.ejb.portfolio.PortfolioMetaData_a4zvzk_HomeImpl.findByPrimaryKey(PortfolioMetaData_a4zvzk_HomeImpl.java:64)
         at com.armanta.ejb.portfolio.PortfolioMasterBean.getPortfolioMetaData(PortfolioMasterBean.java:313)
         at com.armanta.ejb.portfolio.PortfolioMaster_fmk9e8_EOImpl.getPortfolioMetaData(PortfolioMaster_fmk9e8_EOImpl.java:64)
         at com.armanta.ejb.portfolio.PortfolioMaster_fmk9e8_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:517)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:407)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:403)
         at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:56)
         at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:934)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    I checked the equals and hashCode implementations and nothing pops out at me. Once this happens, the EJB seems to get messed up in the database and I lose information!
    Here is the class implementation along with its superclass. I don't see anything blatant. Sorry for the lack of indentation, my original post was indented.
    Thanks
    Eric
    public class ObjectPK extends ArmantaPK {
         private String type;
         private String name;
         private ObjectPK() {
              super();
         public ObjectPK(String type, String name) {
              super();
              this.type = type;
              this.name = name;
         public String getName() {
              return name;
         public String getType() {
              return type;
         public String toString() {
              StringBuffer buffer = new StringBuffer();
              buffer.append("[ObjectPK:");
              buffer.append(" type: ");
              buffer.append(type);
              buffer.append(" name: ");
              buffer.append(name);
              buffer.append("]");
              return buffer.toString();
         * Returns <code>true</code> if this <code>ObjectPK</code> is the same as the o argument.
         * @return <code>true</code> if this <code>ObjectPK</code> is the same as the o argument.
         public boolean equals(Object o) {
              if (this == o) {
                   return true;
              if (!super.equals(o)) {
                   return false;
              if (o == null) {
                   return false;
              if (o.getClass() != getClass()) {
                   return false;
              ObjectPK castedObj = (ObjectPK) o;
              return ((this.type == null ? castedObj.type == null : this.type
                   .equals(castedObj.type)) && (this.name == null
                   ? castedObj.name == null
                   : this.name.equals(castedObj.name)));
         * Override hashCode.
         * @return the Objects hashcode.
         public int hashCode() {
              int hashCode = super.hashCode();
              hashCode = 31 * hashCode + (type == null ? 0 : type.hashCode());
              hashCode = 31 * hashCode + (name == null ? 0 : name.hashCode());
              return hashCode;
         public Object clone() {
              ObjectPK inst = new ObjectPK();
              inst.type = this.type == null ? null : new String(this.type);
              inst.name = this.name == null ? null : new String(this.name);
              return inst;
    public abstract class ArmantaPK implements Serializable, Cloneable, Comparable {
         // Enforce compatability with future versions
         private static final long serialVersionUID = 1980721424128862564L;
         // Cache the hash code
         private transient int hash = 0;
         * Clones a primary key. Note that this is not a deep copy.
         * @return the cloned primary key
         public Object clone() throws CloneNotSupportedException {
              ArmantaPK newKey = (ArmantaPK) super.clone();
              newKey.hash = 0;
              return newKey;
         * Compare the specified object with this key for equality.
         * Implementations should return <tt>true</tt>
         * if and only if the specified object is also a key
         * of the same class and all corresponding attributes in the keys are
         * <i>equal</i>.
         * @param other the object to be compared for equality with this key.
         * @return <tt>true</tt> if the specified object is equal to this key.
         public boolean equals(Object other) {
              return other instanceof ArmantaPK;
         * This implementation only returns an empty String.
         * @return String
         public String toString() {
              return "";
         * Return the hash code value for this key. Implemented to call the
         * key's <code>computeHash</code> method and cache the result for
         * faster operation. Classes extending <code>ArmantaPK</code> should
         * only implement <code>computeHash</code>.
         * @return int
         public int hashCode() {
              if (hash == 0) {
                   hash = computeHash();
              return hash;
         * @y.exclude
         * Compute a hash code for this key. This is the method that should
         * be overridden by sub-classes.
         * @return int
         protected int computeHash() {
              return 0;
         * @y.exclude
         * After called, will force the hash code to get recomputed.
         public void rehash() {
              hash = 0;
         * Compares this <tt>ArmantaPK</tt> to another object by comparing
         * their string representations.
         * @return an integer based upon comparing the <tt>ArmantaPK</tt>s string
         * representations
         public int compareTo(Object o) {
    return toString().compareTo(o.toString());
    }

    We are experiencing a similar error after upgrading 9.2 to 9.2 MP3. We do not want to upgrade to 10g at this time. Is there a patch we can download with the fix?

  • How do I obtain the next number for a Primary Key using an ADF View Object?

    I have two separate View Objects (A & B) for the same Entity Object. View Object A does a SELECT on all of the fields in the table. This View Object is where I execute my adds and updates. View Object B is only used to retrieve the next number for the primary key. This is done so that when I add a row to the database, I always get the max number of the primary key and add one to it. I accomplished this by setting the SQL mode to Expert and using the SQL: "SELECT MAX(NBR) AS MAX_NUMBER FROM TABLE_1". This may be overkill having a seperate View Object for this, but so far this is the only way I have found to obtain the next number. However, I have discovered that this way does not always work.
    The problem I'm running into is when I try to add multiple records to View Object A without committing the transaction between each add. Because View Object B is disconnected from View Object A, the MAX_NUMBER of View Object B comes back with the same number for each add I do on View Object A. So I know I must retrieve the MAX_NUMBER from View Object A.
    I've tried using the following code in my Table1ViewImpl class:
    this.setQuery("SELECT MAX(Table1.NBR) AS MAX_NUMBER FROM TABLE_1 Table1");
    this.executeQuery();
    The view object now has what I want, but I have yet to figure a way to extract the MAX_NUMBER out of the View Object. I've also looked into using the method addDynamicAttribute() but I can't figure out any way to set the attribute with the MAX_NUMBER.
    I can't be the only one trying to retrieve the next number from a database table using ADF. Can anyone help me with this? FYI - I'm using JDev 10.1.3 EA.

    You missing the point.
    On a multi-user db knowing the next highest number doesn't guarantee the number will be available when it comes time to commit the record. You can prove this to yourself by opening two instances of your app and do whatever you do to add a new record to your VO. Both will assume the same number, and when you commit an error will be generated
    You must use sequences to avoid the possibility of duplicate keys. If you are trying to avoid gaps in your numbering then you need to convince yourself why this is necessary.

  • How to specify  tablespace for a primary key inde in create table statement

    How to specify the tablespace for a primary key index in a create table statement?
    Does the following statement is right?
    CREATE TABLE 'GPS'||TO_CHAR(SYSDATE+1,'YYYYMMDD')
                ("ID" NUMBER(10,0) NOT NULL ENABLE,
                "IP_ADDRESS" VARCHAR2(32 BYTE),
                "EQUIPMENT_ID" VARCHAR2(32 BYTE),
                "PACKET_DT" DATE,
                "PACKET" VARCHAR2(255 BYTE),
                "PACKET_FORMAT" VARCHAR2(32 BYTE),
                "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
                 CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") TABLESPACE "INDEX_DATA"
                 TABLESPACE "SBM_DATA";   Thank you
    Edited by: qkc on 09-Nov-2009 13:42

    As orafad indicated, you'll have to use the USING INDEX clause from the documentation, i.e.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE TABLE GPS
      2              ("ID" NUMBER(10,0) NOT NULL ENABLE,
      3              "IP_ADDRESS" VARCHAR2(32 BYTE),
      4              "EQUIPMENT_ID" VARCHAR2(32 BYTE),
      5              "PACKET_DT" DATE,
      6              "PACKET" VARCHAR2(255 BYTE),
      7              "PACKET_FORMAT" VARCHAR2(32 BYTE),
      8              "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
      9               CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") USING INDEX TABLESP
    ACE "USERS"
    10               )
    11*              TABLESPACE "USERS"
    SQL> /
    Table created.Justin

  • Comp. Primary key class-field mapping to DB columns problem.(EJB 2.0 CMP)

    Hi!
    I have deal with EJB 2.0 CMP bean.
    I have a composite PK so use the java class to store it. And there is a corresponding field in the Entity Bean with its primary key class type.
    The problem is: when deployment tool creates sql query for the findByPrimaryKey(PKClass ck)
    where ck is an object with 3 fielde : a_id, b_id, c_id.
    it says:
    <sql>SELECT "ck" FROM "MyTable" WHERE "ck" = ? </sql>
    And it means by the "ck" simple a column in DB but NOT the composite key which has to be splited into 3 different fields. So the container can't do the proper mapping.
    Does anyone know solutions?

    I was wrong about primary key class fields, take a look at Ejb2.0 Specification (10.8.2):
    The primary key class must be public, and must have a public constructor with no parameters.
    All fields in the primary key class must be declared as public.
    The names of the fields in the primary key class must be a subset of the names of the container-managed
    fields. (This allows the container to extract the primary key fields from an instance�s container-managed
    fields, and vice versa.)
    Right now I'm using BMP and I don't have this problems. Primary keys, calculated fields and types not supported by the DB can be easily achieved. But I understand your interest on CMP, is clearly evolving!

Maybe you are looking for