No primary keys a generated by DPL

Hi developers,
when going on to store one entry after the other in a loop (out of a ArrayList) the sequence generator of the DPL generates just one new key. So only one entry is stored, updated with the last value.
Do I store one entry after the other (without a loop) it works fine!
A very simple test shows the problem. Assume there is the simplest key/value DB with a sequenced PrimaryIndex and one value annontiated as secondary key.
     ArrayList<String> stAL = new ArrayList<String>();
          ArrayList<Long> loAL = new ArrayList<Long>();
//Shell be stored one after the other in a loop
          stAL.add("One");
          stAL.add("Two");
          stAL.add("Three");
          desi.setKey((long)0);
//Transaction handle available or not doesn't affect the result in anyway
          Transaction txn = env.beginTransaction(null,null);
          for (int i=0;i<stAL.size();i++) {
//Lookup if entry is already stored
               desiR = desiA.byPrim.get(stAL.get(i));
//Store the entry if not
               if (desiR==null) {
//Set Value in Desi Object
                    desi.setDesignator(stAL.get(i));
//Store object
                    desiA.byKey.putNoReturn(txn,desi);
//wrap the key for printout purposes
                    loAL.add(desi.getKey());
//print out what just stored
                    System.out.println("DesiKey - "+desi.getKey());          
                    System.out.println("Designator - "+
                              desi.getDesignator());
          txn.commit();
          System.out.println("Read out last input");
          for (int i=0;i<loAL.size();i++) {
               desi = desiA.byKey.get(loAL.get(i));
               str = desi.getDesignator();
               if (st.length()==0) str = "NIL";
               System.out.println(""+(i+1)+".("+
                         loAL.get(i)+") "+str);          
Here the Printout:
(Out from the loop)
DesiKey - 301
Designator - One
DesiKey - 301
Designator - Two
DesiKey - 301
Designator - Three
Read out last input
1.(301) Three
2.(301) Three
3.(301) Three
What do I have to do making the sequence generator do its work even if it is to go fast?
Thaks for any help!
Regards
Joachim

Hi developers,
found the error by myselve!
Have to set the primaryindex to 0 within the loop, because it is set by DPL after every access!
So, nothing for bad, thanks in anyway!
Regards
Joachim

Similar Messages

  • Knowing the Primary Key Sequence Generator of a table

    Hello All,
    I'm working on an application that uses Oracle toplinks/JPA for persistence. The entity classes in the application have primary key fields with annotations @Id and @GeneratedValue(strategy = GenerationType.AUTO). Per our understanding, this means the primary key generation is done by JPA/Top-links. When we see our database, we notice only one SEQUENCE table available and that table has only one row, while in the application, we are getting different sequence numbers for the primary key of each entity. So, not clear on how this sequence number is generated. Could anybody share information on where the sequence number is stored for each entity/table? Really appreciate your help here. Our database is MSSQL.
    Thank you,
    Venkatesh

    EclipseLink/TopLink uses Table sequencing for GenerationType.AUTO because it is more portable between databases. My understanding of your issue is from
    http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Table_sequencing
    Each row in the table represents one sequence generator, and your entities are all using the same default sequence generator and so all use the same row.
    To use multiple rows I believe you need to define multiple TableGenerators.
    Best Regards,
    Chris

  • Entity bean with primary key generated by trigger

    Hi,
    We have a table(oracle) with one column as primary key,
    but the primary key is generated by trigger every time
    a new row is inserted into this table, inside the trigger,
    it uses oracle sequence to get the next val.
    If we want to use entity bean with it, what should we specify, it's not application-managed primay key, it's
    not auto-generated primary key either. How can we resolve
    it without change the database part.
    Any thought is appreciated.
    Thanks
    afang

    The code is already there with JDBC call inserting
    into the table, the inserting trigger then will generate
    sequence key and being inserted into primary key column.
    Now wondering if it's possible to change the code to use entity bean but without modifying the trigger (since it contains other business logics).

  • How to "auto" generate "Primary Key" in custom table?

    Hi Folks,
    Requirement:
    I need a function module or program that can create automatically a primary key.
    Scenario:
    I have a program that creates an entries and save it to a custom table at the same time, but a primary key should always be generated respective to the entries saved.
    Example:
    Material(MATNR) 4001001, Plant(WERKS) XX01, ID[Primary Key-auto generated]
    (I'm thinking of a similar concept/logic on how a unique IDOC number is being generated or how SAP standard creates a unique entry)
    I try to look for any SAP FM that can generate a PK, but there's no luck.
    Thanks.
    Regards,
    Jun

    Hi Keshu and All,
    The links are helpful, however:
    #1. I don't have authorization to create a new object in transaction SNRO, but the way I see the objects in SNRO is just for defining the length(number of characters) for the ranges that will be use if I'm not mistaken.
    #2. FM NUMBER_GET_NEXT - yes it can populate incremental unique entries but it's only occurring at runtime ?? So when the program get terminated it's not being saved nowhere.
    So after if I use FM NUMBER_GET_NEXT, I always have to look for all the last primary key in my custom table, then target it as my starting point for creating a new PK.  I think this will give a performance issue, any comments?
    For better visualization, I have scenario:
    1.  (ZQ_CREATE_PK) Create unique incremental PK for material, batch, so on..
    2.  Append line/entries to ZQ_TABLE
    3.  Repeat #1 and #2
    4.  User exits the program
    5.  Back to 1 --> At this point, I need to get the "LATEST" PK then start this as a starting point again to generate PK and append it to ZQ_TABLE
    I'm assuming that SAP has other SAP FMs related in creating this scenario.   Similar to IDOC # creation..
    Thanks.

  • Primary Keys and Triggers

    I am developing a web application for the agency I work for and would like to use toplink (10g, aka 9.0.4). The agency has hade a policy since about Oracle 6 that all primary keys will be generated by a standard trigger returning a 32 character string. This policy is unlikely to change.
    Can toplink be used in this scenario? It does not appear that this is possible. I have seen the "return policy" example which appears to be a solution, but this is for a prototype version of 10g that is not yet released. At least, that is my interpretation.
    Can toplink 10g (9.0.4) insert records into tables where the primary key is generated by a trigger?
    Can this be configured in the Workbench or is this configured manually (if at all)?
    Thanks,
    Brad Smith

    Really it's an impedence mismatch issue.
    With or without TopLink, no matter what you do you're going to always have to do two round trips to get new data in the database (once to Insert it and once to read the PK for use in the cache).
    The question I usually ask is -- is this generated PK relevant to your business model? If it's not relevant, then don't map it, and create and use your own PK that can be managed in the mid-tier, use native sequencing, or some other O-R friendly approach. Go ahead and let the database trigger-generate keys, as long as you have some other unique value for the object, then it doesn't matter if the DB trigger generates one for it's own purposes.
    If you do at some point need this tigger generated value, you can make use of events. Pre/post insert/update/delete/write, whatever, events can be used to get/manage the trigger generated data on the database through JDBC calls.
    Bottom line is that impedence mis-match is your enemy in this situation, and TopLink has the event framework at your disposal to work with this mismatch.
    - Don

  • Database Deferred Primary Key generation

    Does anyone know how to configure 9iAS J2EE/OC4J to defer the creation of the Primary to the Database? For example, I have a table that is mapped to a CMP bean and the primary key is generated by a trigger in the database. I want the bean to use this database generated value but I can't figure out how to make it happen. I have tried setting the <prim-key-class> to java.lang.Object but that doesn't appear to be enough to get 9iAS to figure out that the primary key field is to come from the database.
    Regards,
    Nigel

    you should set in your entity object the attribute as DBSequence and then create a before insert trigger in the db table to get the pk from a sequence or so, something like:
    CREATE OR REPLACE TRIGGER trigger_name
    BEFORE INSERT
    ON table_name
    FOR EACH ROW
    begin
    select seq_name.nextval into :new.pk_id from dual;
    end;

  • 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.

  • EJB3: One-to-one relationships and auto-generation of primary key values...

    Dear Forum,
    I'm relatively new to JEE, and while I've so far enjoyed the convenience of EJB3 for most things, it seems that I have a corner case that can not be handled by the entity manager.
    First, here's a quick mockup of my entities:
        Gallery
                |
                -- [1] -------[1] ----> Author
                |
                -- [1] -------[M] ---> Photo
                                                  |
                                                  -- [1] ------ [1] -> PhotoImage
                                                                                     |
                                                                                     -- [1] ------ [1] -> IPTCData
                                                                                     |
                                                                                     -- [1] ------ [1] -> EXIFDataI also have a remote, stateless session bean that does nothing more than persist()/merge()/remove() and locate (through find() and a few custom queries) my Gallery and Photo instances.
    Now, the abridged version of my problem is this: when I persist a Photo, it naturally gets its primary key generated (I used @Id and @GeneratedValue). However, for some reason none of the other dependent entities inherit Photo's primary key value. In my client, I create a new Gallery locally and then persist it. I then create new Photo, PhotoImage, IPTCData and EXIFData instances. I add the IPTCData and EXIFData instances to PhotoImage (there are PhotoImage methods for adding those); then I add the PhotoImage instance to Photo (again, Photo has a setter for adding a PhotoImage). Then, I persist the Photo.
    --- Aside: ------------
    I've set up my relationships using annotations like @OneToMany (Gallery references a Collection of Photos), and @OneToOne (Photo's primary key references PhotoImage's primary key; PhotoImage's primary key references the primary keys of IPTCData and EXIFData). I've also added @JoinColumn annotations where necessary.
    Finally, I get the Gallery instance's Photo collection (public Collection<Photo> getPhotos()), I add the Photo to the collection, and I add the Photo collection BACK to the Gallery (public void setPhotos(Collection<Photo>)).
    At this point, the Gallery should have all of my entities contained inside of itself. However, when I persist the Gallery at this point, all of the entities show up in the database, but none of the primary keys get inherited. Photo's primary key gets generated automatically, of course, but the rest have zero (0) as their PK values. I had wanted, for example, IPTCData to get the value of Photo.id.
    I had assumed that the entity manager would persist everything for me provided that I told it, through my annotations, about which entities relate to which. Does persistence only work in the direction of retrieval? That is, does the entity manager only do its thing when fetching (versus setting) data when there is more than 1 object in the graph? I can't believe that it can't, otherwise we'd all be ditching it and going back to straight SQL to do our work.
    Thus, I HAVE to be doing something wrong, or else omitting to do something right.
    I've made other incarnations of the above setup, and none of them have worked perfectly. I've even set up foreign key constraints in the database, but I had my share of unresolvable problems there, too.
    So I guess my big question with all of this is: when you have a deeply nested graph of objects, can the entity manager figure everything out and persist all of the objects correctly and with the right values? If not, boo. If so, how does one accomplish this?
    I know that I could persist each and every entity separately in my client code, but I wanted to have a natural-looking way of piecing all of my entities together. More specifically, I could persist IPTCData explicitly; however, I want to be able to add everything to a Photo and only persist the Photo itself, with the idea that all of the objects and sub-objects would be persisted automagically.
    Is this possible? Or have I bought into a pipe dream with the guarantee of the proverbial magic bullet?
    Thanks to everyone in advance for his/her input.
    Regards,
    Michael

    Daniel,
    Late last night I found the solution to my problem. And you're right, it had everything to do with which side is wired to which. I got confused about which side to consider the "owning" side, since one can look at it from the perspective of the database or the application.
    Interestingly, the first 2 lines of your example code match my client code almost verbatim: First, I create a new Gallery (or else I get an existing one). I then create a new Photo and then add it to the Gallery's collection using add(). I then persist the Gallery. My session bean internally calls EntityManager.merge(gallery). How it differs from your example, though, is in the fact that, on an application level, a Photo has no knowledge whatsoever of a Gallery. Which is to say that my Photo class does not have a 'getGallery()' method. Somehow, Hibernate is able to figure it all out and still update Photo's 'parentIdRef' column in the database. My logs show that Hibernate issues a SQL UPDATE on the Photo after both a Gallery and a Photo have been created. It sets the Photo's 'parentIdRef' column to the primary key value of the owning Gallery.
    Getting back to the matter, my problem was not with being able to map a Photo to a Gallery; rather, I was unable to add a PhotoImage to a Photo and have the relationship get correctly mapped in the database. The relationship between a Photo and a Gallery is many-to-one: there can be many Photo objects inside of a Gallery. In the database, a Photo row contains a 'parentIdRef' column whose value is that of a Gallery's primary key. I used @OneToMany on the Gallery, since a Gallery is, from an application perspective, the "owning" side, even though it's only the Photo that knows who it's referring to since only IT contains the 'parentIdRef' column in the database.
    I tried setting up the relationship between a PhotoImage and a Photo in the same manner, with the PhotoImage having a 'parentIdRef' column and referring to a Photo's primary key. I had annotated the Photo's getPhotoImage() method with @OneToOne, along with an appropriate @JoinColumn.
    It was THIS part that I had backwards. With a @OneToMany relationship, the child refers back to the parent --- it can be no other way. However, with a @OneToOne relationship, the owner refers to the child.
    So, to make a long story short, all I had to do was create extra database columns for Photo. Those columns refer to the primary keys of PhotoImage, EXIFData and IPTCData. Concretely, for example, Photo.photoImageIdRef references PhotoImage.id. And so on and so forth.
    The only negative side-effect of this is that my database-level foreign key constraints are now broken, since Hibernate wants to persist PhotoImage, EXIFData and IPTCData before it persists Photo.
    I have to investigate more deeply the 'cascade=...' option of the @OneToOne annotation in order to find out it relates, if at all, to a database-level cascade.
    Anyway, thanks for the reply. It seems that you had a very good idea about what my problem was. I would have posted the fact that I had resolved the problem last night, except that it was too late and I was heading to bed. If you still want the Duke points, let me know. I don't currently know the rules about if, when and to whom I should issue points in cases like these when I've already solved the problem.
    Regards,
    Michael

  • Primary Key Error

    I imported some tables from a CSV file. When I imported, I chose to use the original Primary Key and generated a new sequence for the primary key's trigger. Now, Whenever I use the forms to add a new record to the table, I get the following error message:
    ORA-00001: unique constraint (MOBILE_INV.TBL_NEXTELPHONE_PK) violated
    What should I do?
    Is there something wrong with the trigger?
    reate or replace trigger "bi_TBL_NEXTELPHONE"
    before insert on "TBL_NEXTELPHONE"
    for each row
    begin
    if :new."PHONEID" is null then
    select "TBL_NEXTELPHONE_SEQ".nextval into :new."PHONEID" from dual;
    end if;
    end;
    Is there something wrong with the sequence? (Here's my current sequence)
    Min Value 1
    Max Value 999999999999999999999999999
    Increment By 1
    Cycle Flag N
    Order Flag N
    Cache Size 20
    Last Number 21

    Hello,
    It looks like you already had some records in your table before you created the sequence and triggers. Recreate the sequence and use as Min value the value +1 of the max in your table.
    Regards,
    Dimitri
    -- http://dgielis.blogspot.com/
    -- http://apex-evangelists.com/
    -- http://apexblogs.info/

  • Form not displaying primary key field

    I create a form and the primary field is not displayed???

    Hi user10731167.
    When u use a create form wizard, it ask u about your primary key column, and build the form with the primary key element hidden.
    Depending you data structure, you'd want the primary key be generated trough a trigger firing a sequence or not, but many times this is a no relevant data for the user but relevant to manipulate DML operations.
    Depending your preferences, you can change this element type to standard (read only) o standard read write to "show" it, but this is not an option when you manage couple of tables where primary key of master tables are referenced in detail tables.
    Happy year

  • Primary key column as the key of the cache

    Hi All,
    I am implementing a cache backed by HibernateCacheStore for a table. Cache contains key as the primary key of the table and value as the entire row in object format. the primary key is generated by hibernate.
    when i am inserting new rows through coherence (i.e cahce.put) what persistence strategy should is use to set the cache entries.
    I cannot use cache.put (key, value) because key is the primary key of the table which is not generated yet.
    and if i use the session.save(value) the persisted value is not in the cache.
    is there any mechanism to map the cache key as the primary key column of the table.
    Regards
    S

    Hi -
    Using Hibernate as a CacheStore for Coherence, the key of the cache entry is also the key of the entity
    being stored via Hibernate. For this reason keys for new cache entries must be generated ahead of time.
    A UUID can be used. The commons component of the Incubator project has a key generation utility that
    might be worth looking at.
    /Mark

  • Primary keys in CMP

    Hello,
    I have 2 CMP having master and detailed relationship.
    1) BookingMasterBean
    2) BookingDetailsBean
    (having one to many relationship).
    This is to do with a new booking to be made for Squash halls in our application.
    The primary key in Master bean , as well as the details bean get generated by a triggers (on insert) in the database(oracle).
    I have a stateful session bean which handles the booking process( creating entities in both master and details). After create a master entity the key should of the master record should be used as one of CMP field value in the details bean.
    i.e., I need to retreive the generated key once ejbCreate has been executed and should be sent back to the Stateful session bean.
    Can anybody tell me how to do this?

    Whatever you have understood is exactly correct. I am passing a value object as a parameter in the ejbCreate method. The code looks as folows.
    CMP header bean:
    public Integer ejbCreate(BookingHeaderValueObject bookingHeader)
    throws CreateException
    setBookingId(new Integer(bookingHeader.getBookingId()));
    setBookingDate(bookingHeader.getBookingDate());
    setBookingSlot(bookingHeader.getBookingSlot());
    setMemberId(bookingHeader.getMemberId());
    setClubId(bookingHeader.getClubId());
    setHallNumber(bookingHeader.getHallNumber());
    setAccompaniedBy(bookingHeader.getAccompaniedBy());
    setAccompaniedType(bookingHeader.getAccompaniedType());
    setTotalCharges(bookingHeader.getTotalCharges());
    setBookingStatus('B');
    setArrivalStatus('N');
    setDateModified(new Date());
    return getBookingId();
    Session Bean code:
    public void bookSquashHall(BookingHeaderValueObject bookingHeader,
    ArrayList bookingDetails )
    throws RemoteException,
    CreateException, NamingException
    int bookingSerialNo = 0;
    BookingHeaderHome bookingHeaderHome = (BookingHeaderHome)
    getEntityHome("BookingHeaderBean");
    BookingDetailsHome bookingDetailsHome = (BookingDetailsHome)
    getEntityHome("BookingDetailsBean");
    BookingHeader bookingHeaderRemote = bookingHeaderHome.create(bookingHeader);
    if( bookingHeaderRemote != null)
    for( int index = 0 ; index < bookingDetails.size(); index++)
    BookingDetailsValueObject bookingDetailsObj = (BookingDetailsValueObject)
    bookingDetails.get(index);
    bookingDetailsObj.setBookingSlNo(bookingSerialNo+1);
    bookingDetailsObj.setBookingId(bookingHeaderRemote.getBookingId().intValue());
    BookingDetails bookingDetailsRemote = bookingDetailsHome.create(
    bookingDetailsObj);
    bookingSerialNo = bookingDetailsRemote.getBookingSlNo().intValue();
    The following are scripts used to create the table structures :
    create table booking_header (
    bh_bookingid number,
    bh_booking_date date not null,
    bh_booking_slot varchar2(11) not null,
    bh__memberid number not null,
    bh__clubid number not null,
    bh_hallno varchar2(7) not null,
    bh_accompanied_by varchar2(60),
    bh_accompanied_type varchar2(10),
    bh_totalcharges number(10,2) not null,
    bh_status char(1) not null,
    bh_arrived char(1) not null,
    bh_date_modified date not null,
    constraint booking_header_pk primary key(bh_bookingid),
    constraint booking_header_fk1 foreign key(bh__clubid) references club_details(cd_clubid),
    constraint booking_header_fk2 foreign key(bh__memberid) references member_details(md_memberid)
    create trigger booking_header_insert
    before insert on BOOKING_HEADER
    for each row
    declare
    newBookingId number;
    begin
    select nvl(max(BH_BOOKINGID)+1, 1) into newBookingId from BOOKING_HEADER;
    :new.BH_BOOKINGID := newBookingId;
    end;
    create table booking_details (
    bd_slno number,
    bd__bookingid number not null,
    bd_booking_date date not null,
    bd_booking_slot varchar2(11) not null,
    bd__memberid number not null,
    bd__clubid number not null,
    bd_hallfacility char(1) not null,
    bd__facilityid number,
    bd_charges number(10,2) not null,
    bd_status char(1) not null,
    bd_arrived char(1) not null,
    bd_date_modified date not null,
    constraint booking_details_pk primary key(bd_slno),
    constraint booking_details_fk1 foreign key(bd__bookingid) references booking_header(bh_bookingid),
    constraint booking_details_fk2 foreign key(bd__clubid) references club_details(cd_clubid),
    constraint booking_details_fk3 foreign key(bd__memberid) references member_details(md_memberid)
    create trigger booking_details_insert
    before insert on BOOKING_DETAILS
    for each row
    declare
    newSlNo number;
    begin
    select nvl(max(BD_SLNO)+1, 1) into newSlNo from BOOKING_DETAILS;
    :new.BD_SLNO := newSlNo;
    end;
    Should I be defining the ejb relationships in this case.?
    Also I saw in a search from google that we can implement ejbPostCreate to retrieve the primary key if generated by the container. Could I do something like that in order to get back the primary key.
    Is there any better approach for this. I am fairly new to the subject .

  • Missing Primary Key

    Hi,
    I have this situation where sometimes the primary key is missing or jumps sequence during record saving. It happens occasionally but I do not know when and how it happens.
    The primary key is generated automatically by sequence. For example, last month after the primary key 351 is being saved into table CUSTOMER, the next record is using primary key number 400.
    Earlier this week, the situation happened again. Primary key 904 was recorded into CUSTOMER table. But, the next primary key was 950. I do not know where are primary keys from 905 until 949 went missing.
    I hope anyone could show me how to rectify this.
    Thank you. :-)

    Sequences used Cached values. If a sequence is unused for some time, the cached values may get aged out of the shared pool, resulting in a seeming "loss" of intermediate values (the next call to the sequence will cache values above those just lost).
    Cached values are also lost at shutdown.
    Another situation is when a sequence is incremented but the transaction is not committed but is instead rolled back (either manually or because of some other failure). The incremented sequence value does not get rolled back.
    Sequences are designed to give Unique names. By default, they are not intended to guarantee consecutive numbers.
    Even if you define a sequence as a NOCACHE sequence, you can still lose the last incremented value on a transaction rollback.
    note: A Sequence as a Primary Key is an artificial PK (a "synthetic PK") but is sometimes necessary.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Jul 6, 2012 4:16 PM
    Edited by: Hemant K Chitale on Jul 6, 2012 4:17 PM

  • Entity bean with another class as primary key generator class

    Hi All,
    I have a CMP entity bean in which I generate the primary key using my own class know as unique id generator.
    I use it in ejbCreate method in the following manner
    public Long ejbCreate(HospitalData hospitalData) throws CreateException{
              Long myid = new Long(UniqueIdGenerator.getId());
              System.out.println("My id generated ====== "+myid);
              this.hospitalid = myid;
              System.out.println("My id generated ====== "+this.hospitalid);
              System.out.println("Came in ejbCreate method of HospitalEJB");
              this.hospitalname = hospitalData.getHospitalname();          
              return null;
    Can you tell me how I map this primary key in my ejb-jar.xml and jbosscmp-jdbc.xml.
    Anyhelp would be appreciated.
    Thanks
    Sameer

    "Bhamu" <[email protected]> wrote in message
    news:9keuo4$[email protected]..
    I am trying to develop an entity bean attached to a key which have a
    composite key using Primary Key Class. When I use the findByPrimaryKey
    method of the bean it throws an exception as follows,I notice that you are using the reference CMP plugin.
    at com.netscape.server.ejb.SQLPersistenceManager.find(Unknown Source)I'm also willing to bet that you may have created your own primary key class
    with a single field, rather than using the fields type as a primitive
    primary key class. If you do this, then SQLPersistenceManager will break.
    It is badly written, and has some stupid assumptions. The one I remember
    the most is that if you only have one primary key field, then
    SQLPersistenceManager assumes you have used a primitive type such as
    java.lang.String or java.lang.Integer, to represent it, rather than creating
    your own <Enity>Pk.java file.
    SQLPersistenceManager works for toy examples, but in general I would say it
    is broken and unusable. Either use BMP, or splash out the money for Coco
    Base from Thought Inc. Currently the only CMP plugin for iPlanet App server,
    other than the reference implementation, that I know of.

  • Help required to generate primary key sequence

    Hello All,
    I need your help in generating a sequence for primary key in my db table created using java dictionary project in my NWDS 7.3.
    The table column EMPL_ID is a primary and needs to be a sequence. The code in the JPA entity is as below. The underlying database is DB2 on Linux. Kindly help me resolve this issue.
    * The persistent class for the TMP_EMPL_DATA database table.
    @Entity
    @Table(name="TMP_EMPL_DATA")
    public class TmpEmplData implements Serializable {
         private static final long serialVersionUID = 1L;
         @Id
         @SequenceGenerator(name="EMPLID_GENERATOR", sequenceName="EMPID_SEQ", initialValue = 10000, allocationSize = 1)
         @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="EMPLID_GENERATOR")
         @Column(name="EMPL_ID")
         private String _emplId_;
    My bean class contains a public method as follows.
    public TmpEmplData createEmployee(String employeeName, int age, String location)
             TmpEmplData emplData = new TmpEmplData();
             emplData.set_emplName_(employeeName);
             emplData.setAge(age);
             emplData.setLocation(location);
             entityManager.persist(emplData);
             entityManager.find(TmpEmplData.class, emplData.get_emplId_());
             return emplData;
    During execution, i am getting an error as below.
    Caused by: javax.persistence.PersistenceException: The generated SQL statement is not valid for the underlying database platform (platform no. 99). For more details see attached exception. SQL statement is SELECT NEXT VALUE FOR "EMPID_SEQ" FROM ( VALUES (1) )
    at com.sap.engine.services.orpersistence.sqlmapper.mapping.JPASQLMapperImpl.createSequenceIDGeneratorSelectText(JPASQLMapperImpl.java:1239)
    at com.sap.engine.services.orpersistence.entitymanager.CachedJPASQLMapper.createSequenceIDGeneratorSelectText(CachedJPASQLMapper.java:259)
    at com.sap.engine.services.orpersistence.generator.GeneratorFactory.<init>(GeneratorFactory.java:156)
    at com.sap.engine.services.orpersistence.entitymanager.EntityManagerFactoryImpl$MetaDataImpl.<init>(EntityManagerFactoryImpl.java:323)
    at com.sap.engine.services.orpersistence.entitymanager.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:137)
    at com.sap.engine.services.orpersistence.entitymanager.JtaEntityManagerFactoryImpl.<init>(JtaEntityManagerFactoryImpl.java:39)
    at com.sap.engine.services.orpersistence.provider.PersistenceProviderImpl.createJtaEntityManagerFactory(PersistenceProviderImpl.java:251)
    at com.sap.engine.services.orpersistence.provider.PersistenceProviderImpl.createContainerEntityManagerFactory(PersistenceProviderImpl.java:236)
    at com.sap.engine.services.orpersistence.container.EMFInstanceCreator.getEntityManagerFactory(EMFInstanceCreator.java:134)
    at com.sap.engine.services.orpersistence.container.ORPersistenceObjectFactory.getEMF(ORPersistenceObjectFactory.java:300)
    at com.sap.engine.services.orpersistence.container.ORPersistenceObjectFactory.getObjectInstance(ORPersistenceObjectFactory.java:73)
    at com.sap.engine.lib.injection.ReferenceObjectFactory.getObject(ReferenceObjectFactory.java:96)
    at com.sap.engine.lib.injection.FieldInjector.inject(FieldInjector.java:113)
    ... 122 more
    Caused by: com.sap.engine.services.orpersistence.sqlmapper.generate.SQLMappingException: SQL statement is not valid for underlying database platform.
    at com.sap.engine.services.orpersistence.sqlmapper.common.CommonSQLMappingResult.getStatementString(CommonSQLMappingResult.java:237)
    at com.sap.engine.services.orpersistence.sqlmapper.mapping.JPASQLMapperImpl.createSequenceIDGeneratorSelectText(JPASQLMapperImpl.java:1237)
    ... 134 more
    Caused by: com.sap.sql.tree.StringRepresentationFailureException: Cannot represent next value expression as string.
    at com.sap.sql.tree.impl.OpenSqlTextExpert.nextValueExpressionToText(OpenSqlTextExpert.java:185)
    at com.sap.sql.tree.impl.NextValueExpressionBuilderImpl$NextValueExpressionImpl.toSqlTxt(NextValueExpressionBuilderImpl.java:140)
    at com.sap.sql.tree.impl.AbstractSqlTextExpert.selectSublistToText(AbstractSqlTextExpert.java:130)
    at com.sap.sql.tree.impl.SelectSublistImpl.toSqlTxt(SelectSublistImpl.java:150)
    at com.sap.sql.tree.impl.QuerySpecificationImpl.toSqlTxt(QuerySpecificationImpl.java:361)
    at com.sap.sql.tree.impl.SelectStatementImpl.toSqlTxt(SelectStatementImpl.java:139)
    at com.sap.sql.tree.impl.SQLStatementImpl.toSqlString(SQLStatementImpl.java:75)
    at com.sap.engine.services.orpersistence.sqlmapper.common.CommonSQLMappingResult.getStatementString(CommonSQLMappingResult.java:233)
    ... 135 more

    Hi,
    does the sequence exist? SAP JPA does not support creation of sequences, you have to create it manually.
    Maybe SAP JPA also does not support DB2 sequences with "Open SQL" correctly.
    - Tryp to set your data source to "native" or "vendor".
    - Try to turn on oracle compatibility:
    db2set DB2_COMPATIBILITY_VECTOR=ORA
    Regards
    Rolf

Maybe you are looking for

  • How can you add/change the currency rate in spro?

    Hi all, you can add a new currency code by going to spro --- general settings --- check currency codes for example: PERU ---> PEN But, how can we add/change the currency rate PEN in spro? for example: Peruvian Nuevo Sol     = 4,3567619 Is it still in

  • The threads increase and the iPlanet Web Server 6.1SP5 restart itself

    Hi all, i becoming crazy, with my web servers. I have 3 front-end balanced servers with the same configuration: SunOS 5.9 Generic_118558-22 sparc SUNW,Sun-Fire-V240, 4GB RAM. iPlanet Web Server is 6.1 SP5 Then the problem is: - When i start my Web Se

  • OCI_ATTR_PREFETCH_ROWS

    Hi All, I am having problems setting the attribute OCI_ATTR_PREFETCH_ROWS. I need to set the value of this attribute in order to decrease the number of trips to the server. Until now I am having one row per trip and this causes my application to be v

  • Invoke BPEL process using a java client - NullPointerException

    Hi, We are trying to call a BPEL process using a java client from our Web Application. For some reason the BPEL engine just logs a NullPointerException and exits. The same SOAP request when through SOAP UI tool works great. Any help in resolving this

  • Detection methodology problems with 15.0.0.189 MSI installers

    I have made the latest 16.x updates available to my environment via SCUP + Config Mgr 2012 R2, and I'm noticing that clients with Adobe Flash 15.0.0.189 MSI (ax & plugin) deployed to them are trying to install even though software updates have now br