objectbridge-developers Mailing List for ObJectRelationalBridge (Page 42)
Brought to you by:
thma
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(14) |
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(33) |
Feb
(8) |
Mar
(3) |
Apr
(1) |
May
(18) |
Jun
(6) |
Jul
(15) |
Aug
(71) |
Sep
(29) |
Oct
(43) |
Nov
(77) |
Dec
(54) |
2002 |
Jan
(54) |
Feb
(147) |
Mar
(144) |
Apr
(163) |
May
(307) |
Jun
(240) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <ba...@ge...> - 2002-01-15 14:55:46
|
Hi Thomas, Rather than using build.sh, I use the ant script. Looking at the source code, source code in the ojb/ package refers to SAX classes, which are found in parser.jar, and code in ojb, org.odmg and javax.jdo refer to javax.transaction, which is found in jta-spec1_0_1.jar. The build.xml compiles the source variable, which is just the src/ directory, so it seems to me that all those files will be compiled, and those jars needed in the classpath. Apologies if the problem is either my using 'ant' or my being stupid. Thanks for the reply, Bay On Tue, 15 Jan 2002, Mahler Thomas wrote: > Hi Bay, > > thanks for your notes, > > > -----Urspr=FCngliche Nachricht----- > > Von: ba...@ge... [mailto:ba...@ge...] > > Gesendet: Montag, 14. Januar 2002 18:08 > > An: obj...@li... > > Betreff: [OJB-developers] build.xml missing jars > > > > > > Just a quick note, am sure you've come across it already. > > > > When running build.xml through ant, the following two jars are missing > > from the $classpath variable, and thus 'main' doesn't execute fully. > > > > ${lib}/parser.jar:${lib}/jta-spec1_0_1.jar > > I have been running the build process under Linux and Windows without any > problems. > running build.sh junit (or build.bat junit) works fine on all my machines= =2E > AFAIK the libs parser.jar and jta-spec1_0_1.jar are not reference during > compilation. > They are only needed at runtime, that's why they are contained in the > runtime_classpath. > > > > > I also get the following when the OQL is trying to be parsed > > in the 'oql' > > task. > > > > [build oql parser] oql-ojb.g:476: warning: nondeterminism upon > > [build oql parser] oql-ojb.g:476: k=3D=3D1:Identifier > > [build oql parser] oql-ojb.g:476: k=3D=3D2:"not" > > [build oql parser] oql-ojb.g:476: between alts 3 and 5 of block > > > > That's normal! (Don't ask me what it's saying...) > > cu, > > Thomas > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > |
From: Mahler T. <tho...@it...> - 2002-01-15 09:40:42
|
Hi Bay, thanks for your notes, > -----Urspr=FCngliche Nachricht----- > Von: ba...@ge... [mailto:ba...@ge...] > Gesendet: Montag, 14. Januar 2002 18:08 > An: obj...@li... > Betreff: [OJB-developers] build.xml missing jars >=20 >=20 > Just a quick note, am sure you've come across it already. >=20 > When running build.xml through ant, the following two jars are = missing > from the $classpath variable, and thus 'main' doesn't execute fully. >=20 > ${lib}/parser.jar:${lib}/jta-spec1_0_1.jar I have been running the build process under Linux and Windows without = any problems. running build.sh junit (or build.bat junit) works fine on all my = machines. AFAIK the libs parser.jar and jta-spec1_0_1.jar are not reference = during compilation. They are only needed at runtime, that's why they are contained in the runtime_classpath. >=20 > I also get the following when the OQL is trying to be parsed=20 > in the 'oql' > task. >=20 > [build oql parser] oql-ojb.g:476: warning: nondeterminism upon > [build oql parser] oql-ojb.g:476: k=3D=3D1:Identifier > [build oql parser] oql-ojb.g:476: k=3D=3D2:"not" > [build oql parser] oql-ojb.g:476: between alts 3 and 5 of block >=20 That's normal! (Don't ask me what it's saying...) cu, Thomas=20 |
From: Mahler T. <tho...@it...> - 2002-01-15 09:29:38
|
Hi Michael, There will be a lot of people using OJB who do not use named roots. Just imagine their faces when the GC starts and deletes all their objects because they where unreferenced >:-() !!! Thus Having the GC as a separate tool is a good idea, not to say a MUST! Implementing a GC that will reclaim everything that can not be reached from a named root will not be difficult. The algorithm you describe is a simple "mark and sweep" algorithm. Would be fun to implement such a thing! cheers, Thomas > > Hi Thomas! > > I've been thinking about the GC process over the last few days. > > > Currently there is no GC implemented. > > IMHO it will be VERY difficult to have a real GC as it > would be possible > > with an OODBMS. > > It will be very difficult to decide if objects can safely > be deleted. > > > > BUT: we have been thinking of changing the semantics of > DList.remove() > > an similar methods as name roots unbind so that removed objects are > > deleted from the DB. > > A first step towards true persistence by reachability could > be to offer > offline GC. This way you don't have the to deal with objects which not > reachable from any named root object any more but are still > referenced under > another transaction that has not yet committed. The algorithm > could look > like this: > > 1. Make a list of all objects stored in the database > 2. from every named root object traverse the object graph and mark any > object you come across as being persistent > 3. delete all the objects from the database which are > currently not marked > as persistent. > > The algorithm can be implemented using recursion. In order to avoid > indefinite loops caused by cyclic references, the algorithm > has to check > whether an object under investigation is already marked. > > Another advantage is that people who do not want seamless > persistence the > "Java Way" but instead want to have a more basic level > control over their > data still have the option not to execute the garbage collector. > > What do you think about it? > > Greetings Michael > ----- Original Message ----- > From: "Thomas Mahler" <tho...@ho...> > To: "Michael Nowotny" <mic...@gm...>; "ojb" > <obj...@li...> > Sent: Wednesday, January 09, 2002 6:51 PM > Subject: Re: Named Root Objects > > > > Hi again, > > > > > > Michael Nowotny wrote: > > > > > Hi Thomas! > > > > > > Thanks for the illustration. Binding collections works > fine for me now! > > > The reason why my earlier attempt failed was that I was > still using > > > InstantDB.It seems that some transactions got only > halfway commited due > to > > > program termination following db.close(). Now I'm using > Hypersonic and > > > everything works. > > > > > > > Fine ! > > > > > > > During the course of setting up a test procedure I came > across some > strange > > > behaviour. The following code snipped throws an > ObjectNameNotBoundException. > > > > > > // fails: > > > tx = odmg.newTransaction(); > > > tx.begin(); > > > db.bind(odmg.newDList(), "MyList"); > > > db.unbind("MyList"); > > > db.bind(odmg.newDList(), "MyList"); > > > // DList list = (DList)db.lookup("MyList"); > > > tx.commit(); > > > > > > tx = odmg.newTransaction(); > > > tx.begin(); > > > DList newList = (DList)db.lookup("MyList"); > > > tx.commit(); > > > > > > Binding the same name twice within the same transaction > seems to cause > an > > > error. > > > > > > Oops, This is a bug. I'll add it to my todo list! > > > > > > This is not very important though because usually one wouldn't want > > > to bind an object to a some name and thereafter unbinding > that name > withing > > > the same transaction. > > > > > > Another question arose when I had a look at the contents > of my database. > If > > > I add content to my list which is a named root object > this content gets > > > persistent as well. That's part of persistence by > reachability. But when > I > > > unbind the root object and the content is therefore no > longer reachable, > it > > > doesn't get removed from the database but is still > present. Is there any > way > > > of performing some kind of garbage collection? > > > > > > > > > > > Currently there is no GC implemented. > > IMHO it will be VERY difficult to have a real GC as it > would be possible > > with an OODBMS. > > It will be very difficult to decide if objects can safely > be deleted. > > > > BUT: we have been thinking of changing the semantics of > DList.remove() > > an similar methods as name roots unbind so that removed objects are > > deleted from the DB. > > > > Any ideas? > > > > -- Thomas > > > > > > > > > > > Keep up the good work! > > > > > > Thanks, Michael > > > > > > ----- Original Message ----- > > > From: "Thomas Mahler" <tho...@ho...> > > > To: "Michael Nowotny" <mic...@gm...>; "ojb" > > > <obj...@li...> > > > Sent: Tuesday, January 08, 2002 8:20 PM > > > Subject: Re: Named Root Objects > > > > > > > > > > > >>Hi Michael, > > >> > > >>please see the attached Java class. > > >> > > >>You can replace the original version of > test.ojb.odmg.OdmgExamples with > > >>this new version to have it executed with the OJB JUnit tests. > > >> > > >>There is a new testMethod testNrmAndDlists that tests > your scenario. > > >>Works great! > > >> > > >>HTH, > > >> > > >>Thomas > > >> > > >>Michael Nowotny wrote: > > >> > > >> > > >>>Hi Thomas! > > >>> > > >>>Just found your OJB project on sourceforge. I think it's > great to have > > >>> > > > an > > > > > >>>open source ODMG implementation around. > > >>>Now I've got a question concerning the ODMG implemetation. > > >>>Is it possible to use a DList for example as a named root object. > > >>> > > > Binding > > > > > >>>that object to a name works but looking it up again causes an > > >>>IllegalArgumentException. > > >>> > > >>>Have you ever tried to bind a Collection. If so, I would > be grateful if > > >>> > > > you > > > > > >>>could drop me some lines of source code. > > >>> > > >>>Thanks Michael > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >> > > >> > > > > > > > > > > > -------------------------------------------------------------- > ------------ > -- > > > ---- > > > > > > > > > > > >>package test.ojb.odmg; > > >> > > >> > > >>import junit.framework.TestCase; > > >>import ojb.broker.Identity; > > >>import ojb.broker.PersistenceBroker; > > >>import ojb.broker.PersistenceBrokerFactory; > > >>import ojb.broker.cache.ObjectCacheFactory; > > >>import ojb.odmg.OJB; > > >>import ojb.odmg.states.ModificationState; > > >>import ojb.odmg.states.StateNewClean; > > >>import ojb.odmg.states.StateNewDirty; > > >>import org.odmg.*; > > >> > > >>import java.util.List; > > >> > > >>/** Demo Application that shows basic concepts for > Applications using > the > > >> > > > OJB ODMG > > > > > >> * implementation as an transactional object server. > > >> */ > > >>public class OdmgExamples extends TestCase > > >>{ > > >> public static void main(String[] args) > > >> { > > >> String[] arr = {CLASS.getName()}; > > >> junit.textui.TestRunner.main(arr); > > >> } > > >> > > >> private static Class CLASS = OdmgExamples.class; > > >> private String databaseName; > > >> > > >> /** > > >> * Insert the method's description here. > > >> * Creation date: (24.12.2000 00:33:40) > > >> */ > > >> public OdmgExamples(String name) > > >> { > > >> super(name); > > >> } > > >> > > >> /** > > >> * Insert the method's description here. > > >> * Creation date: (06.12.2000 21:58:53) > > >> */ > > >> public void setUp() > > >> { > > >> databaseName = > > >> > > > > PersistenceBrokerFactory.getConfiguration().getRepositoryFilename(); > > > > > >> > > >> } > > >> > > >> /** > > >> * Insert the method's description here. > > >> * Creation date: (06.12.2000 21:59:14) > > >> */ > > >> public void tearDown() > > >> { > > >> databaseName = null; > > >> } > > >> > > >> /**TestThreadsNLocks state transition of modification states*/ > > >> public void testModificationStates() > > >> { > > >> // get facade instance > > >> Implementation odmg = OJB.getInstance(); > > >> Database db = odmg.newDatabase(); > > >> //open database > > >> try > > >> { > > >> db.open(databaseName, Database.OPEN_READ_WRITE); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> ModificationState oldState = StateNewClean.getInstance(); > > >> ModificationState newState = oldState.markDirty(); > > >> assertEquals(StateNewDirty.getInstance(), newState); > > >> > > >> oldState = newState; > > >> newState = oldState.markDirty(); > > >> assertEquals(oldState, newState); > > >> > > >> > > >> // close database > > >> try > > >> { > > >> db.close(); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> > > >> } > > >> > > >> public void testOdmgSession() > > >> { > > >> // get facade instance > > >> Implementation odmg = OJB.getInstance(); > > >> Database db = odmg.newDatabase(); > > >> //open database > > >> try > > >> { > > >> db.open(databaseName, Database.OPEN_READ_WRITE); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> Transaction tx = odmg.newTransaction(); > > >> > > >> //perform transaction > > >> try > > >> { > > >> tx.begin(); > > >> > > >> Article example = new Article(); > > >> example.setArticleId(777); > > >> db.makePersistent(example); > > >> > > >> > > >> > > >> // modify Object > > >> example.setStock(333); > > >> example.addToStock(47); > > >> example.addToStock(7); > > >> example.addToStock(4); > > >> > > >> > > >> //System.out.println("now commit all changes..."); > > >> tx.commit(); > > >> } > > >> catch (Exception ex) > > >> { > > >> tx.abort(); > > >> } > > >> > > >> // close database > > >> try > > >> { > > >> db.close(); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> } > > >> > > >> public void testOQLQuery() > > >> { > > >> // get facade instance > > >> Implementation odmg = OJB.getInstance(); > > >> Database db = odmg.newDatabase(); > > >> //open database > > >> try > > >> { > > >> db.open(databaseName, Database.OPEN_READ_WRITE); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> Transaction tx = odmg.newTransaction(); > > >> > > >> //perform transaction > > >> try > > >> { > > >> tx.begin(); > > >> > > >> > > >> OQLQuery query = odmg.newOQLQuery(); > > >> query.create("select anArticle from " + > > >> > > > Article.class.getName() + " where articleId = 7"); > > > > > >> List results = (List) query.execute(); > > >> > > >> Article a = (Article) results.get(0); > > >> > > >> > > >> // cross check with PersistenceBroker lookup > > >> // 1. get OID > > >> Article example = new Article(); > > >> example.setArticleId(7); > > >> Identity oid = new Identity(example); > > >> // 2. lookup object by OID > > >> PersistenceBroker broker = > OJB.getInstance().getBroker(); > > >> broker.clearCache(); > > >> Article b = (Article) broker.getObjectByIdentity(oid); > > >> > > >> assertEquals("should be same object", a, b); > > >> > > >> //System.out.println("now commit all changes..."); > > >> tx.commit(); > > >> } > > >> catch (Exception ex) > > >> { > > >> tx.abort(); > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> > > >> // close database > > >> try > > >> { > > >> db.close(); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> } > > >> > > >> public void testNrmAndDlists() > > >> { > > >> // get facade instance > > >> Implementation odmg = OJB.getInstance(); > > >> Database db = odmg.newDatabase(); > > >> //open database > > >> try > > >> { > > >> db.open(databaseName, Database.OPEN_READ_WRITE); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> Transaction tx = odmg.newTransaction(); > > >> > > >> //perform transaction > > >> try > > >> { > > >> tx.begin(); > > >> > > >> > > >> OQLQuery query = odmg.newOQLQuery(); > > >> query.create("select x from " + > Article.class.getName() + " > > >> > > > where productGroupId = 7"); > > > > > >> DList results = (DList) query.execute(); > > >> > > >> > > >> int originalSize = results.size(); > > >> > > >> OJB.getLogger().info(results); > > >> > > >> String name = "gimme fruits !"; > > >> > > >> db.bind(results, name); > > >> tx.commit(); > > >> > > >> // clear the cache to make sure things are > loaded from RDBMS > ! > > >> OJB.getInstance().getBroker().clearCache(); > > >> > > >> tx = odmg.newTransaction(); > > >> tx.begin(); > > >> > > >> // look it up again > > >> DList newResults = (DList) db.lookup(name); > > >> > > >> assertEquals(originalSize,newResults.size()); > > >> OJB.getLogger().info(results); > > >> > > >> tx.commit(); > > >> > > >> > > >> } > > >> catch (Throwable t) > > >> { > > >> tx.abort(); > > >> fail("ODMGException: " + t.getMessage()); > > >> } > > >> > > >> // close database > > >> try > > >> { > > >> db.close(); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> } > > >> > > >> > > >> > > >> public void testOQLQueryBind() > > >> { > > >> // get facade instance > > >> Implementation odmg = OJB.getInstance(); > > >> Database db = odmg.newDatabase(); > > >> //open database > > >> try > > >> { > > >> db.open(databaseName, Database.OPEN_READ_WRITE); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> Transaction tx = odmg.newTransaction(); > > >> > > >> //perform transaction > > >> try > > >> { > > >> tx.begin(); > > >> > > >> > > >> OQLQuery query = odmg.newOQLQuery(); > > >> query.create("select anArticle from " + > > >> > > > Article.class.getName() + " where articleId = $678"); > > > > > >> query.bind(new Integer(7)); > > >> > > >> List results = (List) query.execute(); > > >> > > >> Article a = (Article) results.get(0); > > >> > > >> //crosscheck with PersistenceBroker lookup > > >> // 1. get OID > > >> Article example = new Article(); > > >> example.setArticleId(7); > > >> Identity oid = new Identity(example); > > >> > > >> ObjectCacheFactory.getObjectCache().clear(); > > >> // 2. lookup object by OID > > >> PersistenceBroker broker = > OJB.getInstance().getBroker(); > > >> broker.clearCache(); > > >> Article b = (Article) broker.getObjectByIdentity(oid); > > >> > > >> assertEquals("should be same object", a, b); > > >> > > >> //System.out.println("now commit all changes..."); > > >> tx.commit(); > > >> } > > >> catch (Exception ex) > > >> { > > >> tx.abort(); > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> > > >> // close database > > >> try > > >> { > > >> db.close(); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> } > > >> > > >> public void tesOQLQueryOnCollections() > > >> { > > >> // get facade instance > > >> Implementation odmg = OJB.getInstance(); > > >> Database db = odmg.newDatabase(); > > >> //open database > > >> try > > >> { > > >> db.open(databaseName, Database.OPEN_READ_WRITE); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> Transaction tx = odmg.newTransaction(); > > >> > > >> //perform transaction > > >> try > > >> { > > >> tx.begin(); > > >> OQLQuery query = odmg.newOQLQuery(); > > >> query.create("select aLotOfArticles from " + > > >> > > > Article.class.getName() + " where productGroupId = 4"); > > > > > >> DCollection results = (DCollection) query.execute(); > > >> results = results.query("price > 35"); > > >> > > >> // now perform control query > > >> query = odmg.newOQLQuery(); > > >> query.create("select aLotOfArticles from " + > > >> > > > Article.class.getName() + " where productGroupId = 4 and > price > 35"); > > > > > >> DCollection check = (DCollection) query.execute(); > > >> > > >> assertEquals(results, check); > > >> > > >> > > >> tx.commit(); > > >> } > > >> catch (Exception ex) > > >> { > > >> tx.abort(); > > >> ex.printStackTrace(); > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> > > >> // close database > > >> try > > >> { > > >> db.close(); > > >> } > > >> catch (ODMGException ex) > > >> { > > >> fail("ODMGException: " + ex.getMessage()); > > >> } > > >> } > > >> > > >> > > >> /**try to open non-existing db*/ > > >> public void tesWrongDbName() > > >> { > > >> // get facade instance > > >> OJB objectserver = OJB.getInstance(); > > >> Database db = objectserver.newDatabase(); > > >> > > >> //try open database with non existing repository file: > > >> String wrongDatabaseName = "ThereIsNoSuchFile"; > > >> try > > >> { > > >> db.open(wrongDatabaseName, Database.OPEN_READ_WRITE); > > >> fail("should not be able to open database " + > > >> > > > wrongDatabaseName); > > > > > >> } > > >> catch (ODMGException ex) > > >> { > > >> return; > > >> } > > >> } > > >>} > > >> > > >> > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > |
From: Michael N. <mic...@gm...> - 2002-01-14 21:10:42
|
Hi Thomas! I've been thinking about the GC process over the last few days. > Currently there is no GC implemented. > IMHO it will be VERY difficult to have a real GC as it would be possible > with an OODBMS. > It will be very difficult to decide if objects can safely be deleted. > > BUT: we have been thinking of changing the semantics of DList.remove() > an similar methods as name roots unbind so that removed objects are > deleted from the DB. A first step towards true persistence by reachability could be to offer offline GC. This way you don't have the to deal with objects which not reachable from any named root object any more but are still referenced under another transaction that has not yet committed. The algorithm could look like this: 1. Make a list of all objects stored in the database 2. from every named root object traverse the object graph and mark any object you come across as being persistent 3. delete all the objects from the database which are currently not marked as persistent. The algorithm can be implemented using recursion. In order to avoid indefinite loops caused by cyclic references, the algorithm has to check whether an object under investigation is already marked. Another advantage is that people who do not want seamless persistence the "Java Way" but instead want to have a more basic level control over their data still have the option not to execute the garbage collector. What do you think about it? Greetings Michael ----- Original Message ----- From: "Thomas Mahler" <tho...@ho...> To: "Michael Nowotny" <mic...@gm...>; "ojb" <obj...@li...> Sent: Wednesday, January 09, 2002 6:51 PM Subject: Re: Named Root Objects > Hi again, > > > Michael Nowotny wrote: > > > Hi Thomas! > > > > Thanks for the illustration. Binding collections works fine for me now! > > The reason why my earlier attempt failed was that I was still using > > InstantDB.It seems that some transactions got only halfway commited due to > > program termination following db.close(). Now I'm using Hypersonic and > > everything works. > > > > Fine ! > > > > During the course of setting up a test procedure I came across some strange > > behaviour. The following code snipped throws an ObjectNameNotBoundException. > > > > // fails: > > tx = odmg.newTransaction(); > > tx.begin(); > > db.bind(odmg.newDList(), "MyList"); > > db.unbind("MyList"); > > db.bind(odmg.newDList(), "MyList"); > > // DList list = (DList)db.lookup("MyList"); > > tx.commit(); > > > > tx = odmg.newTransaction(); > > tx.begin(); > > DList newList = (DList)db.lookup("MyList"); > > tx.commit(); > > > > Binding the same name twice within the same transaction seems to cause an > > error. > > > Oops, This is a bug. I'll add it to my todo list! > > > This is not very important though because usually one wouldn't want > > to bind an object to a some name and thereafter unbinding that name withing > > the same transaction. > > > > Another question arose when I had a look at the contents of my database. If > > I add content to my list which is a named root object this content gets > > persistent as well. That's part of persistence by reachability. But when I > > unbind the root object and the content is therefore no longer reachable, it > > doesn't get removed from the database but is still present. Is there any way > > of performing some kind of garbage collection? > > > > > > Currently there is no GC implemented. > IMHO it will be VERY difficult to have a real GC as it would be possible > with an OODBMS. > It will be very difficult to decide if objects can safely be deleted. > > BUT: we have been thinking of changing the semantics of DList.remove() > an similar methods as name roots unbind so that removed objects are > deleted from the DB. > > Any ideas? > > -- Thomas > > > > > > Keep up the good work! > > > > Thanks, Michael > > > > ----- Original Message ----- > > From: "Thomas Mahler" <tho...@ho...> > > To: "Michael Nowotny" <mic...@gm...>; "ojb" > > <obj...@li...> > > Sent: Tuesday, January 08, 2002 8:20 PM > > Subject: Re: Named Root Objects > > > > > > > >>Hi Michael, > >> > >>please see the attached Java class. > >> > >>You can replace the original version of test.ojb.odmg.OdmgExamples with > >>this new version to have it executed with the OJB JUnit tests. > >> > >>There is a new testMethod testNrmAndDlists that tests your scenario. > >>Works great! > >> > >>HTH, > >> > >>Thomas > >> > >>Michael Nowotny wrote: > >> > >> > >>>Hi Thomas! > >>> > >>>Just found your OJB project on sourceforge. I think it's great to have > >>> > > an > > > >>>open source ODMG implementation around. > >>>Now I've got a question concerning the ODMG implemetation. > >>>Is it possible to use a DList for example as a named root object. > >>> > > Binding > > > >>>that object to a name works but looking it up again causes an > >>>IllegalArgumentException. > >>> > >>>Have you ever tried to bind a Collection. If so, I would be grateful if > >>> > > you > > > >>>could drop me some lines of source code. > >>> > >>>Thanks Michael > >>> > >>> > >>> > >>> > >>> > >>> > >> > >> > > > > > > -------------------------------------------------------------------------- -- > > ---- > > > > > > > >>package test.ojb.odmg; > >> > >> > >>import junit.framework.TestCase; > >>import ojb.broker.Identity; > >>import ojb.broker.PersistenceBroker; > >>import ojb.broker.PersistenceBrokerFactory; > >>import ojb.broker.cache.ObjectCacheFactory; > >>import ojb.odmg.OJB; > >>import ojb.odmg.states.ModificationState; > >>import ojb.odmg.states.StateNewClean; > >>import ojb.odmg.states.StateNewDirty; > >>import org.odmg.*; > >> > >>import java.util.List; > >> > >>/** Demo Application that shows basic concepts for Applications using the > >> > > OJB ODMG > > > >> * implementation as an transactional object server. > >> */ > >>public class OdmgExamples extends TestCase > >>{ > >> public static void main(String[] args) > >> { > >> String[] arr = {CLASS.getName()}; > >> junit.textui.TestRunner.main(arr); > >> } > >> > >> private static Class CLASS = OdmgExamples.class; > >> private String databaseName; > >> > >> /** > >> * Insert the method's description here. > >> * Creation date: (24.12.2000 00:33:40) > >> */ > >> public OdmgExamples(String name) > >> { > >> super(name); > >> } > >> > >> /** > >> * Insert the method's description here. > >> * Creation date: (06.12.2000 21:58:53) > >> */ > >> public void setUp() > >> { > >> databaseName = > >> > > PersistenceBrokerFactory.getConfiguration().getRepositoryFilename(); > > > >> > >> } > >> > >> /** > >> * Insert the method's description here. > >> * Creation date: (06.12.2000 21:59:14) > >> */ > >> public void tearDown() > >> { > >> databaseName = null; > >> } > >> > >> /**TestThreadsNLocks state transition of modification states*/ > >> public void testModificationStates() > >> { > >> // get facade instance > >> Implementation odmg = OJB.getInstance(); > >> Database db = odmg.newDatabase(); > >> //open database > >> try > >> { > >> db.open(databaseName, Database.OPEN_READ_WRITE); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> ModificationState oldState = StateNewClean.getInstance(); > >> ModificationState newState = oldState.markDirty(); > >> assertEquals(StateNewDirty.getInstance(), newState); > >> > >> oldState = newState; > >> newState = oldState.markDirty(); > >> assertEquals(oldState, newState); > >> > >> > >> // close database > >> try > >> { > >> db.close(); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> > >> } > >> > >> public void testOdmgSession() > >> { > >> // get facade instance > >> Implementation odmg = OJB.getInstance(); > >> Database db = odmg.newDatabase(); > >> //open database > >> try > >> { > >> db.open(databaseName, Database.OPEN_READ_WRITE); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> Transaction tx = odmg.newTransaction(); > >> > >> //perform transaction > >> try > >> { > >> tx.begin(); > >> > >> Article example = new Article(); > >> example.setArticleId(777); > >> db.makePersistent(example); > >> > >> > >> > >> // modify Object > >> example.setStock(333); > >> example.addToStock(47); > >> example.addToStock(7); > >> example.addToStock(4); > >> > >> > >> //System.out.println("now commit all changes..."); > >> tx.commit(); > >> } > >> catch (Exception ex) > >> { > >> tx.abort(); > >> } > >> > >> // close database > >> try > >> { > >> db.close(); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> } > >> > >> public void testOQLQuery() > >> { > >> // get facade instance > >> Implementation odmg = OJB.getInstance(); > >> Database db = odmg.newDatabase(); > >> //open database > >> try > >> { > >> db.open(databaseName, Database.OPEN_READ_WRITE); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> Transaction tx = odmg.newTransaction(); > >> > >> //perform transaction > >> try > >> { > >> tx.begin(); > >> > >> > >> OQLQuery query = odmg.newOQLQuery(); > >> query.create("select anArticle from " + > >> > > Article.class.getName() + " where articleId = 7"); > > > >> List results = (List) query.execute(); > >> > >> Article a = (Article) results.get(0); > >> > >> > >> // cross check with PersistenceBroker lookup > >> // 1. get OID > >> Article example = new Article(); > >> example.setArticleId(7); > >> Identity oid = new Identity(example); > >> // 2. lookup object by OID > >> PersistenceBroker broker = OJB.getInstance().getBroker(); > >> broker.clearCache(); > >> Article b = (Article) broker.getObjectByIdentity(oid); > >> > >> assertEquals("should be same object", a, b); > >> > >> //System.out.println("now commit all changes..."); > >> tx.commit(); > >> } > >> catch (Exception ex) > >> { > >> tx.abort(); > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> > >> // close database > >> try > >> { > >> db.close(); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> } > >> > >> public void testNrmAndDlists() > >> { > >> // get facade instance > >> Implementation odmg = OJB.getInstance(); > >> Database db = odmg.newDatabase(); > >> //open database > >> try > >> { > >> db.open(databaseName, Database.OPEN_READ_WRITE); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> Transaction tx = odmg.newTransaction(); > >> > >> //perform transaction > >> try > >> { > >> tx.begin(); > >> > >> > >> OQLQuery query = odmg.newOQLQuery(); > >> query.create("select x from " + Article.class.getName() + " > >> > > where productGroupId = 7"); > > > >> DList results = (DList) query.execute(); > >> > >> > >> int originalSize = results.size(); > >> > >> OJB.getLogger().info(results); > >> > >> String name = "gimme fruits !"; > >> > >> db.bind(results, name); > >> tx.commit(); > >> > >> // clear the cache to make sure things are loaded from RDBMS ! > >> OJB.getInstance().getBroker().clearCache(); > >> > >> tx = odmg.newTransaction(); > >> tx.begin(); > >> > >> // look it up again > >> DList newResults = (DList) db.lookup(name); > >> > >> assertEquals(originalSize,newResults.size()); > >> OJB.getLogger().info(results); > >> > >> tx.commit(); > >> > >> > >> } > >> catch (Throwable t) > >> { > >> tx.abort(); > >> fail("ODMGException: " + t.getMessage()); > >> } > >> > >> // close database > >> try > >> { > >> db.close(); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> } > >> > >> > >> > >> public void testOQLQueryBind() > >> { > >> // get facade instance > >> Implementation odmg = OJB.getInstance(); > >> Database db = odmg.newDatabase(); > >> //open database > >> try > >> { > >> db.open(databaseName, Database.OPEN_READ_WRITE); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> Transaction tx = odmg.newTransaction(); > >> > >> //perform transaction > >> try > >> { > >> tx.begin(); > >> > >> > >> OQLQuery query = odmg.newOQLQuery(); > >> query.create("select anArticle from " + > >> > > Article.class.getName() + " where articleId = $678"); > > > >> query.bind(new Integer(7)); > >> > >> List results = (List) query.execute(); > >> > >> Article a = (Article) results.get(0); > >> > >> //crosscheck with PersistenceBroker lookup > >> // 1. get OID > >> Article example = new Article(); > >> example.setArticleId(7); > >> Identity oid = new Identity(example); > >> > >> ObjectCacheFactory.getObjectCache().clear(); > >> // 2. lookup object by OID > >> PersistenceBroker broker = OJB.getInstance().getBroker(); > >> broker.clearCache(); > >> Article b = (Article) broker.getObjectByIdentity(oid); > >> > >> assertEquals("should be same object", a, b); > >> > >> //System.out.println("now commit all changes..."); > >> tx.commit(); > >> } > >> catch (Exception ex) > >> { > >> tx.abort(); > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> > >> // close database > >> try > >> { > >> db.close(); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> } > >> > >> public void tesOQLQueryOnCollections() > >> { > >> // get facade instance > >> Implementation odmg = OJB.getInstance(); > >> Database db = odmg.newDatabase(); > >> //open database > >> try > >> { > >> db.open(databaseName, Database.OPEN_READ_WRITE); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> Transaction tx = odmg.newTransaction(); > >> > >> //perform transaction > >> try > >> { > >> tx.begin(); > >> OQLQuery query = odmg.newOQLQuery(); > >> query.create("select aLotOfArticles from " + > >> > > Article.class.getName() + " where productGroupId = 4"); > > > >> DCollection results = (DCollection) query.execute(); > >> results = results.query("price > 35"); > >> > >> // now perform control query > >> query = odmg.newOQLQuery(); > >> query.create("select aLotOfArticles from " + > >> > > Article.class.getName() + " where productGroupId = 4 and price > 35"); > > > >> DCollection check = (DCollection) query.execute(); > >> > >> assertEquals(results, check); > >> > >> > >> tx.commit(); > >> } > >> catch (Exception ex) > >> { > >> tx.abort(); > >> ex.printStackTrace(); > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> > >> // close database > >> try > >> { > >> db.close(); > >> } > >> catch (ODMGException ex) > >> { > >> fail("ODMGException: " + ex.getMessage()); > >> } > >> } > >> > >> > >> /**try to open non-existing db*/ > >> public void tesWrongDbName() > >> { > >> // get facade instance > >> OJB objectserver = OJB.getInstance(); > >> Database db = objectserver.newDatabase(); > >> > >> //try open database with non existing repository file: > >> String wrongDatabaseName = "ThereIsNoSuchFile"; > >> try > >> { > >> db.open(wrongDatabaseName, Database.OPEN_READ_WRITE); > >> fail("should not be able to open database " + > >> > > wrongDatabaseName); > > > >> } > >> catch (ODMGException ex) > >> { > >> return; > >> } > >> } > >>} > >> > >> > > > > > > > > > > > |
From: <ba...@ge...> - 2002-01-14 17:07:42
|
Just a quick note, am sure you've come across it already. When running build.xml through ant, the following two jars are missing from the $classpath variable, and thus 'main' doesn't execute fully. ${lib}/parser.jar:${lib}/jta-spec1_0_1.jar I also get the following when the OQL is trying to be parsed in the 'oql' task. [build oql parser] oql-ojb.g:476: warning: nondeterminism upon [build oql parser] oql-ojb.g:476: k==1:Identifier [build oql parser] oql-ojb.g:476: k==2:"not" [build oql parser] oql-ojb.g:476: between alts 3 and 5 of block Thanks, Bay |
From: Mahler T. <tho...@it...> - 2002-01-14 13:05:13
|
Hi Alex, >Hi Thomas, >I'm working on a Java <-> LDAP (JNDI) mapping tool and was thinking = >to use >your PB for the tool's kernel. >Do you think that it is a reasonable and possible thing to do?=20 >If yes what PB parts should be extended or added?=20 >Does abstract query may be extended to support non SQL syntax? I think it will be easy to use the abstract syntax as defined by the ojb.broker.query package for LDAP too. You just need a translator that translates these expressions into LDAP queries. We have done exactly that in a project at my company. I don't believe that there are a lot other things that might be reused for an LDAP access in OJB. The PersistenceBrokerImpl is focussed on JDBC and nothing else. But: you might consider to let you tool implement the PersistenceBroker interface! This way OJB could be used to transparently serve relational databases AND Ldap servers. HTH, Thomas >Thank you in advance, >Alex Grivnin |
From: Jakob B. <jbr...@ho...> - 2002-01-14 07:49:42
|
hi, i have a problem using OQL. when i try to run the following qurty with a between criteria query.create("select persons from brj.ojb.Person where test between $1 and $2 and name like $3"); query.bind(new Integer(80)); query.bind(new Integer(100)); query.bind("%er"); i get the following error: org.odmg.QueryParameterCountInvalidException at ojb.odmg.oql.OQLQueryImpl.bind(OQLQueryImpl.java:122) at brj.ojb.TestODMG.queryBetween(TestODMG.java:67) at brj.ojb.TestODMG.run(TestODMG.java:88) at brj.ojb.TestODMG.main(TestODMG.java:26) the problem comes imho from OQLQueryImpl.bind(Oject parameter) ... SelectionCriteria crit = (SelectionCriteria) this.bindIterator.next(); crit.bind(parameter); ... when binding a between criteria the bindIterator should not be advanced after the first parameter. jakob ----- Original Message ----- From: "Thomas Mahler" <tho...@ho...> To: "ojb" <obj...@li...> Sent: Sunday, January 13, 2002 11:19 AM Subject: [OJB-developers] [ann] new release > Hi all, > > I just released a new release. There are some new features and a lot of > bug fixes. > > Simon provided a complete rewrite of the OQL parser. All OQL related > bugs should be fixed and some cool new things like subselects are > possible now! Thank you Simon! > > > There had been a request regarding batch operation with OJB. I fixed the > ObjectModification mechanism and rewrote the PerformanceTest to have a > separate view on broker.store(obj,true), broker.store(obj,false), > broker.getObjectByIdentity(...), broker.delete(obj) performance. > > Just try build.sh performance to see how long it takes to insert, > update, select, delete 5000 objects. You can even change the build.xml > file to increase the number of objects. > > > From the release notes: > > Changes in Release 0.7.310 > > new features: > - Support loading of OJB.properties and repository.xml as resources > through a ClassLoader > - Implement IS NULL for OQL Queries > - Integrate new Criteria into OQL Parser > - TestCase for named roots map and Dlist > - TestCase for OQL Path expressions > - JNDI lookup of JDBC Connections now completely configured through > repository.xml > > bug fixes: > - Bugs in FK assignment and superfluous calls to broker.store() > - Bug in RsIterator::releaseDbResources > - Repair ObjectModification mechanism > - Identities must always refer to toplevel extent class or interface > - Bug in Named Roots Unbind > - Fix db-setup.sql for DB2 and Oracle > - Schema attribute belongs to table not to JDBCDescriptor ! > - Fix bugs in OQL Parser (reading ints etc.) > - Bug in MetaObjectCacheImpl > - Made CollectionProxies client/server ready > > refactorings: > - Rewrote PerformanceTest to allow separate evaluation of insert, > update, select and delete operations > > > cheers, > > Thomas > > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > |
From: Thomas M. <tho...@ho...> - 2002-01-13 10:19:34
|
Hi all, I just released a new release. There are some new features and a lot of bug fixes. Simon provided a complete rewrite of the OQL parser. All OQL related bugs should be fixed and some cool new things like subselects are possible now! Thank you Simon! There had been a request regarding batch operation with OJB. I fixed the ObjectModification mechanism and rewrote the PerformanceTest to have a separate view on broker.store(obj,true), broker.store(obj,false), broker.getObjectByIdentity(...), broker.delete(obj) performance. Just try build.sh performance to see how long it takes to insert, update, select, delete 5000 objects. You can even change the build.xml file to increase the number of objects. From the release notes: Changes in Release 0.7.310 new features: - Support loading of OJB.properties and repository.xml as resources through a ClassLoader - Implement IS NULL for OQL Queries - Integrate new Criteria into OQL Parser - TestCase for named roots map and Dlist - TestCase for OQL Path expressions - JNDI lookup of JDBC Connections now completely configured through repository.xml bug fixes: - Bugs in FK assignment and superfluous calls to broker.store() - Bug in RsIterator::releaseDbResources - Repair ObjectModification mechanism - Identities must always refer to toplevel extent class or interface - Bug in Named Roots Unbind - Fix db-setup.sql for DB2 and Oracle - Schema attribute belongs to table not to JDBCDescriptor ! - Fix bugs in OQL Parser (reading ints etc.) - Bug in MetaObjectCacheImpl - Made CollectionProxies client/server ready refactorings: - Rewrote PerformanceTest to allow separate evaluation of insert, update, select and delete operations cheers, Thomas |
From: Thomas M. <tho...@ho...> - 2002-01-11 18:14:30
|
Hi Matt, I agree that the current implementation is not optimal. Your proposal 3 sounds good to me. But I believe that it needs an intense redesign of parts of the query mechanism. This will be a lot of work... I don't know if I can implement your request soon. Maybe someone is volunteering on this problem ?! regards, Thomas Matt Goodall wrote: > Hi all, > > > > I've got a few more comments on the "inheritance mapping on one table" > scenario ... > > > > 1. Extra objects are created > > > > When retrieving all records of a derived class creates an object for > *every* record in the table regardless of whether the ojbConcreteClass > matches the type (or derived type) requested. Obviously, that has a huge > performance impact if the table is large. > > > > I tried implementing a RowReader and returning a null class descriptor > when I didn't want to load the record but that just makes it think that > they were of the type I requested so I got extra matches. > > > > 2. You have to map all objects stored in the table > > > > At the moment, I don't care about a lot of the data in the table I'm > using but OJB insists on loading everything and then starts failing when > it finds a type I haven't mapped in the repository yet. It would be > really nice if these objects could be silently ignored. > > > > 3. The SQL query could be improved > > > > If you load all objects of a derived type then OJB actually retrieves > every record in the table. It seems to me that since the repository > knows the inheritance graph for all these classes it could construct a > where clause to reduce the number of records loaded. > > > > Just in case that's not clear, here's a contrived example. Given a class > hirearchy of > > > > Fruit > > Orange > > SevilleOrange > > Satsuma (yeah, I know it's not an orange - I said it was > contrived) > > Banana > > > > When you ask for all Orange objects the where clause could be "where > ojbConcreteClass in ('Orange', 'SevilleOrange', 'Satsuma')". > > > > In fact when you ask for all Fruit objects it could build a where clause > for all types in the hierarchy and any unmapped types would not be > retrieved. > > > > > > It looks like the implementation of 3 would actually solve 1 and 2. > > > > Thomas, can you see any problems with this - I have very limited > knowledge of OJB's implementation at the moment. > > > > Cheers, Matt > > > > --- > > Matt Goodall > > Analyst Programmer, Strategic Systems Solutions > > e: mat...@ss... <mailto:mat...@ss...>, t: +44 > 113 3892645 > > > |
From: Thomas M. <tho...@ho...> - 2002-01-11 18:14:30
|
Hi Lasse, Lasse Lindgard wrote: > Will ORB development branch for the version 2.0 development ? > > With the rather large refactorings that Thomas suggests I find it hard to > belive that the interface won't change and that bugs won't be introduced. > > I belive that keeping a branch for stablizing version 1.0 would make it > possible for a lot of developers to start using ORB in production sites. > You are right. The development of OJB 2.0 should not destabilize the existing release! If necessary we will have to maintain a branch. But I hope it will not be necessary as it will be a lot of unproductive work to maintain a branch. Just my 0.02EUR Thomas > Just my 2? > > /Lasse > > > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers > > > > |
From: Thomas M. <tho...@ho...> - 2002-01-09 17:51:18
|
Hi again, Michael Nowotny wrote: > Hi Thomas! > > Thanks for the illustration. Binding collections works fine for me now! > The reason why my earlier attempt failed was that I was still using > InstantDB.It seems that some transactions got only halfway commited due to > program termination following db.close(). Now I'm using Hypersonic and > everything works. > Fine ! > During the course of setting up a test procedure I came across some strange > behaviour. The following code snipped throws an ObjectNameNotBoundException. > > // fails: > tx = odmg.newTransaction(); > tx.begin(); > db.bind(odmg.newDList(), "MyList"); > db.unbind("MyList"); > db.bind(odmg.newDList(), "MyList"); > // DList list = (DList)db.lookup("MyList"); > tx.commit(); > > tx = odmg.newTransaction(); > tx.begin(); > DList newList = (DList)db.lookup("MyList"); > tx.commit(); > > Binding the same name twice within the same transaction seems to cause an > error. Oops, This is a bug. I'll add it to my todo list! This is not very important though because usually one wouldn't want > to bind an object to a some name and thereafter unbinding that name withing > the same transaction. > > Another question arose when I had a look at the contents of my database. If > I add content to my list which is a named root object this content gets > persistent as well. That's part of persistence by reachability. But when I > unbind the root object and the content is therefore no longer reachable, it > doesn't get removed from the database but is still present. Is there any way > of performing some kind of garbage collection? > Currently there is no GC implemented. IMHO it will be VERY difficult to have a real GC as it would be possible with an OODBMS. It will be very difficult to decide if objects can safely be deleted. BUT: we have been thinking of changing the semantics of DList.remove() an similar methods as name roots unbind so that removed objects are deleted from the DB. Any ideas? -- Thomas > Keep up the good work! > > Thanks, Michael > > ----- Original Message ----- > From: "Thomas Mahler" <tho...@ho...> > To: "Michael Nowotny" <mic...@gm...>; "ojb" > <obj...@li...> > Sent: Tuesday, January 08, 2002 8:20 PM > Subject: Re: Named Root Objects > > > >>Hi Michael, >> >>please see the attached Java class. >> >>You can replace the original version of test.ojb.odmg.OdmgExamples with >>this new version to have it executed with the OJB JUnit tests. >> >>There is a new testMethod testNrmAndDlists that tests your scenario. >>Works great! >> >>HTH, >> >>Thomas >> >>Michael Nowotny wrote: >> >> >>>Hi Thomas! >>> >>>Just found your OJB project on sourceforge. I think it's great to have >>> > an > >>>open source ODMG implementation around. >>>Now I've got a question concerning the ODMG implemetation. >>>Is it possible to use a DList for example as a named root object. >>> > Binding > >>>that object to a name works but looking it up again causes an >>>IllegalArgumentException. >>> >>>Have you ever tried to bind a Collection. If so, I would be grateful if >>> > you > >>>could drop me some lines of source code. >>> >>>Thanks Michael >>> >>> >>> >>> >>> >>> >> >> > > > ---------------------------------------------------------------------------- > ---- > > > >>package test.ojb.odmg; >> >> >>import junit.framework.TestCase; >>import ojb.broker.Identity; >>import ojb.broker.PersistenceBroker; >>import ojb.broker.PersistenceBrokerFactory; >>import ojb.broker.cache.ObjectCacheFactory; >>import ojb.odmg.OJB; >>import ojb.odmg.states.ModificationState; >>import ojb.odmg.states.StateNewClean; >>import ojb.odmg.states.StateNewDirty; >>import org.odmg.*; >> >>import java.util.List; >> >>/** Demo Application that shows basic concepts for Applications using the >> > OJB ODMG > >> * implementation as an transactional object server. >> */ >>public class OdmgExamples extends TestCase >>{ >> public static void main(String[] args) >> { >> String[] arr = {CLASS.getName()}; >> junit.textui.TestRunner.main(arr); >> } >> >> private static Class CLASS = OdmgExamples.class; >> private String databaseName; >> >> /** >> * Insert the method's description here. >> * Creation date: (24.12.2000 00:33:40) >> */ >> public OdmgExamples(String name) >> { >> super(name); >> } >> >> /** >> * Insert the method's description here. >> * Creation date: (06.12.2000 21:58:53) >> */ >> public void setUp() >> { >> databaseName = >> > PersistenceBrokerFactory.getConfiguration().getRepositoryFilename(); > >> >> } >> >> /** >> * Insert the method's description here. >> * Creation date: (06.12.2000 21:59:14) >> */ >> public void tearDown() >> { >> databaseName = null; >> } >> >> /**TestThreadsNLocks state transition of modification states*/ >> public void testModificationStates() >> { >> // get facade instance >> Implementation odmg = OJB.getInstance(); >> Database db = odmg.newDatabase(); >> //open database >> try >> { >> db.open(databaseName, Database.OPEN_READ_WRITE); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> ModificationState oldState = StateNewClean.getInstance(); >> ModificationState newState = oldState.markDirty(); >> assertEquals(StateNewDirty.getInstance(), newState); >> >> oldState = newState; >> newState = oldState.markDirty(); >> assertEquals(oldState, newState); >> >> >> // close database >> try >> { >> db.close(); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> >> } >> >> public void testOdmgSession() >> { >> // get facade instance >> Implementation odmg = OJB.getInstance(); >> Database db = odmg.newDatabase(); >> //open database >> try >> { >> db.open(databaseName, Database.OPEN_READ_WRITE); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> Transaction tx = odmg.newTransaction(); >> >> //perform transaction >> try >> { >> tx.begin(); >> >> Article example = new Article(); >> example.setArticleId(777); >> db.makePersistent(example); >> >> >> >> // modify Object >> example.setStock(333); >> example.addToStock(47); >> example.addToStock(7); >> example.addToStock(4); >> >> >> //System.out.println("now commit all changes..."); >> tx.commit(); >> } >> catch (Exception ex) >> { >> tx.abort(); >> } >> >> // close database >> try >> { >> db.close(); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> } >> >> public void testOQLQuery() >> { >> // get facade instance >> Implementation odmg = OJB.getInstance(); >> Database db = odmg.newDatabase(); >> //open database >> try >> { >> db.open(databaseName, Database.OPEN_READ_WRITE); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> Transaction tx = odmg.newTransaction(); >> >> //perform transaction >> try >> { >> tx.begin(); >> >> >> OQLQuery query = odmg.newOQLQuery(); >> query.create("select anArticle from " + >> > Article.class.getName() + " where articleId = 7"); > >> List results = (List) query.execute(); >> >> Article a = (Article) results.get(0); >> >> >> // cross check with PersistenceBroker lookup >> // 1. get OID >> Article example = new Article(); >> example.setArticleId(7); >> Identity oid = new Identity(example); >> // 2. lookup object by OID >> PersistenceBroker broker = OJB.getInstance().getBroker(); >> broker.clearCache(); >> Article b = (Article) broker.getObjectByIdentity(oid); >> >> assertEquals("should be same object", a, b); >> >> //System.out.println("now commit all changes..."); >> tx.commit(); >> } >> catch (Exception ex) >> { >> tx.abort(); >> fail("ODMGException: " + ex.getMessage()); >> } >> >> // close database >> try >> { >> db.close(); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> } >> >> public void testNrmAndDlists() >> { >> // get facade instance >> Implementation odmg = OJB.getInstance(); >> Database db = odmg.newDatabase(); >> //open database >> try >> { >> db.open(databaseName, Database.OPEN_READ_WRITE); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> Transaction tx = odmg.newTransaction(); >> >> //perform transaction >> try >> { >> tx.begin(); >> >> >> OQLQuery query = odmg.newOQLQuery(); >> query.create("select x from " + Article.class.getName() + " >> > where productGroupId = 7"); > >> DList results = (DList) query.execute(); >> >> >> int originalSize = results.size(); >> >> OJB.getLogger().info(results); >> >> String name = "gimme fruits !"; >> >> db.bind(results, name); >> tx.commit(); >> >> // clear the cache to make sure things are loaded from RDBMS ! >> OJB.getInstance().getBroker().clearCache(); >> >> tx = odmg.newTransaction(); >> tx.begin(); >> >> // look it up again >> DList newResults = (DList) db.lookup(name); >> >> assertEquals(originalSize,newResults.size()); >> OJB.getLogger().info(results); >> >> tx.commit(); >> >> >> } >> catch (Throwable t) >> { >> tx.abort(); >> fail("ODMGException: " + t.getMessage()); >> } >> >> // close database >> try >> { >> db.close(); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> } >> >> >> >> public void testOQLQueryBind() >> { >> // get facade instance >> Implementation odmg = OJB.getInstance(); >> Database db = odmg.newDatabase(); >> //open database >> try >> { >> db.open(databaseName, Database.OPEN_READ_WRITE); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> Transaction tx = odmg.newTransaction(); >> >> //perform transaction >> try >> { >> tx.begin(); >> >> >> OQLQuery query = odmg.newOQLQuery(); >> query.create("select anArticle from " + >> > Article.class.getName() + " where articleId = $678"); > >> query.bind(new Integer(7)); >> >> List results = (List) query.execute(); >> >> Article a = (Article) results.get(0); >> >> //crosscheck with PersistenceBroker lookup >> // 1. get OID >> Article example = new Article(); >> example.setArticleId(7); >> Identity oid = new Identity(example); >> >> ObjectCacheFactory.getObjectCache().clear(); >> // 2. lookup object by OID >> PersistenceBroker broker = OJB.getInstance().getBroker(); >> broker.clearCache(); >> Article b = (Article) broker.getObjectByIdentity(oid); >> >> assertEquals("should be same object", a, b); >> >> //System.out.println("now commit all changes..."); >> tx.commit(); >> } >> catch (Exception ex) >> { >> tx.abort(); >> fail("ODMGException: " + ex.getMessage()); >> } >> >> // close database >> try >> { >> db.close(); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> } >> >> public void tesOQLQueryOnCollections() >> { >> // get facade instance >> Implementation odmg = OJB.getInstance(); >> Database db = odmg.newDatabase(); >> //open database >> try >> { >> db.open(databaseName, Database.OPEN_READ_WRITE); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> Transaction tx = odmg.newTransaction(); >> >> //perform transaction >> try >> { >> tx.begin(); >> OQLQuery query = odmg.newOQLQuery(); >> query.create("select aLotOfArticles from " + >> > Article.class.getName() + " where productGroupId = 4"); > >> DCollection results = (DCollection) query.execute(); >> results = results.query("price > 35"); >> >> // now perform control query >> query = odmg.newOQLQuery(); >> query.create("select aLotOfArticles from " + >> > Article.class.getName() + " where productGroupId = 4 and price > 35"); > >> DCollection check = (DCollection) query.execute(); >> >> assertEquals(results, check); >> >> >> tx.commit(); >> } >> catch (Exception ex) >> { >> tx.abort(); >> ex.printStackTrace(); >> fail("ODMGException: " + ex.getMessage()); >> } >> >> // close database >> try >> { >> db.close(); >> } >> catch (ODMGException ex) >> { >> fail("ODMGException: " + ex.getMessage()); >> } >> } >> >> >> /**try to open non-existing db*/ >> public void tesWrongDbName() >> { >> // get facade instance >> OJB objectserver = OJB.getInstance(); >> Database db = objectserver.newDatabase(); >> >> //try open database with non existing repository file: >> String wrongDatabaseName = "ThereIsNoSuchFile"; >> try >> { >> db.open(wrongDatabaseName, Database.OPEN_READ_WRITE); >> fail("should not be able to open database " + >> > wrongDatabaseName); > >> } >> catch (ODMGException ex) >> { >> return; >> } >> } >>} >> >> > > > > |
From: Thomas M. <tho...@ho...> - 2002-01-08 19:21:02
|
Hi Michael, please see the attached Java class. You can replace the original version of test.ojb.odmg.OdmgExamples with this new version to have it executed with the OJB JUnit tests. There is a new testMethod testNrmAndDlists that tests your scenario. Works great! HTH, Thomas Michael Nowotny wrote: > Hi Thomas! > > Just found your OJB project on sourceforge. I think it's great to have an > open source ODMG implementation around. > Now I've got a question concerning the ODMG implemetation. > Is it possible to use a DList for example as a named root object. Binding > that object to a name works but looking it up again causes an > IllegalArgumentException. > > Have you ever tried to bind a Collection. If so, I would be grateful if you > could drop me some lines of source code. > > Thanks Michael > > > > > |
From: <ll...@li...> - 2002-01-08 14:01:54
|
Will ORB development branch for the version 2.0 development ? With the rather large refactorings that Thomas suggests I find it hard to belive that the interface won't change and that bugs won't be introduced. I belive that keeping a branch for stablizing version 1.0 would make it possible for a lot of developers to start using ORB in production sites. Just my 2? /Lasse |
From: Matt G. <mat...@ss...> - 2002-01-08 10:47:27
|
Hi all, I've got a few more comments on the "inheritance mapping on one table" scenario ... 1. Extra objects are created When retrieving all records of a derived class creates an object for *every* record in the table regardless of whether the ojbConcreteClass matches the type (or derived type) requested. Obviously, that has a huge performance impact if the table is large. I tried implementing a RowReader and returning a null class descriptor when I didn't want to load the record but that just makes it think that they were of the type I requested so I got extra matches. 2. You have to map all objects stored in the table At the moment, I don't care about a lot of the data in the table I'm using but OJB insists on loading everything and then starts failing when it finds a type I haven't mapped in the repository yet. It would be really nice if these objects could be silently ignored. 3. The SQL query could be improved If you load all objects of a derived type then OJB actually retrieves every record in the table. It seems to me that since the repository knows the inheritance graph for all these classes it could construct a where clause to reduce the number of records loaded. Just in case that's not clear, here's a contrived example. Given a class hirearchy of Fruit Orange SevilleOrange Satsuma (yeah, I know it's not an orange - I said it was contrived) Banana When you ask for all Orange objects the where clause could be "where ojbConcreteClass in ('Orange', 'SevilleOrange', 'Satsuma')". In fact when you ask for all Fruit objects it could build a where clause for all types in the hierarchy and any unmapped types would not be retrieved. It looks like the implementation of 3 would actually solve 1 and 2. Thomas, can you see any problems with this - I have very limited knowledge of OJB's implementation at the moment. Cheers, Matt --- Matt Goodall Analyst Programmer, Strategic Systems Solutions e: mat...@ss..., t: +44 113 3892645 |
From: Matt G. <mat...@ss...> - 2002-01-07 15:24:20
|
Hi, The "inheritance mapping on one table" is much better, thanks! There is a bug in ojb.broker.accesslayer.RsIterator.releaseDbResources() now though. It should close the ResultSet before attempting to close the Statement. At the moment it throws a NullPointerException when used with the Oracle thin JDBC driver. Simply move the m_rs.close() line to before the (if stmt != null) line. Cheers, Matt |
From: Mahler T. <tho...@it...> - 2002-01-07 08:40:52
|
Hi Matt, -----Urspr=FCngliche Nachricht----- Von: Matt Goodall [mailto:mat...@ss...] Gesendet: Freitag, 4. Januar 2002 14:30 An: Objectbridge Developers List (E-mail) Betreff: [OJB-developers] EJB transaction support Hi, =20 I've not done any entity bean stuff yet so forgive me for asking a = probably simple question. =20 If I was to use OJB as the persistence layer for bean managed = persistence how would I use the transaction support that the EJB container = supplies? =20 Currently OJB does not provide any integration in JTA or CMT. I placed this as a high priority feature request on the todo-list! =20 regards, =20 Thomas =20 Thanks, Matt --- Matt Goodall Analyst Programmer, Strategic Systems Solutions e: mat...@ss... <mailto:mat...@ss...> , t: = +44 113 3892645 =20 |
From: Thomas M. <tho...@ho...> - 2002-01-06 10:39:43
|
Hi all, I just assembled a new release. It's mainly a bug fix release. The C/S mode should now run without any problems! There are only two new features: - The SequenceManager can now also return long values (and arbitrary objects) - Jakob's implementation of collection proxies has been integrated. from the release notes: Changes in Release 0.7.290 new features: - SequenceManager: return long and Object - Provide a better proxy mechanism for 1:n references. We need proxies not on the element level of the collection,but on the collection level. That is: not 100 proxies for 100 elements in the collection, but 1 Proxy for the complete collection. bug fixes: - TX serializable: one tx can't acquire read lock twice - Bugs in inheritance mapping on one table - Bugs in PB Server - RsIterator bug with releaseDbResources - ODMG tx checkpoint must rethrow exceptions - Bug with updating objects that have only primary key fields ("UPDATE table WHERE col1=1 AND col2=2") refactorings: - Cache synchronization More information is available at http://objectbridge.sourceforge.net Copyright (c) 2000, 2001, Thomas Mahler, et al. |
From: Matt G. <mat...@ss...> - 2002-01-04 13:29:43
|
Hi, I've not done any entity bean stuff yet so forgive me for asking a probably simple question. If I was to use OJB as the persistence layer for bean managed persistence how would I use the transaction support that the EJB container supplies? Thanks, Matt --- Matt Goodall Analyst Programmer, Strategic Systems Solutions e: mat...@ss..., t: +44 113 3892645 |
From: Bischof, R. <rai...@ed...> - 2002-01-04 11:13:43
|
Hi, I am trying to get automatic FK-assignment working with the ODMG interface and guess I found some bugs but I am not quite sure. My setup: I have a parent class with an auto-incremented PK named id which holds a collection of child objects. I have a child class has a PK that consists of parent_id (which is the ID of parent) and an additional String. It has it's own reference back to it's parent. I create a new parent and new children. The problem is that for new objects the sequence is: insert object, store references (where FK references are assigned), update the object. When the children are inserted their PK contains a parent_id 0. The method storeReferences updates the parent_id referencing to match the parent's id. Updating the child afterwards performs an "update ... where parent_id=123 and ...". This update does not match the child because the children have an (invalid) parent_id of 0, leaving DB state and OJB cache inconsistent. Another point is that you can't lock the children before they are stored as each of theoir PKs contains the invalid parent_id 0. I guess this works fine if the child object has it's own PK that does not include the reference to it's parent. Next bug seems to be that the FK assignment won't work if the children don't have references back to the parent. The children may be stored before the parent is stored, thus the FK assignment has not yet taken place, leaving the FK of all children invalid which are stored before the parent is stored. This is related to the missing direction in the object graph which causes the known foreign key violation bug. What about performing all FK assignment before the first object of a ODMG transaction is stored? Or when the object is locked? Any idea? Thanks Rainer Bischof |
From: Matt G. <mat...@ss...> - 2002-01-03 18:00:32
|
Hello again, I've been trying to get the "mapping all classes on the same table" scenario working. I think there's a bug in the code that instantiates these objects. I originally posted about problems with this in December last year - I should have followed it up sooner :(. The easiest way to hilight the problem is by extending the PersistenceBrokerTest.java unit tests - at the end of the message is a modified version of the testMappingToOneTable() test. AFAICT, the test now adds 2 A's and 1 B, I haven't found any other tests which add any more. I would therefore expect the table to hold 2 A's and 1 B which should mean that a search for AB's, A's and B's should return 3, 2 and 1 objects respectively. You actually get 6, 3 and 3 objects! Hopefully, I've understood how to use OJB in this way. If not, my apologies for saying there's a bug ;) Hopefully, one day (if I ever get to use OJB properly), I'll be able to send patches in instead. Cheers, Matt ---------------------------------------------------------------------- /** * performs a test of the inheritance mapping to one table. */ public void testMappingToOneTable() { try { A a1 = new A(); Identity iA1 = new Identity(a1); A a2 = new A(); Identity iA2 = new Identity(a2); B b1 = new B(); Identity iB2 = new Identity(b1); broker.store(a1); broker.store(a2); broker.store(b1); AB ab = null; Criteria crit = new Criteria(); crit.addEqualTo("id", new Integer(a1.id)); Query q = QueryFactory.newQuery(AB.class, crit); ab = (AB) broker.getObjectByQuery(q); assertEquals(A.class.getName(), ab.getConcreteClass()); assertEquals(A.class, ab.getClass()); crit = new Criteria(); crit.addEqualTo("id", new Integer(b1.id)); q = QueryFactory.newQuery(AB.class, crit); ab = (AB) broker.getObjectByQuery(q); assertEquals(B.class.getName(), ab.getConcreteClass()); assertEquals(B.class, ab.getClass()); Collection abs = null; // Test retrieval of collections q = QueryFactory.newQuery(AB.class, null); abs = broker.getCollectionByQuery(q); //System.out.println("AB's = " + abs.size()); assertEquals(abs.size(), 3); q = QueryFactory.newQuery(A.class, null); abs = broker.getCollectionByQuery(q); //System.out.println("A's = " + abs.size()); assertEquals(abs.size(), 2); q = QueryFactory.newQuery(B.class, null); abs = broker.getCollectionByQuery(q); //System.out.println("B's = " + abs.size()); assertEquals(abs.size(), 1); } catch (Throwable t) { fail(t.getMessage()); } } ---------------------------------------------------------------------- --- Matt Goodall Analyst Programmer, Strategic Systems Solutions e: mat...@ss..., t: +44 113 3892645 |
From: Jakob B. <jbr...@ho...> - 2002-01-03 16:33:32
|
hi, the attached zip contains extensions based on ojb 07.277 to support proxy collections and refresh of relationships for objects found in the cache. proxy collections: this is ONE proxy for the whole collection of related objects, the proxy collection will load as soon as data is read from it, reading the size does NOT load the data (retrieving the size is done with select count(*) ). definition is on CollectionDescriptor <CollectionDescriptor id="1"> <orderby sort="asc">saldo</orderby> <cdfield.name>konti</cdfield.name> <items.class>brj.ojb.Konto</items.class> <inverse_fk_descriptor_ids>2</inverse_fk_descriptor_ids> <auto.retrieve>true</auto.retrieve> <auto.update>true</auto.update> <auto.delete>true</auto.delete> <lazy>true</lazy> <<<<< lazy uses proxy collection </CollectionDescriptor> refresh relationships: the current implementation of ojb does not do this, when the RSIterator finds an object in the cache. i had a problem with sorted realtionships when the sort attribute was updated. definition is on ClassDescriptor, it could later be moved to the Relationship itself to allow finer control of the behaviour. as an alternative the query could provide a refresh feature. anyway, my current solution is simple and refreshes all relationships of a class. <ClassDescriptor id="1"> <class.name>brj.ojb.Person</class.name> <table.name>tabPerson</table.name> <conversionStrategy>brj.ojb.ConversionStrategy</conversionStrategy> <refreshRelationships>true</refreshRelationships> <<<<< refresh <FieldDescriptor id="1"> <field.name>id</field.name> jakob |
From: Thomas M. <tho...@ho...> - 2002-01-03 15:07:45
|
Hi Georg, Georg Schneider wrote: > > Hi, > > I have been following the ojb project for some time now and I have to > admit that I am quite impressed. > I still have a question concerning path expressions. Do you also support > longer expressions like e.g. .... where a.b.c = ... ? > I guess it does. The testcases check till a.b.c = ... But there is no Testcase for a.b.c.d or deeper . Just give it a try! -- Thomas > Thx for your answer > > Regards > > Georg > > _______________________________________________ > Objectbridge-developers mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-developers |
From: Bischof, R. <rai...@ed...> - 2002-01-03 14:50:38
|
Thomas, I found a minor problem with the RsIterator: In releaseDbResources() it only catches and hides SQLExceptions. But my DB2 Driver throws an AbstractMethodError which is not handled there. I guess it should be changed to catch any Throwable. Best Regards rb |
From: Georg S. <ge...@me...> - 2002-01-03 13:55:36
|
Hi, I have been following the ojb project for some time now and I have to admit that I am quite impressed. I still have a question concerning path expressions. Do you also support longer expressions like e.g. .... where a.b.c = ... ? Thx for your answer Regards Georg |
From: Matt G. <mat...@ss...> - 2002-01-03 10:54:45
|
> -----Original Message----- > From: to...@ma... [mailto:to...@ma...]On Behalf Of > Thomas Mahler > Sent: 03 January 2002 12:18 > To: Matt Goodall > Cc: Objectbridge Developers List (E-mail) > Subject: Re: [OJB-developers] ODMG transaction question snip! > This is definitively a bug in .checkpoint() ! > I assume that exceptions thrown from the lower level PersistenceBroker > API are ignored or not handled correctly during .checkpoint(). Something that I find quite unusual about the ODMG interface, especially org.odmg.Transaction's commit() and checkpoint(), is that its exceptions are all derived from RuntimeException. That makes it easy to miss things ... oh well. > > I have to say, I'm not sure I'd ever use transactions like this, it > > all came about through some test code which *always* aborted the > > transaction. I didn't have the checkpoint() then either. > The intention > > was to leave the database intact after running the test which addded > > data and then retrieved it again - I was just playing with the API > > basically. > > > > But even if it's no realistic scenario: OJB must handle it > correctly!!! True. > Thanks for you detailed report, it will help me to fix this thing > quickly! No problem, glad I can help. Cheers, Matt |