Keith Ching wrote: > Hi, > > I am trying to write a plugin to automatically make objects from sample > -> rawbioassay. > however, after you call dc.commit() it closes the connection. what is > the normal way to > re-establish a connection? dc.reconnect() does not seem to work. > getting a new dc via > dc = sc.newDbControl(); does not seem to work either.
A DbControl can only be used once. If you call commit() or close() that connection can't be used anymore. SessionControl.newDbControl() should give you a new connection. You don't say why it doesn't work, so it is hard for me to give more help. The stack trace you sent in the second mail gives an error in AutoBuild.addLabeledExtract but you don't show that code. The org.hibernate.TransientObjectException is usually an indication that objects are saved in the wrong order. Ie. before creating the labeled extract you must save the extract is is referencing. With this I don't mean that you have to commit() the extract to the database just that you should call DbControl.saveItem(). DbControl.reconnect() is used together with the DbControl.disconnect() method. It should be used if you have an operation that takes a long time and you don't want to hold a database connection during that time. The only place we use these methods are in the file upload, calling disconnect() before the upload starts, then reconnect() at the the end to finish the upload and commit(). We have some test code that creates everything from biosource to rawbioassays with just two DbControl:s. Check http://base.thep.lu.se/browser/trunk/src/test/net/sf/basedb/test/roles/UserTest.java /Nicklas > > i need to commit the created objects between steps because subsequent > objects do database > lookups of previous objects to create themselves. > > here is my general outline. > > ArraySlide slide; > for (Sample sourceObj : sources) > { > dc.reattachItem(sourceObj); > /** > * 1. get the slide > */ > slideName = sourceObj.getName().split(" ")[0]; > slide = getSlideByName(dc, slideName); > > /** > * 2. make chromatin input sample from pooled sample > */ > Sample chromatinSample = getChromatinSample(dc, sourceObj); > Extract chromatinExtract = addExtract(dc, chromatinSample); > /** > * 3. make the extract from the pooled sample > */ > Extract pooledExtract = addExtract(dc, sourceObj); > dc.commit(); > > dc = sc.newDbControl(); > /** > * 4. make the labelled extracts from extracts > */ > LabeledExtract chromatinLabeledExtract = > addLabeledExtract(dc, inputLabel, chromatinExtract); > LabeledExtract pooledLabeledExtract = > addLabeledExtract(dc, poolLabel, pooledExtract); > dc.commit(); > dc = sc.newDbControl(); > /** > * 5. make the hybridization from the matched pairs, add > the slide > */ > Hybridization hyb = addHybridization(dc, > chromatinLabeledExtract, pooledLabeledExtract, slide); > dc.commit(); > dc = sc.newDbControl(); > /** > * 6. make the scan > */ > Scan scan = addScan(dc, hyb); > dc.commit(); > dc = sc.newDbControl(); > /** > * 7. make the rawbioassay > */ > String datatype = "GenePix"; > RawBioAssay myRawBioAssay = addRawBioAssay(dc, scan, > RawDataTypes.getRawDataType(datatype) ); > dc.commit(); > dc = sc.newDbControl(); > // group into experiment ? > > fileNames = fileNames + " " + > myRawBioAssay.getName(); > } > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ The BASE general discussion mailing list basedb-users@lists.sourceforge.net unsubscribe: send a mail with subject "unsubscribe" to [EMAIL PROTECTED]