How my EntityBean knows about its primary key?

Well, i found a dubious place in my EntityBean.
I wrote an ItemBean with some simple getter and setter methods.
It has 3 instance variables:
- String id, (primary key)
- String productId,
- String name
Here is the code of my application client:
Context init = new InitialContext();
Object ref = init.lookup("java:comp/env/ejb/ItemBean");
ItemRemoteHome home = (ItemRemoteHome)PortableRemoteObject.narrow(
    ref,ItemRemoteHome.class);
ItemRemote remote = home.create("x","y","z");
String key = remote.getPrimaryKey();
System.out.println(key);The code works well, but i dont know how my EntityBean knows its primary key when
i call the remote.getPrimaryKey() method.
i traced the method invoking and checked the server log.
// when calling home.create()
the bean's constructor is called to create a bean
setEntityContext() is called. but now the primary key in the entity context is null
ejbCreate() and ejbPostCreate() is called
( i inserted a row to the DB in the ejbCreate() method)
ejbStore() is called
// when calling remote.getPrimaryKey();
ejbLoad() is called, so all the bean's instance variables are refreshed
but non of the getter or setter methods are called
I think that the primary key is taken from the entity context instead of the bean.
but when did the entity context get the primary key?
I never tell the bean that its primary key is its id.
Stange, isnt it?

I never tell the bean that its primary key is its id.You should be returning the primary key from the ejbCreate method. The container picks that up and pops it into the EJB context.

Similar Messages

  • My touch screen isnt working. how do i know if its broken?

    my touch screen isnt working on my ipod touch. i cant get past slide to unlock or slide to power off. how do i know if its actually damaged or if i just need to altar a setting or restore etc?

    See Here for
    Frozen or unresponsive iPod touch
    Try this First... You will not lose any Data...
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    Wait for the Apple logo to Appear...
    Usually takes about 15 - 20 Seconds... ( But can take Longer...)
    Release the Buttons...
    http://support.apple.com/kb/ht1430
    If that does not work... try letting the battery fully drain.
    Then Charge for an Hour and try the Reset again.

  • Getting the UPDATEd value and its primary key

    I have two procedures, proc1 and proc2.
    In proc1 there is an update happening like
    CREATE OR REPLACE procedure proc1
    as
    TYPE NumList IS TABLE OF employees.employee_id%TYPE;
    enums NumList;
    TYPE NameList IS TABLE OF employees.last_name%TYPE;
    names NameList;
    BEGIN
    UPDATE emp set sal=900 WHERE department_id = 30
    RETURNING employee_id, last_name BULK COLLECT INTO enums, names;
    DBMS_OUTPUT.PUT_LINE('Updated ' || SQL%ROWCOUNT || ' rows:');
    FOR i IN enums.FIRST .. enums.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE('Employee #' || enums(i) || ': ' || names(i));
    END LOOP;
    END;
    /In proc2 which is getting executed just after proc2 i want to SELECT the sal column values and its primary keys(employee_id) which got updated in proc 1.
    How can i achieve this?

    add two out parameters from proc1 so that you can pass them into proc2 (obv. you'd need to add two in parameters to proc2 if they aren't there already)

  • Let me know the standary primary key tables in standard table??

    let me know the standary primary key tables in standard table??

    Hi,
    You can go and check the primary keys of a table in SE11 by entering the table name and pressing display.
    You will get to see that there will be some fields with a tick mark in the primary key column.The fields which have such tick marks are the primary keys of that table.
    As far as I know there is nothing called primary key tables.All tables have some fields as primary keys based upon which a record is uniquely defined in that table.
    Hope it was useful.
    Thanks,
    Sandeep.

  • How to impliment a auto increamenting  primary key feature in ADF ??

    How to implement an auto incrementing primary key feature in ADF ( With out using database Triggers)
    Edited by: Dinil Mithra on Apr 24, 2009 2:28 AM
    Edited by: Dinil Mithra on Apr 24, 2009 2:59 AM

    Dinil,
    Create a sequence in the database.
    Read section 4.11.5 of the Fusion Developer's Guide - which has sample code to get the next sequence value from Java without a database trigger.
    John

  • How can I know about the latest updates / versions which when available for all the CC products, without having to install and check it with the Desktoip Creative Cloud Application ?

    How can I know about the latest updates / versions which when available for all the CC products, without having to install and check it with the Desktoip Creative Cloud Application ?

    Thanks for looking into this Jeff!
    I work with an Inventory module software and is responsible for software detection across several computers. Once an updated version comes up, I update our database with latest software details to get it detected if installed on any machines.
    The problem tracking updates with Desktop Creative Cloud Software are;
    1)We have to have it installed with the CC applications in-order to get the notification of the latest updates and have to check everyday.
    2)Only relates to the latest updates, so in-between we may miss a prior update unknowingly.Hence, the remote machines having those updates may not get  detected with the software version update which would create problem in reporting.
    3)For all CC products, there is no base or previous updates available for installation if we miss one.
    I went through the Adobe Products Update pages [Product updates] which holds good when it comes to Acrobat and Reader software which I follow to track down any newer updates but this is inconsistent when it comes to CC products like in After Effects CC, Dreamweaver CC etc...
    So overall to be very specific, is there any one channel I can follow to get the notifications only for the updates on CC products and then may be I can rely on Desktop Creative Cloud for installation if not available anywhere like in product update pages of Adobe ?
    Regards,
    Subrat

  • How can i know about any users who log on sap last one month..all data and

    Dear all,
    how can i know about any users who log on sap last one month..all data and  transaction code they used in a month.
    Regards,
    ASHUTOSH
    9891595497

    Dear Ashutosh,
    I think your question is in the wrong forum. This is for SAP MDM related questions and answers. SAP MDM does not use Transaction codes. So you may not get much help here.
    Please try posting your question in the ABAP forums and you may get the right resources to help you.
    Thanks.
    Siva K.

  • I have monthly subscription app how can i know about who cancel subscription ? and how i can calculed the monthly revenue ?

    i have monthly subscription app how can i know about who cancel subscription ? and how i can calculed the monthly revenue ?

    Apple20141 wrote:
    Or open sim tray and find out the carrier ring the carrier and give them numbers on sim
    The carrier will not give out information about the owner of the phone.

  • I have monthly subscription app how can i know about who cancel the supscription ?

    i have monthly subscription app how can i know about who cancel subscription ? and how i can calculed the monthly revenue ?

    Apple20141 wrote:
    Or open sim tray and find out the carrier ring the carrier and give them numbers on sim
    The carrier will not give out information about the owner of the phone.

  • I have a damaged iPhoto software, I bought the apps, and it says its installing, how long will it take to install? How do I know if its installing

    I have a damaged iPhoto software, I bought the apps, and it says its installing, how long will it take to install? How do I know if its installing

    I use the Download Statusbar add-on for exactly the reasons you are mentioning. See the demo here
    [http://youtu.be/BUDqWrJ-Vao Using Download Statusbar]
    To install the addon, see
    [[Find and install add-ons to add features to Firefox]]

  • How to create sequence based (SERIAL) primary key?

    Does anybody know any workaround to modify dictionary table outside Web Dynpro?
    I specify default column value in SQL Studio:
    ALTER TABLE PB_ORGANIZATION COLUMN ORG_ID ADD DEFAULT SERIAL(1)
    Everything is OK, but when I try to insert values in modified table from Web Dinpro EJB application I get the error:
    com.sap.engine.services.ejb.exceptions.
    BaseReliableNoSuchEntityException: The entity does not
    exist in the database. Its value in the cache has to be
    refreshed.
    It seems WebAS keeps some metadata, generated by Web Dynpro, and manual changes in a database table put it out of sync with this metadata.
    I need serial primary keys in my project. Is it possible to solve the above problem?

    I'll better send You entire application. It has Web Service frontend (PhoneBook) which can be used for testing. Method createOrganization() throws the exception.
    No, this error appears in EJB application only.
    BTW, I have even made attempt to replace <default-value>0</default-value> by <default-value>SERIAL(1)</default-value> but it didn't help.

  • How to pass values for compound primary keys for updating the record in db.

    i have a entity bean in my ejb with two primary keys to it...eg. roleid,rolename...
    when iam retriving the record i use only one primary key ...so again to modify and update he same record which i retrived is a pbm..
    i cannot set the values for the compoundpk,,,
    but i can do the update for the bean with single primary key..
    i need to know how to pass the values/parameters for the coumpound primary key in my update method...
    thanx in advance...
    Arjun.G

    I istantiated a object for the pk class and assign the values for the primary key fields...
    Arjun.G

  • How to get the inserted row primary key with out  using select statement

    how to return the primary key of inserted row ,with out using select statement
    Edited by: 849614 on Apr 4, 2011 6:13 AM

    yes thanks to all ,who helped me .its working fine
    getGeneratedKeys
    String hh = "INSERT INTO DIPOFFERTE (DIPOFFERTEID,AUDITUSERIDMODIFIED)VALUES(DIPOFFERTE_SEQ.nextval,?)";
              String generatedColumns[] = {"DIPOFFERTEID"};
              PreparedStatement preparedStatement = null;
              try {
                   //String gen[] = {"DIPOFFERTEID"};
                   PreparedStatement pstmt = conn.prepareStatement(hh, generatedColumns);
                   pstmt.setLong(1, 1);
                   pstmt.executeUpdate();
                   ResultSet rs = pstmt.getGeneratedKeys();
                   rs.next();
    //               The generated order id
                   long orderId = rs.getLong(1);

  • Help - How do I manually configure SQLServer primary key?

    The help under title "Limitations Using SQLServer" states that when running in "design time" tables with primary keys aren't picked up. I can see that it is specified under the table's structure indices but it is not offered when I try to construct a Business Component "View." The help states that "You must put a primary key in manually to compile the project." It also says that "since BC4J design time requires a key you will need to assign one attribute a key as well." So here's the paradox. I can't figure out how to tell JDeveloper what field is the primary key. Consequently, I can't construct "views" and consequently I can't define "Application Modules" and thus can't change my "Configurations" settings for it.
    For the development team, I recommend that you make specifying the application key more intuitive. Perhaps a right click on the structure field of interest could yield a drop-down list with appropriate options. For configuring database connections, perhaps right clicking the entity in the System Navigator could yield an appropriate "Configuration" option that would allow the user to map everything about the connection from there.

    Dean,
    thanks for your comments: we are actively working on making
    the tool easier to use for "foreign" databases.
    The documentation shoulkd be clearer here: you need to define your
    primary keys against the ENTITY, not the view. If you run against
    Oracle, this happens automagically, but against SQL*Server, you should
    run the wizard but don't pick any tables.
    Then, right-click on the application module and invoke the
    "New Entity Wizard". After you have picked the table, you should
    see the UI to assign properties to the attributes.
    Assign a PK to one, and leave the "automatically create default view"
    checkbox selected, and you should have an ok time.
    Incidentally, if you are prepared to work a little bit with the
    SQL*Server schema, this is the workaround for the bug:
    Create a login with the same name as the owner name, for example,
    "dbo". Then our tool will recognise constraints.
    regrads, Karl

  • How to use AttributeHierarchyOptimizedState property with Primary Key of the Dimension?

    I'm reading the article about increasing SSAS performance. http://www.mssqltips.com/sqlservertip/2567/ssas--best-practices-and-performance-optimization--part-3-of-4/
    I would like to increase processing performance of Customer Dimension with CustomerID as the primary key. It is a good practice to set AttributeHierarchyOptimizedState to NotOptimized to CustomerID attribute. What are the implications to the query
    performance?
    Please advise.

    Hi,
       Since the CustomerID is the primary key (surrogate key) and the usual practice is to hide the surrogate keys in client tools. It is the best practice to set the AttributeHierarchyOptimizedState to NotOptimized to CustomerID attribute. As specified
    in the article SSAS will not create Bitmap indexes on top of that attribute and it saves a lot of processing time and decreases the cube size.
    Regards,
    Venkata Koppula

Maybe you are looking for

  • Looking for a MFC, printer/scanner

    I am looking for an all in one printer scanner. I need both the printer and the scanner to work in arch linux, and I don't want to spend a week making it happen. I would prefer something that supports ethernet and both features work over the network

  • Indesign 5 - Pdf export - Changing transparency opacity

    Just installed CS5. Its my first time in Indesign for CS5. I need to make some changes on an Indesign doc I created in CS4 and save to pdf. There is a background image that I have on every page of the doc... its set to opacity of 40%. Every time I tr

  • Method called three times on page loading

    I have a page with panelTabbed and several showDetailItems. On the first showDetailItem I have ADF Query component with the results table. I want the second showDetailItem to be enabled or disabled depending on whether there is a selected row in the

  • Cannot find imported iPhone photos in iPhoto?

    Where do they go?  They are not in last import?  They are listed as "already imported"... I've tried importing to an album but none of them show up?  I've tried straight import but none of them show up?  Where are they?  I'm looking to do a mass dump

  • No Document Opened / Message No. SOFFICEINTEGRATION 022

    Dear all, I got a problems when I want export a report to excel at IFRS report. just got a blank windows without excel running. SAP prompt: No Document Opened Message No. SOFFICEINTEGRATION 022. Previously after I button F8, I'll got a popup excel wi