[Objectbridge-developers] transaction not committing?
Brought to you by:
thma
From: David E. <esp...@ne...> - 2001-09-05 22:24:35
|
Howdy all, I have an interesting problem ... I have used some of the sample code in tutorial1 to make my own sample application. Using PersistenceBroker, I'm trying to create records in a table that has only 2 fields (the PK and a text field) ... It seems like it's working because i'm getting new uniqueIDs from the broker.getUniqueId() call, but when I look in the DB, nothing has been created in my table, nor have any records been created in the obj_seq table ... here's a trimmed down version of what I'm doing ... I'm using Postgres 7.1.2 (and the corresponding JDBC driver) and i'm using the latest OJB (0.5.155) .. SQL Schema create table color( color_id int not null primary key, name varchar(100) not null ); in REPOSITORY.XML <ClassDescriptor id="7"> <class.name>schema.Color</class.name> <table.name>color</table.name> <FieldDescriptor id="1"> <field.name>colorID</field.name> <column.name>color_id</column.name> <jdbc_type>INTEGER</jdbc_type> <PrimaryKey>true</PrimaryKey> </FieldDescriptor> <FieldDescriptor id="2"> <field.name>name</field.name> <column.name>name</column.name> <jdbc_type>VARCHAR</jdbc_type> </FieldDescriptor> </ClassDescriptor> JAVA application: public myMethod() { public static final String[] colorList = {"Red","Yellow","Green","Purple","Black"}; broker = PersistenceBrokerFactory.createPersistenceBroker("repository.xml"); broker.beginTransaction(); for(int i=0; i<colorList.length; i++) { Color color = new Color(); color.setName(colorList[i]); color.setColorID(new Integer(broker.getUniqueId(Color.class,"colorID"))); broker.store(color); log("Created new Color with ID: " + color.getColorID()); } broker.commitTransaction(); } the OUTPUT from myMethod: Created new Color with ID: 1 Created new Color with ID: 2 Created new Color with ID: 3 Created new Color with ID: 4 Created new Color with ID: 5 Has anyone heard of such a thing? It's as if the transaction isn't committed to the DB ... If i start another instance of this application while one is running, it hangs until the first one is killed, so that usually means that there is an uncommitted transaction hanging around ... -Dave |