DHIS2 uses the hibernate_sequence to generate the id and even if you create another sequence that will not be used.
This is the general way in which the Postgres Dialect operates.
If we’ve imported data outside of hibernate, there will be mismatch with the sequence generator and this is the current problem you are facing.
One approach for us could be to change the dialect to be able to deal with this problem, such that every auto-increment column has its own sequence.
That sequence can be used if data is imported into the database.
Here is some discussion around that - http://grails.1312388.n4.nabble.com/One-hibernate-sequence-is-used-for-all-Postgres-tables-td1351722.html
···
Regards,
Saptarshi PURKAYASTHA
My Tech Blog: http://sunnytalkstech.blogspot.com
You Live by CHOICE, Not by CHANCE
On 15 May 2013 12:27, Uddin Fatema fatemacse@gmail.com wrote:
Dear All,
I converted MySql Database In Postgres with Data. Conversion is good.
However, I face few bugs about insert new dataelement or datset. It is shows duplicate id.
For solving this bug, I created dataelementid_seq sequence for auto incremented dataelement id and set as a default value of dataelemtid column in dataelement table.
Unfortunately, Now If i am create a new dataelemt then it is not taking the default value which one i set in dataelementid colum. It is taking the curvalue of hibernate_sequence. Not from my new dataelementid_seq.
The sequence step are follows:
CREATE SEQUENCE dataelementid_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
ALTER TABLE dataelementid_seqOWNER TO postgres;
SELECT MAX(dataelementid) FROM dataelement
SELECT nextval(‘dataelementid_seq’);
SELECT setval(‘dataelementid_seq’, (SELECT MAX(dataelementid) FROM dataelement));
Set default value: nextval(‘dataelementid_seq’::regclass)
Have any one any solution about default value.
Fatema Uddin ----------------------------------------Junior Advisor HIS
Priority Area Health
Deutsche Gesellschaft für Internationale Zusammenarbeit (GIZ) GmbH
House10/A, Road 90, Gulshan 2, Dhaka 1212, Bangladesh
Office location:
Monitoring & Evaluation Unit
Ministry of Health and Family Welfare
Janashankha Bhaban (2nd Floor), Azimpur
Dhaka 1205, Bangladesh
Phone: +880 2 966 53 13
Fax: +880 2 966 53 14
Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help : https://help.launchpad.net/ListHelp