Setting primary key field value in jdoPrestore() not flushed to database ?BUG?

Hello,
When I set value of primary key field of a new instance in jdoPrestore() new
value does not get flushed to database - old (default) value get stored
instead. All other fields assigned in jdoPrestore() get successfully
flushed except primary key one.
Alex

Abe,
You fixed only part of the problem. Right now if I assign value to a PK
field in jdoPreStore() it does get flushed but there is another issue - all
other instances which referenced the one I assigned PK to will not get this
PK value. Example A references B, in B.jdoPreStore() I generate id for B -
b.id = 100. When A gets flushed it would not get 100 in its b_id field.
Specs says:
This method is called ***before the values are stored from the instance to
the StateManager***.
Data store fields that might have been affected by modified non-persistent
fields should
be updated in this method. This method is modified by the enhancer so that
changes to
persistent fields will be reflected in the data store.
The context in which this call is made allows access to the
PersistenceManager and
other persistent JDO instances.
I read it as callbacks should be invoked on ALL instances before they get
stored to StateManager. Does Kodo invoke callbacks for all istances first
and then store them to instance manager? Based on the problem I am having it
does not look like it
Alex
"Abe White" <[email protected]> wrote in message
news:[email protected]..
I just confirmed this as a bug and fixed it. We should be able to post
the new jars for you soon. Hang in there.

Similar Messages

  • Setting primary key fields from sequence. Please advise

    What is the most logical place to automatically set primary key fields from
    sequence?
    jdoPrestore seems to be a little late - my instance will not have id till
    it's committed. I can not do it in constructor because it gets called every
    time Kodo needs to construct an instance. What other options do I have for
    automatic pk assignment except do it in my code (hate it)?
    I wish I could use store managed OIDs but I need access to OID underlying
    data
    Please also see my previous message "Application Identity Extention"

    I came up with following pattern:
    public class OrgUnit implements InstanceCallbacks {
    private long orgUnitId = -1;
    private transient long tempOrgUnitId = -1;
    public long getOrgUnitId() {
    if (orgUnitId < 0) {
    if (tempOrgUnitId < 0) {
    tempOrgUnitId = JDOFactory.getNextSequenceId(getClass());
    return tempOrgUnitId;
    } else {
    return orgUnitId;
    public void jdoPreStore() {
    if (!JDOHelper.isDeleted(this)) {
    if (orgUnitId < 0) {
    setOrgUnitId(getOrgUnitId());
    I use -1 as an indicator that ID has not been assigned yet. If you use Long
    instead of long it will be cleaner since we can test for null
    "Alex Roytman" <[email protected]> wrote in message
    news:9q27co$r35$[email protected]..
    What is the most logical place to automatically set primary key fieldsfrom
    sequence?
    jdoPrestore seems to be a little late - my instance will not have id till
    it's committed. I can not do it in constructor because it gets calledevery
    time Kodo needs to construct an instance. What other options do I have for
    automatic pk assignment except do it in my code (hate it)?
    I wish I could use store managed OIDs but I need access to OID underlying
    data
    Please also see my previous message "Application Identity Extention"

  • Primary key field problem in DBSchema Wizard

    Hi,
    I am using Sun ONE studio 4 update 1, EE.
    I have generated schema using the Database Schema Wizard.
    The generated table representations does not recognise the primary key fields so I can not map my CMP to any table :-(
    Is this a bug?
    because I have generated schemas from 3 different databases (IBM, MySQL, SAP) and the tables have primary key fields.
    When I get a connection in Runtime Pane under Database node, I can see the primary fields are highlighted with red color.
    However, when I obtain the schema using, New->Database->Database Schema, there are no primary key fields generated.
    Anyone have any ideas, work around?
    Thanks
    Tex...

    First, thanks for posting the code that lets us reproduce your test. That is essential for issues like this.
    Because the primary key is global you will not be able to use
    INCLUDING INDEXES
    WITH VALIDATION;And you will need to add the primary key to the temp table
    ALTER TABLE DEMO_INTERVAL_DATA_LOAD_Y ADD CONSTRAINT IDX_DEMO_ROLL_Y PRIMARY KEY (ROLL_NUM);The the exchange will work. You will need to rebuild the primary key after the exchange.

  • Cannot modify value of primary key field after lookup.

    I realize this could be a WebSphere problem, but I don't know if it is an EJB problem or what? So I'm posting anyway, and adding Duke Dollars in the hopes someone out there has encountered this.
    Okay, I'm using WebSphere Studio Application Developer 4.0.3.
    I am using an EJB that has three primary key fields.
    I use the primary keys to lookup the bean.
    I then want to update the value of one of the primary keys.
    So I create a setter and getter method for that primary key field.
    I then can call the set method, but it does nothing.
    I get no errors.
    It compiles.
    I rebuild, regenerate access beans, and redeploy and rmic.
    I can use ctrl-space to see the functions in the JSP editor.
    However, the set function never gets called for some reason, and I get no runtime exception either.
    For example, if I do this in my code:
    MyBeanFactory myBean = new MyBeanFactory();
    MyBeanKey myBeanKey = new MyBean(name,age,city);
    MyBean myBean = myBeanFactory.findByPrimaryKey(myBeanKey);
    // this function doesn't do anything, because it's a primary key field
    // but it does compile and I get no runtime errors
    myBean.setCity("Orlando");
    // this function works fine, presumably because it isn't a primary key
    myBean.setState("Florida");Questions;
    Is there a restriction that says I can't update the value of a field if it is marked as a primary key?
    If not, what could I be doing wrong?

    Looks like your appserver is working as per the specification.
    Check this out:
    Question
    How can I update the primary key field in a CMP Entity Bean?
    Derived from
    A question posed by Shanks75 shanks75
    Topics
    Java:API:EJB:EntityBean:CMP, Java:API:EJB:2.0
    Author
    Tim Duggan
    Created
    Oct 9, 2001
    Answer
    You cannot change the primary key field of an Entity bean. Refer to page 130 of the EJB 2.0 specification, it states "Once the
    primary key for an entity bean has been set, the Bean Provider must not attempt to change it by use of set accessor methods
    on the primary key cmp-fields. The Bean provider should therefore not expose the set accessor methods for the primary key
    cmp-fields in the component interface of the entity bean."
    A work around to update a primary key field, would be to remove and then an re-create the bean.
    taken from here:
    http://www.jguru.com/faq/view.jsp?EID=515864

  • Can not set OARG.cstAllcAcc field value with CustomsGroups Object

    Can not set OARG.cstAllcAcc field value with CustomsGroups Object, please open this field in this Object because it is a key field related to financial system.

    I guess, it should work; instead of html:submit, try with button.

  • Error when i set primary key to a field in table

    I created a table. with one primary key field
    on saving it following error happened 
    at Microsoft.SqlServer.Management.DataTools.Interop.IDTDocTool.Save(Object dsRef, String path, Boolean okToOverwrite)
    at Microsoft.SqlServer.Management.UI.VSIntegration.Editors.VsDataDesignerNode.Save(VSSAVEFLAGS dwSave, String strSilentSaveAsName, IVsUIShell pIVsUIShell, IntPtr punkDocDataIntPtr, String& strMkDocumentNew, Int32& pfCanceled)
    then i removed primary key. Table was saved successfully.
    I need to make primary key field.. how can i solve it?

    CREATE TABLE tblname (c INT NOT NULL PRIMARY KEY) 
    Have you ran the above statement successfully?  Do you create a table in VS?  
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • "Item Containing Primary Key Column Value" does not display records

    Hello,
    We are developing a new page where an "Automated Row Fetch" process is needed.
    With other pages we experienced no issues. But with a new one, when defining the value for the field “Item Containing Primary Key Column Value”, Apex displays no rows.
    As far as we know, Apex should display all the fields defined for the page. Is there any property which affects the fields visibility?
    The affected page has textarea and text fields.
    Thanks in advance.

    Hello,
    Sorry, we have already detected that the problem was at field definition.
    Fields should be defined as "Source Type: Database Column". They were wrong defined.
    Thanks.

  • Problems referencing a primary key field in a master-detail

    Hello,
    I am making an application where I have a master-detail page.
    In the detail section it is possible to add new rows using the standard "Add row"-button that the wizard creates.
    The detail section has a column with a link in it. This link leads to another part of the application.
    When I press this link I would like to send the field "Id" of the current detail row to the page which the link redirects to.
    So far I have concluded that the primary key field "Id" of the detail is only filled out after I do a submit. So I have my column link set up to do:
    javascript: doSubmit('NAVIGATE_1');
    In the branching I am testing on the :REQUEST object to see if it contains 'NAVIGATE_1' - I can't seem to get the value from the "Id" field though. I tried to add #ID# in the javascript submit call - but since the "Id" is filled only after I submitted then this doesnt really work at all.
    Does anyone have an idea on how to make this work in APEX ? Its probably some simple thing that I just didnt think of yet ;)
    Kind regards
    Bo Normann

    I found a way. I dont like it - but it works.
    I made a column link in the detail with the following:
    javascript: doSubmit('NAVIGATE@#ROWNUM#);
    This way I obtain information in the :REQUEST object about which row was clicked.
    In a After submit process on the page I then parse this :REQUEST object like this:
    DECLARE
    v_row NUMBER;
    v_pos NUMBER;
    BEGIN
    v_pos := instr(:REQUEST,'@',-1);
    v_row := substr(:REQUEST, v_pos+1);
    IF APEX_Application.g_f02(v_row) IS NOT NULL THEN
    :P_PRIMARY_KEY_ID:= APEX_Application.g_f02(v_row);
    ELSE
    :P_PRIMARY_KEY_ID:= -1;
    END IF;
    END;
    I know that my "Id" column is named f02 in the form, so this way I can find the id. I then assign this id to a kind of global variable - on the page I redirected to I can now find the Id.
    Talk about ugly code :P

  • How to add a new data element for existing table filed(Primary key field)

    Hi Experts,
    How to add a new data element for existing table field(Primary key field)
    For this filed ther is no foreign key relation ships and even check table.
    while activating table it is giving message like below.
    can you help any one to solve this and wil steps to add new dataelement for existing primary key filed of a table.
    Check table (NAMING SPACE/TABLE NAME(EX:/TC/VENDOR)) (username/19.02.10/03:29)           
    Primary key change not permitted for value table /TC/VENDOR
    Check on table  /TC/VENDOR resulted in errors              
    Thanks
    Ravi

    Hi,
    Easiest way is to download the table eg into an Excel table (if possible) or text table. Drop the table from the database. Build your table with the new key field. Build the database table again and fill it.
    You can do it also over the database into a new table. Drop the old one. Build the enhanced one and fill it. Afterwards drop your (temporary) table.
    Maybe there are other ways, but this works.
    Success,
    Rob

  • Problems deleting a primary key field in a table.

    Hello Guys,
    I deleted a primary key field in a custom table by clicking 'delete row' icon and then tried activating it through se14 - database utility. It is throwing an error saying 'Primary key change not permited for the value table zxxxx'. What is the problem???
    How can I delete a primary key in a table??
    Please help.
    Thanks,
    Naren

    I am pasting the detail explaination over that error.
    Primary key change not permitted for value table ZTV_RANGE_NUMBER
    Message no. AD 300
    Diagnosis
    This table is defined as a check table. For reasons of consistency, changes to the primary key of the table are not allowed.
    Procedure
    If it is essential that you change the primary key, you must delete the relevant foreign keys. Refer to the where-used list to find all tables containing a field that is checked against this table. Delete the foreign keys for these fields.
    If necessary, maintain the deleted foreign keys again.

  • Adding 2 new fields as Primary Key field in a Z Table which is existing PRD

    Hi Friends,
    I have to add two new fields as primary key fields in a Z TABLE, which is existing in Quality and Production Systems with Data.
    If I incorporate these two new fields (Primary Key fields) in development and if the TR is moved to Quality and Production sytems, is there any possibility of loss in data will happen at Quality and Prd systems?
    At present, Table is having 20 fields with 2 primary key fields and i have to add 2 more primary key fields.
    I have checked in SCN and not find relevant threads.
    Please help me out.
    Regards,
    Suresh.

    NO . It wont be a problem .
    For ex :
    If you have VBELN  , POSNR are key fields now , you have an unique reord with that combination .
    If you add one other field in it  fo ex  VKBUR  then records will be like this
    VBELN     POSNR     VKBUR   MATERIAL   QTY
    10020      10                            abcxyz      1
    10020      10            1234        abcxyz     1
    So your previous records before adding new primary keys , will have new fields balnk , and the new records will have data filled up in all primary key fields .
    However , if you try to update the existing records that will be in existing PRIMARYKEY combination only .
    for example if you try update record 1 above with VKBUR value 85858 , it creates a new record , it wont be updated in existing record.
    Hope this helps , Pls let me know if u have any more doubts.

  • Problems with BC4J input select tag when its bounded to a primary key field

    HI..
    I have an jsp BC4J edit form. This form uses a BC4J input select tag. This component is mapping one of the primary key Entity fields.
    When im working with this component and it doesnt map a primary key field it shows the default "none" value when im inserting a record(thats Ok). but when it maps a primary key field the default value is a database value so it is not advisable.. How can i do in order to fix that?
    Thank you

    The none value is only shown when the field accepts null values.

  • Default Primary Key Field of any database table

    hi,
    I am working on a database in which the data in the tables is generated from some other modules. I have to add, view and update functionalities to this table in the database. Unfortunately there is no primary key field for the table i am working on and as some existing modules are using this table i am not allowed to change the design of the table at this stage.
    Without primary i think its not possible to do updates. Because if all fields can have their values changed, then there will be a breakdown if the field value changes in the mid time when i had already retrieved the data to show on the screen, but not yet updated the value in the database. I hope you understood my problem.
    Please suggest solutions. I am not sure, but i think i read somewhere that every table created has a default primary associated whose value is always incresing with a new addtion of recored and its value never decreases. But i am unable to recollect the field name...i think it is some thing like[b] OID .... But i checked there is no such field name by OID. So please help me with some alternative solution...or by telling the default primary key field name.
    Thanx

    All the databases I know (namely Informix, PostgreSQL, SQL Server, even Access) have a row id column generated automatically.
    PostgreSQL example
    There is a way to read the value of this column; for example with PostgreSQL let�s say you have the following:
    CREATE TABLE no_id_column (
    column_one varchar(80),
    column_two varchar(80)
    INSERT INTO no_id_column(column_one, column_two) VALUES (�red�, �pink�);
    INSERT INTO no_id_column(column_one, column_two) VALUES (�yellow�, �orange�);Certainly, if we executed:
    SELECT * FROM no_id_column;Would obtain:
    column_one          column_two
    red               pink
    yellow               orangeBut if we modify the query
    SELECT  oid, * FROM no_id_column;We magically obtain a row identificator
    oid          column_one          column_two
    21569          red               pink
    21570          yellow               orangeThe data in the oid column is generated automatically by the database manager. Every time we insert a row we�ll have a different one. Just take into account that if the database contains a large amount of data, the oid could cycle.

  • Exception: non-read-only mapping defined for the primary key field

    Hello.
    I'm new to Oracle and I created Java EE Web Project.
    And I created entities from tableA, tableB, tableC from my database.
    tableA has foreign key to tableB and has unidirectional Many-to-One relationship. tableC has two primary keys and one of these is foreign key to primary key in tableA. tableC also has unidirection Many-to-One relationship to tableA.
    Then I created session bean and data control from it, in design window, created read-only table from tableA.
    And I selected columns in tableA and also in tableB.
    I ran the application and saw the following exception in log window.
    Local Exception Stack:
    Exception [EclipseLink-46] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DescriptorException
    Exception Description: There should be one non-read-only mapping defined for the primary key field [tableC.tableA_ID].
    Descriptor: RelationalDescriptor(mypack.tableC --> [DatabaseTable(tableC)])
    tableA_ID is a primary key in tableA.
    How can I solve this error?
    Please help me.
    Edited by: 900471 on 2011. 12. 3 오전 5:32
    Edited by: 900471 on 2011. 12. 3 오전 5:33
    Edited by: 900471 on 2011. 12. 3 오전 5:33
    Edited by: 900471 on 2011. 12. 3 오전 5:34

    There are not enough details to be sure since you have not provided the mappings. From just the error, it looks like you are using the tableC.tableA_ID field as the foreign key in the ManyToOne relationship to A, but have marked it as insertable=false, writeable=false, meaning that it cannot be updated or used for inserts.
    Either make it writable (set the settings to true), or add another basic mapping/attribute in the entity for TableC that maps to the field which you can use to set when you insert a new tableC entity. A simple example is available at
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/DerivedIdentifiers
    Best Regards,
    Chris

  • How to display the Primary key field in Application Form.

    IDFINALNO , USERNAME
    (No view) , RockQin
    I developed one new application form which is including the "Edit" item in every record.
    But I can not find the data that is Primary key field . So how to config the property to display that data.
    Thanks a lot!

    One of the guidelines when selecting column for a primary key is:
    Choose a column whose data values are never changed. A primary key value is only used to identify a row in the table, and its data should never be used for any other purpose. Therefore, primary key values should rarely or never be changed.
    Cheers!

Maybe you are looking for