Non-sequential IDs assigned using sequence="ID" on PrimaryKey

Hello,
I've seen some people asking something similar but I can't get this thing to work and it's driving me crazy. I'm using je-3.2.23 BTW.
I have this simple class:
* SYSADM.java
* Created on 26 de junio de 2007, 09:29 AM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package haven;
import com.sleepycat.persist.model.Entity;
import com.sleepycat.persist.model.PrimaryKey;
* @author Mario
@Entity
public class SYSADM extends Usuario{
private boolean root;
@PrimaryKey(sequence="ID")
private long id;
/** Creates a new instance of SYSADM */
public SYSADM() {
/** Creates a new instance of SYSADM from parameters */
public SYSADM(boolean root,long id, String loginName, String password, String nombre, String apellido, String email) {
super(loginName, password, nombre, apellido, email);
setRoot(root);
//setId(id);
/** Creates a new instance of SYSADM from a VOSYADM */
public SYSADM(VOSYSADM voSYSADM) {
super(voSYSADM.getLoginName(),voSYSADM.getPassword(),
voSYSADM.getNombre(),voSYSADM.getApellido(),voSYSADM.getEmail());
setRoot(voSYSADM.isRoot());
//setId(voSYSADM.getId());
public VOSYSADM getVOSYSADM() {
return new VOSYSADM(this.isRoot(),this.getId(),this.getLoginName(),this.getPassword(),
this.getNombre(),this.getApellido(),this.getEmail());
public boolean isRoot() {
return root;
public void setRoot(boolean root) {
this.root = root;
public long getId() {
return id;
public void setId(long id) {
this.id = id;
and when I add records to the database using DPL I get ids like 1,101,201... and so on.
I've looked at all the examples and tested them myself and I get the same behavior from all the classes I test.
Plus all the tutorials and materials say that this is plain simple... let me quote from PrimaryIndex:
" Employee employee;
employee = new Employee("Jane Smith");
primaryIndex.putNoReturn(employee); // Inserts an entity
assert employee.id == 1;
employee = new Employee("Joan Smith");
primaryIndex.putNoReturn(employee); // Inserts an entity
assert employee.id == 2; "
I don't get... may be I'm plain dumb... should've ask that first to myself... I'm getting desperate here people... really!
Anyway... any help is much appreciated.
Regards to all,
Mario

First of all many thanks for your feedback... it's
really encouraging in times of desperation to find
somebody out willing and actually helping you! You're welcome!
This is good. I'm aware of how RDBMS are integrated
in the AS. Basically you need the driver and the
connection to the database. For DBD JE I have made a
simple test and I can persist objects from a web
application in the AS. I simply open the environment
that points to a directory in the file system. I
suppose that as long as that directory is accessible
through the network it should be fine. Is this
correct?That''s correct. However, I strongly recommend that the Environment directory be on a local disk. There are problems with using NFS, see:
http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#1
The question of scalability arises. As far as I read
DBD C is the number one embeddable OpenSource
Database out there. So I assume the same would apply
for BDB JE some day (more even once it gets HA). How
scalable is BDB JE? The limitation seems to be the
available space in the machine where the filesystem
is located? Does the filesystem have to the same
where the AS is installed?It sounds like you're asking about data size scalability, not processor scalability. Yes, the limitation is the amount of file storage available, via a single directory, from the process that embeds JE. JE uses the standard java.io package for creating and accessing log files, so any hardware and file system that works under that API will work, as long as file locking is supported as mentioned in the FAQ above. JE creates numbered log files in sequence from 00000000.jdb to FFFFFFFF.jdb, and you can configure the size of the files. The default size is 10 MB.
Ok I 'll look into it. Specialy into what a "Service"
is. Off the top of my head I guess that by service
you are referring to a stateless ejb implementing the
Singleton pattern so you have only one instance
running at all times, that embeds all database
interactions, opens the environment at creation time,
give data-accessors and thus handles all access to
the database. Exactly.
Should I open all indexes in the
Singleton at creation time as well and simply get
data-accessors to to perform read/write operations?Yes, that's what I recommend. See:
http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#12
Ok we willhave to wait then. One of the questions I
received about BDB JE is why a JE when you have the C
version with a Java API? I guess it's related to
being written in Java (portability-wise), it runs in
the same JVM and it's 100% Java codeYes, this is the primary reason. A pure Java library is easier to deploy, test and debug than a C-based library, especially if you target multiple platforms. And the product can be optimized for the Java platform.
and that it
incorporates the DPL much in the way JPA works to
have a closer integration. Am I correct?The DPL is only available for the JE product today, but it may be available for the C product in the future, since it is implemented on top of the base Java API that is common to both products.
Also, while the JE product has similar functionality to the C product, it uses a different internal architecture. JE uses a log structured storage system rather than a traditional page-based storage system; this is better for writing (disk head moves less) but worse for fetching records that are not in cache (disk head moves more). JE also uses record locking rather than page locking; this improves concurrent access but uses more memory for locks.
See "Berkeley DB Java Edition Architecture" here:
http://www.oracle.com/technology/products/berkeley-db/je/index.html
Last but not least. Portability-wise we are using DAO
to persist and in the DAOs we perisist the objects.
My logic is that by decorating POJOs with BDB JE
annotations i can use DAO to persist in DB JE, any
other persistency type including text, dbf, RDBMs
using an ORM (without JPA), or creating a separate
set of classes decorated with JPA annotations (though
I would stick with ANSI SQL if I could). Do you see
this as correct? Would you reccomend using DAO at all
with Berkeley?Yes, a DAO is a good idea when you need to target multiple storage mechanisms. And the DPL does not meet this need, because it can only be used for Berkeley DB JE.
If you need an API that works very well for Berkeley DB (JE and C products), plus relational DBs, then I strongly recommend Carbonado, an open-source framework from Amazon:
http://carbonado.sourceforge.net/
Mark

Similar Messages

  • HSDIO Dynamic Generation of Digital Signals on Separate Non-sequential Ports Using the PCI-6542

    I am using the PCI-6542 trying to generate serial data timing on separate non-sequential ports 8, 9 and 16 as shown in the attached Digital Waveform Editor JPEG file
    I would like to be able to send binary data to ports (lines) 8, 9 and 16 without disturbing the other 29 ports on the PCI-6542 board. Looking on various HSDIO examples I don't see the capability of being able to send dynamic generation in binary format to a group of ports or being able to mask out non-timing involved ports like you can in static generation. 
    Was anyone successful in implementing this type of serial binary timing waveforms using the PCI-6542 board.
    Please advise.
    Thanks

    Hi Nycor,
    Outputting your data on lines that you specify is indeed possible on HSDIO cards.  You just need to list the channels you want to use in your Channel List when call the niHSDIO Assign Dynamic Channels VI.  For example, for lines 8, 9, and 16, you would input 8,9,16 into the Channel List.  Order in this list matters, so the first waveform in your file will correspond to line 8, second waveform to line 9, etc.  If your waveforms are out of order in your file, then rearrange the Channel List accordingly.
    One of my colleagues here is actually working on an example that implements this; I believe it may be for an open service request that you have.  I will speak with her when she is done and see if there is some example code we can provide that demonstrates this.  If you have further questions, I am happy to help out here, but you will likely get faster response through your open service request via phone and email.
    Regards,
    Chris E.
    Applications Engineer
    National Instruments
    http://www.ni.com/support

  • Using Sequence

    Hi Everyone,
    Is there any way that we can assign/attach a sequence to the column of a table, actually the requirement is that I have table, in which a third party will be inserting the data and they want me to attach a sequence to column where that sequence should generate a auto number upon inserting each record.
    As far as I knew that we can use sequence thru a form to insert auto numbers.
    Any help will be appreciated.
    Thanks in advance
    Ahon

    Is there a simple way to return the value generated to the form?
    Forms 6i, 9i database.
    I have a basic form that allows the user to insert a record into a table CALL_HISTORY. That table has a BEFORE INSERT trigger that gets a sequence value and uses it as the primary key, CALL_ID.
    Now on the form post-save I want the call_id display field populated with this new value. I can't query for it as none of the other data is unique. Surely Forms must have some function to do this?

  • How to use Sequence in Forms

    Hi,
    I have an Empno Column, At the time of Opening a Form The Empno Will be displayed by using Sequence.
    If the User doesn't save the Form Then the Empno Generated number will be changed.
    How to write the code to get sequence numbers at Empno columns by using Sequence?
    Thanks & Regards,
    Hari Babu

    Ok, I understand now your question. Since the oracle sequence is commited in a separate transaction, it is not possible to get the no-gap sequence, considering your example. In the other hand, if you don't commit immediately, than two concurrently opened forms could use the same sequence number, so you'll get the duplicate key!
    If you're sure that this couldn't happen, you can manage your own sequencing, storing them in another table. Let's say you reached seq 999: entering the form, you'll read from your sequence table 1000, increment to 1001, and assign it to empno, but without commiting. Next time, you'll get the same number, until you commit form, and at the same time, change in seq table. So another will get 1001.
    Downside of this approach are, as mentioned before, concurrent sessions, which will get the same sequence.

  • Error Using Sequence in Weblogic

    I tried to use Sequence object in weblogic to generate auto-imcremental integers
    for my db insert keys. I first create a mydbsequece in oracle database. Then,
    I built a class in which I obtain a dataSource using jndi to look for my dataSource.
    And then use the ds to getConnection. After I had the connection, I do the following:
    Sequence sequence = new Sequence(con, "mydbsequence");
    int i = sequence.nextValue();
    When I call sequence.nextValue() method, I got the following error message: NullPointerException
    at Weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:65).
    Does anyone know what causes this error? and How do I fix it? Please advise me
    on this. Thank you very much.
    Qin

    Qin Ding wrote:
    >
    I tried to use Sequence object in weblogic to generate auto-imcremental integers
    for my db insert keys. I first create a mydbsequece in oracle database. Then,
    I built a class in which I obtain a dataSource using jndi to look for my dataSource.
    And then use the ds to getConnection. After I had the connection, I do the following:
    Sequence sequence = new Sequence(con, "mydbsequence");
    int i = sequence.nextValue();
    When I call sequence.nextValue() method, I got the following error message: NullPointerException
    at Weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:65).
    Does anyone know what causes this error? and How do I fix it? Please advise me
    on this. Thank you very much.
    QinSequence is a non-standard JDBC object. It is an Oracle-specific class, which presumably
    takes a standard java.sql.Connection in it's constructor. Oracle has repeatedly created
    such new classes with methods claiming to take java.sql.* arguments, but in fact they
    require an Oracle-specific class. In this case, however, we might succeed anyway if
    we dig some. Can you show me the entire stacktrace of the exception?
    Please take the attached jar file, and put it in front of all the weblogic stuff
    in the server's classpath, and repeat the problem and show me the new exception.
    From the line, I am assuming you're on the 6.1 version of WebLogic. If not, forget the
    jar, and let me know.
    Joe
    [61rmicon.jar]

  • USING SEQUENCE IN PACKAGE SPEC

    I Want to Use Sequence.NEXTVAL & Sequence.CURRVAL throughout the package. How can i declare the global sequence variable and make them available for all the stored procedures inside the package ?
    Any help highly appreciated..
    Thank you all in advance

    Data Boy wrote:
    No i know that but using directly SEQUENCE.CURRVAL inside the Insert statement is not a good practice.
    We need to declare inside the procedure a variable and then fetch the SEQUENCE.CURRVAL into that variable
    and use that variable inside the insert statement. But we that variable scope will be available only inside that procedure.
    if i want the same CURRVAL in another stored procedure. How can i get it ..that is my Question.What exactly are you trying to achieve?
    If it's a case of needing to know the value of the sequence number assigned to an inserted record you would typically use the RETURNING clause on the insert statement...
    SQL> create table temp (id number, val varchar2(20));
    Table created.
    SQL> create sequence temp_seq;
    Sequence created.
    SQL> ed
    Wrote file afiedt.buf
      1  create trigger trg_temp before insert on temp
      2  for each row
      3  begin
      4    select temp_seq.nextval into :new.id from dual;
      5* end;
    SQL> /
    Trigger created.
    SQL> set serverout on
    SQL> declare
      2    v_num number;
      3  begin
      4    insert into temp (val) values ('Fred') returning id into v_num;
      5    dbms_output.put_line('ID inserted was: '||to_char(v_num));
      6  end;
      7  /
    ID inserted was: 1
    PL/SQL procedure successfully completed.
    SQL> select * from temp;
            ID VAL
             1 Fred
    SQL>

  • How to use sequence in MS sql server?

    In Oracle DB we use sequence like that:
    SequenceImpl s = new SequenceImpl("customer_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setId(new Number(next.intValue()));
    But there is no sequence in sql server ,how can I do?
    Thank you~~

    MS SQLServer have a IDENTITY column property and UNIQUEIDENTIFIER data type that is somewhat similar to Oracle's sequence. I don't know whether your table contain either of these, or you just want to set sequential number to a column.
    Below is some info about IDENTITY and UNIQUEIDENTIFIER you may already know since they are in SQLServer Book.
    IDENTITY property: You can define IDENTITY property on a numeric column. You can set the seed and increment on this column property very much like Oracle's sequence. The only thing I think it does not have is the "nextval". You can use IDENT_CURRENT function or @@IDENTITY after an INSERT or SELECT INTO to get the last value generated. Of course you can use this value and add the increment to get the next
    value but it not the same as seqname.nextval which keep incrementing each time you call it. Getting the current identity value and adding the increment your self will not work for multiple sessions with pending
    insert. Another thing about column with IDENTITY property is that you cannot insert value into this column (i.e, omit it in your insert statement values) unless IDENTITY_INSERT is on, but only one table in a
    session can have IDENTITY_INSERT to be turned on.
    If you don't need to know the next seq value, then IDENTITY work similar to Oracle sequence. Execute select after postchanges or commit will have system generated values. If you need to get next value before insert, Sung suggest using SEQ_TABLE and managing the next value (write a database function to mimic Oracle'
    s nextval).
    UNIQUEIDENTIFIER datatype: UNIQUEIDENTIFIER is a 16-byte hexadecimal number indicating a globally unique identifier (GUID). The GUID is useful when a row must be unique among many other rows. You could use NEWID() to create a value of type uniqueidentifier or calling some API function that returns a GUID. The advantage of using uniqueidentifier is that the values generated by NEWID function or application GUID are guaranteed to be unique throughout the world. The disadvantage of using uniqueidetifier is that it is long and obscure, random, difficult for user to remember or type correctly. It is 16 byte, which is large compare to other datatype such as 4-byte integer.
    Thanks,
    Yvonne

  • Non-sequential enum causes error

    When calling a .NET object that has a property that sets an enum value, I am getting a runtime error in the .NET code if the enum is defined such that each value is not a sequential number (as in a bit mask). If the values are sequential there is no problem. In both cases, the sequence editor shows a drop down with the names of the enum values but puts the name in quotes.
    Does TestStand handle enums with non-sequential values properly?
    Solved!
    Go to Solution.

    It works for me if I specify the values separated by commas or specify the value numerically. For example:
        [Flags]
        public enum mybitfield
            myval1 = 0x1,
            myval2 = 0x2
    For the above bitfield, to specify both values for a parameter you can either specify:
    "myval1, myval2"
    0x1 | 0x2
    0x3
    Any of the above worked for me in both TestStand 4.2.1 and TestStand 2010.
    Hope this helps,
    -Doug

  • Non sequential values for knobs

    Is it possible to set non-sequential values for the control knobs on the front panel? For example, I'd like to set values of 1, 2, 5, 10, 20, 25, 50, 100, etc...

    Use the log mapping and text labels.  See example.
    Attachments:
    Non_Seq_Knob.ctl ‏5 KB

  • Locking Non Synced Audio To A Sequence

    I have some old audio files ( mostly that came - using old drum machines) - that I want to sync to logic.
    In digital performer 4.6 - I am able to highlight a multi bar drum track - then click " analyze audio" - and it makes an attempt to guess at the beats per minute. Then I can change the sequence to that BPM - then slide the audio drum track ( and all other related audio tracks) - and match up the drum downbeats to the beginning of a bar - and thereby lock non-synced audio to a sequence very easily.
    Question: how do I do this in logic 7.11?

    Beat mapping is probaly what you want
    if you have an exact loop use adjust tempo using region length/locators

  • Generating non-sequential primary keys

    Is there a simple way to generate non-sequential primary keys? Say for instance I want to generate a user ID. I'd like all of the IDs to be unique, but not strictly sequential.

    >
    Hi Crottyan,
    Is there a simple way to generate non-sequential primary keys? Say
    for instance I want to generate a user ID. I'd like all of the IDs to be
    unique, but not strictly sequential.Normally this is done to eliminate contentation for index inserts - why do
    you want to do it?
    Be careful with GUID - it can be [url http://en.wikipedia.org/wiki/Globally_unique_identifier#Sequential_algorithms]sequential.
    It's a pity you didn't tell us your version of Oracle :( - you should always do this.
    10 XE has a sequential algorithm. 11 XE doesn't.
    HTH,
    [Edit] Just saw your post about inferring insert order - fair enough. Will be able to tell you about 11 EE next
    week ;)
    Paul...
    Edited by: Paulie on 18-Jul-2012 18:03

  • Enter only one non-statistical account assignment (J1IIN)

    Hi Friends,
    We are facing one problem relating to controlling. 
    Here we are assigning internal order in sales order for scrap sales and we are doing order related billing.
    we are maintaining different GL accounts for billing and Exicse accounts for Excise and this accounts are cost elements.
    when we are doing the billing system is not creating any error message and we are activated COPA also. So in billing COPA document is generating.
    we are tried to post the excise invoice for this billing document using the standard transaction code J1IIN. 
    But system is giving the error message "Enter only one non-statistical account assignment"
    Please suggest.
    Regards
    Ram

    The system does not recognize whether it should be assigned to the sales  order or to the internal order probably. There is every possibility of program error, please refer to oss notes like 170014.

  • Non-sequential scanning with SCXI and Labwindows/CVI

    I'm trying to scan channels 0 and 2 (skipping channel 1) of a SCXI-1520 module with a SCXI-1000 chassis using LabWindows/CVI, but am getting error 10370 (Invalid Scan list).
    I've read here that the SCXI-1520 module supports non-sequential scanning, even with traditional NI-DAQ drivers, but I can't get this working.
    I'm using NI-DAQ 6.9.3 and LabWindows/CVI 6.0.
    I'm not using a channel string, but intead am using SCXI_Track_Hold_Setup and SCXI_SCAN_Setup.
    For the scan setup my arrays are:
    Module_List={1,1}
    #_of_Channels_List={1,1}
    Start_Channel_List={0,2}
    I've tried setting the Hol
    d_Count for the module to both 1 and 2 in SCXI_Track_Hold_Setup, but that doesn't help.
    Is this possible, and if so, how?

    OK, in essence, my code is:
    SCXI_Reset(chassis,-1);
    SCXI_Load_Config(chassis);
    hold_count=2; // Note: Tried 1 but that doesn't work either.
    SCXI_Track_Hold_Setup(chassis,slot,2,2,0,hold_count,device);
    // Note: tried 2,0,2 but doesn't work either, and then can't scan multiple modules.
    SCXI_Set_Gain(chassis,slot,-1,1);
    SCXI_Set_Excitation(chassis,slot,-1,VDC,5.0,&actual);
    SCXI_Configure_Filter(chassis,slot,0,BYPASS,0);
    SCXI_Configure_Filter(chassis,slot,2,BYPASS,0);
    SCXI_Configure_Connection(chassis,slot,-1,QUARTER);
    num_modules=2;
    Module_List={1,1};
    Channels_List={1,1};
    Start_List={0,2}
    SCXI_Scan_Setup(chassis,num_modules,Module_List,Channels_List,Start_List,device,0);
    // This causes error -10370:badScanListError
    Any help greatly appre
    ciated!

  • Comenting code - style - how to keep coments where you want them - without using sequences

    Silly question maybe about style of commenting.
    Basically i like to use sequence boxes to keep comments on my diagram beside the bits of code that they refere to - otherwise when you use diagram cleanup (which i'm afraid i use all the time) they go anywhere.  This is good - except that i found especially when doing FPGA programming the sequence boxes reduce the amount of parralelism that can go on - since the 'box' needs to finish before any of the outputs can be used.  Is there some other method i should be using instead of sequence boxes to keep text beside elements - without enforcing that a set of elements are fixed in one place?
    Solved!
    Go to Solution.

    I usually use labels of structures (loops, cases, etc) and labels of diagram constants, etc. for comments. In newer versions, we also have wire labels.
    (see also)
    What is your LabVIEW version? Also the LabVIEW 2011 cleanup does a better job keeping diagram comments together with the related code compared to earlier version.
    LabVIEW Champion . Do more with less code and in less time .

  • Non-static variable being used in static context

    I am currently attempting to write a basic user login system using basic applets. I have two JTextFields named "userText" and "passText".
    What i am attempting to do is use the ".getText()" method to get the text out of the JTextField and verifying the string against a string already in a file using the bufferedReader, etc.
    However when i try to compare the string in the file with the one in the text field using the following code:
    if ((line.compareTo(username)) == 0)
    i get the following error...
    "non-static variable being used in a static context"
    Any ideas?

    The static method doesn't know about instances of the class instead you pass the instance to the method:
    static public void myMethod(MyClass instance, String var) {
      if(instance.line.compareTo(var))
    And then the call would be:
    MyClass.myMethod(anInstance, userName);

Maybe you are looking for

  • How to get iphones / ipad user agent for internet access

    Hi. We recently setup some wireless, and I'm wondering how I can get iphones and ipads connected to the internet without prompting for a username and password. Even if it does prompt and we put in our domain credentials, things don't work.. it's like

  • Aperture 1.1 & RAW

    Currently I'm not using Aperture 1.1, or 1.0 or at all. I don't want to spend an extra £350GBP to receive £130 Apple Credits/Vouchers to purchase V1.0 to upgrade through the web to 1.1 or now 1.1.1. As I don't need to bank with Apple. This means that

  • Matrix addrow problem

    I want to enter some value in a matrix I enbled matrix with oMatrix.AddRow() but problem is that - when I am inputing data in matrix fields , after pressing tab the value disappears how can I resolve the problem?

  • Monitoring critical transaction in SL report

    Hi, I am not able to  add business critical transaction in SL report configuration. It shows TOP LOADED transaction which is not requirement. I like to add new transaction as per customer requirement, We have recently upgraded solution manger to SAP

  • RFx Q&A dump SRM 7- Dynamic type conflict when assigning references Q&A

    Hello, We are on SRM 7.0 SP05. When adding a question via the Q&A 'chat' functionality on a published RFx the EP shows the following error: 'Dynamic type conflict when assigning references Q&A'. Could somebody test if this issue is also occuring on t