From: Hilmar L. <hl...@ne...> - 2009-12-23 17:21:02
|
Youjun - this smells like a hibernate misconfiguration. You can tell hibernate that the database will assign the primary key, rather than hibernate assigning it itself. More importantly, it needs to be consistent with the database. If the database has sequence definitions and auto-increment (SERIAL or DEFAULT('nextval XXXX' in PostgreSQL) for the primary key, then hibernate has got to be using them as well (i.e., database and not hibernate assigns primary keys). If hibernate assigns primary keys, then the database tables must not have auto-increment rules on its primary key columns. Right now it looks like the database has auto-increment rules *and* hibernate tries to do its own thing? -hilmar On Dec 23, 2009, at 11:37 AM, youjun guo wrote: > Hilmar & Vladimir, > > When hibernate insert a record into the database, it need to create > a unique id (primer_key) for it. > > In treebase hibernate use sequence. yes It is a database object in > treebase-dev. hibernate will ask for a key from this sequence object. > > By default hibernate will looking for a sequence object named > "hibernate_sequence" unless some other sequence are explicitly > appointed in hibernate configuration (NOT DATABASE SETUP). > > In the treebase code, I didn't find any other sequence defined in > the hibernate configuration. I assume it will use default that is > "hibernate_sequence". > > Most importantly the testing code do complain primer key conflict in > these two tables, And the key hibernate got from the sequence do > exist in the tables already. > > Only the owner of the treebase-dev can make change of the sequence. > > Youjun > > > > On Wed, Dec 23, 2009 at 10:29 AM, Vladimir Gapeyev <vla...@du... > > wrote: > In the schema, both taxonlabel and phylotreenode use their own > sequences (taxonlabel_id_sequence and phylotreenode_id_sequence) whose > current values are in sync with the tables. What is the purpose of > the hibernate_sequence sequence? --VG > > > On Dec 23, 2009, at 7:42 AM, youjun guo wrote: > > > Hilmar and Bill, > > > > In our database, the current hibernate_sequence value (1416) is much > > smaller than max id value of table taxonlabel and phylotreenode, > > that make primer key conflict when hibernate try to insert new data > > into this two table. > > > > It need to be change to a bigger number so that the current value > > big than max phylotreenode_id. > > > > I tried but the server said only the owner can alter it. > > > > Enjoy your holiday to all! > > > > Youjun > > > ------------------------------------------------------------------------------ > > This SF.Net email is sponsored by the Verizon Developer Community > > Take advantage of Verizon's best-in-class app development support > > A streamlined, 14 day to market process makes app distribution fast > > and easy > > Join now and get one step closer to millions of Verizon customers > > http://p.sf.net/sfu/verizon-dev2dev > > _______________________________________________ > > Treebase-devel mailing list > > Tre...@li... > > https://lists.sourceforge.net/lists/listinfo/treebase-devel > > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast > and easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > Treebase-devel mailing list > Tre...@li... > https://lists.sourceforge.net/lists/listinfo/treebase-devel > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast > and easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > Treebase-devel mailing list > Tre...@li... > https://lists.sourceforge.net/lists/listinfo/treebase-devel -- =========================================================== : Hilmar Lapp -:- Durham, NC -:- informatics.nescent.org : =========================================================== |