AW: [Objectbridge-developers] transaction not committing?
Brought to you by:
thma
From: Mahler T. <tho...@it...> - 2001-09-06 07:49:18
|
Hi David, > -----Urspr=FCngliche Nachricht----- > Von: David Esposito [mailto:esp...@ne...] > Gesendet: Donnerstag, 6. September 2001 00:24 > An: obj...@li... > Betreff: [Objectbridge-developers] transaction not committing? >=20 >=20 > Howdy all, >=20 > I have an interesting problem ... I have used some of the=20 > sample code in > tutorial1 to make my own sample application. Using=20 > PersistenceBroker, I'm > trying to create records in a table that has only 2 fields=20 > (the PK and a > text field) ... It seems like it's working because i'm=20 > getting new uniqueIDs > from the broker.getUniqueId() call, but when I look in the=20 > DB, nothing has > been created in my table, nor have any records been created=20 > in the obj_seq > table ... here's a trimmed down version of what I'm doing ... >=20 > I'm using Postgres 7.1.2 (and the corresponding JDBC driver)=20 > and i'm using > the latest OJB (0.5.155) .. >=20 > SQL Schema >=20 > create table color( > color_id int not null primary key, > name varchar(100) not null > ); >=20 > in REPOSITORY.XML >=20 > <ClassDescriptor id=3D"7"> > <class.name>schema.Color</class.name> > <table.name>color</table.name> > <FieldDescriptor id=3D"1"> > <field.name>colorID</field.name> > <column.name>color_id</column.name> > <jdbc_type>INTEGER</jdbc_type> > <PrimaryKey>true</PrimaryKey> > </FieldDescriptor> > <FieldDescriptor id=3D"2"> > <field.name>name</field.name> > <column.name>name</column.name> > <jdbc_type>VARCHAR</jdbc_type> > </FieldDescriptor> > </ClassDescriptor> >=20 > JAVA application: >=20 > public myMethod() > { >=20 > public static final String[] colorList =3D > {"Red","Yellow","Green","Purple","Black"}; >=20 > broker =3D=20 > PersistenceBrokerFactory.createPersistenceBroker("repository.xml"); >=20 > broker.beginTransaction(); >=20 > for(int i=3D0; i<colorList.length; i++) > { > Color color =3D new Color(); > color.setName(colorList[i]); > color.setColorID(new=20 > Integer(broker.getUniqueId(Color.class,"colorID"))); >=20 > broker.store(color); >=20 > log("Created new Color with ID: " + color.getColorID()); > } >=20 > broker.commitTransaction(); >=20 > } >=20 > the OUTPUT from myMethod: >=20 > 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 >=20 >=20 > Has anyone heard of such a thing? It's as if the transaction=20 > isn't committed > to the DB ... If i start another instance of this application=20 > while one is > running, it hangs until the first one is killed, so that=20 > usually means that > there is an uncommitted transaction hanging around ... >=20 This is really kinda strange! Your code looks good and SHOULD work! The only thing I can imagine is a problem with the JDBC driver. You could try to ommit the broker.beginTransaction() and broker.commitTransaction() calls, to check whether it works with JDBC AUtoCommit enabled. A different approach to check if the problems are due to OJB-PostGres incompatibility is to run your example against the shipped instantDB. If it runs with instantDB we will have to have a deeper look at the Postgres JDBC-driver... =20 Have you tried to run the unmodified Tutorial1 against PostGres? HTH, Thomas > -Dave >=20 >=20 >=20 > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers >=20 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ********************************************************************** |