RE: repository_user.xml, reverse-db and field indexes
Hi, Ricardo, Currently I am still using 0.9.8. In 0.9.8 the first field id must start with "1" and no hole should be allowed in the numbering of the field id's. (i.e. must be "1, 2, 3, 4" instead of "0, 12, 23, 14"). The reverse-db currently cannot generating the field id in the proper way. If you are using 0.9.8 or before, you would have to manually edit the id. Regards, Anthony -Original Message- From: Ricardo Tercero Lozano [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 04, 2003 1:45 AM To: OJB Users List Subject: RE: repository_user.xml, reverse-db and field indexes New information: Field descriptor indexes can begin with "0" (there's no complaints) but if I put a reference-descriptor with a foreign-key id = "6", OJB gets the bean for the previous field-id (as it starts counting with "1"). Ricardo. -Mensaje original- De: Ricardo Tercero Lozano [mailto:[EMAIL PROTECTED] Enviado el: lunes, 03 de marzo de 2003 18:24 Para: [EMAIL PROTECTED] Asunto: repository_user.xml, reverse-db and field indexes I found than if list of field descriptors inside a class descriptor in repository_user.xml don't work properly if field indexes begin with "0" (as generated by reverse-db) and reference descriptors are defined for some fields. Key values were loaded right, but some associated beans are loaded and some not. This behavior was found for a table with 4 references to another table (4 types of users of class UserBean). I use OJB 0.9.9. Ricardo. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to use Map type for Collections?
Thomas Mahler schrieb: >Hi ½²³Õ¦Ü, > >Why don't you simply use the ODMG DMap Implementation? >This will save you a lot of work! > >Thomas > > > Are classes from packages ..odmg.. restricted for use with OQL or can i use persistenceBroker too? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
error storing null value in not null field..
Hello I'm experiencing a very strange problem with ojb 0.9.9 and PostgreSQL. I'm having this exception: java.sql.SQLException: ERROR: ExecAppend: Fail to add null value in not null attribute member_id at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:94) at org.postgresql.Connection.ExecSQL(Connection.java:398) at org.postgresql.jdbc2.Statement.execute(Statement.java:130) at org.postgresql.jdbc2.Statement.executeUpdate(Statement.java:73) at org.postgresql.jdbc2.PreparedStatement.executeUpdate(PreparedStatement.java:113) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:205) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(JdbcAccessImpl.java:199) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeToDb(PersistenceBrokerImpl.java:1742) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:1683) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(PersistenceBrokerImpl.java:632) at org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.store(DelegatingPersistenceBroker.java:151) at org.mayaxatl.db.PersistenceManager_OJB.store(PersistenceManager_OJB.java:36) But just before the broker.store(subscr) is called, my logs show: subscr.getMemberId() = 562 So i'm storing an object with a certain property set to a not null value, but somehow in the store process, the value gets lost. Anyone an idea? thanks in advance! Felix repository_user.xml: - code: Subscription subscr = new Subscription(); //prepopulated by struts log.debug ("subscr.getMemberId() = " + subscr.getMemberId()); //logs show value broker.beginTransaction(); //broker alreasy initialized of course broker.store (subscr); broker.andTransaction(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[ann] new release
hi all, the first 1.0 release candidate is out. We have tried to fix all known problems of the 0.9.9 release. We have also paid much attention to the build process under the different jdks. The tutorial apps should work without problems now. enJoy, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OJB and JDOUserException : Object Exists
Hi Lennart, The problem is presumably that the identities assigned from the sequence Manager are not immediately visible to the JDO layers. You could avoid these problems by explicitely triggering computing the sequence numbers *before* making the objects persistent. lManager.currentTransaction().begin(); new Identity(lA1); lManager.makePersistent( lA1); lManager.currentTransaction().commit(); lManager.currentTransaction().begin(); new Identity(lA2); lManager.makePersistent( lA2); lManager.currentTransaction().commit(); cheers, Thomas Lennart Benoot wrote: Hi all, I have an jdo enabled object that has an primary key id generated by a mysql auto incremented integer. Therefore i use the "org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl" SequenceManager. I tried to disable the cache by setting: lFactory.setIgnoreCache( true); lFactory is the PersistenceManagerFactory. Then i executed the following code: (lA1 and lA2 are two valid objects) lManager.currentTransaction().begin(); lManager.makePersistent( lA1); lManager.currentTransaction().commit(); lManager.currentTransaction().begin(); (*)lManager.makePersistent( lA2); lManager.currentTransaction().commit(); the following exeption is throws at (*) : javax.jdo.JDOUserException: Object exists. Instance with the same primary key is already in the PersistenceManager cache. at com.sun.jdori.common.CacheManagerImpl.register(Unknown Source) at com.sun.jdori.common.PersistenceManagerImpl.register(Unknown Source) at com.sun.jdori.common.state.StateManagerImpl.initializeSM(Unknown Source) at com.sun.jdori.common.state.StateManagerImpl.makePersistent(Unknown Source) at com.sun.jdori.common.CacheManagerImpl.makePersistent(Unknown Source) at com.sun.jdori.common.PersistenceManagerImpl.makePersistentInternal(Unknown Source) at com.sun.jdori.common.PersistenceManagerImpl.makePersistent(Unknown Source) at com.sun.jdori.common.PersistenceManagerWrapper.makePersistent(Unknown Source) at axelera.gui.model.messaging.adaptor.AdaptorHome.main(AdaptorHome.java:145) What wrong here? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PersistenceBrokerAware and current transaction
Thank you, Armin. I am using TxManagerFactory.instance().getCurrentTransaction() now. --Bill. - Original Message - From: "Armin Waibel" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Monday, March 03, 2003 1:05 AM Subject: Re: PersistenceBrokerAware and current transaction > Hi Bill, > > - Original Message - > From: "V.B. Skrypnyk" <[EMAIL PROTECTED]> > To: "OJB Users List" <[EMAIL PROTECTED]> > Sent: Monday, March 03, 2003 7:28 AM > Subject: PersistenceBrokerAware and current transaction > > > > Hi, > > > > I am trying to implement my own cascading deletes of sorts through > > PersistenceBrokerAware beforeDelete callback. Strangely (?) I can't > seem to > > get the current transaction by calling: > > > > OJB.getInstance().currentTransaction() > > OJB isn't a singleton, thus when calling > OJB.getInstance() > you will get a new Implementation instance. > > regards, > Armin > > > > > so that I can add the affected dependent objects to it (so it may be > saved). > > I get the following exception: > > > > [java] org.odmg.DatabaseClosedException: Database is NULL, must have > a DB > > in order to create a transaction > > > > Is this correct behaviour? It's the same thread, shouldn't I be able > to > > retrieve the current transaction? > > > > Cheers, > > --Bill. > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting access to OJB's datasource
Hi Mark, see FAQ http://db.apache.org/ojb/faq.html#24 or in shipped docs. regards, Armin - Original Message - From: "Mark H" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 03, 2003 6:51 PM Subject: Getting access to OJB's datasource > Hi there, > > Is there anyway to get access to the OJB's datasource (pooled connection) in > Persistant broker for straight SQL queries? > > Thx, Mark > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Getting access to OJB's datasource
Yes. broker.serviceConnectionManager().getConnection() Ron Gallagher Atlanta, GA [EMAIL PROTECTED] > > From: "Mark H" <[EMAIL PROTECTED]> > Date: 2003/03/03 Mon PM 12:51:49 EST > To: <[EMAIL PROTECTED]> > Subject: Getting access to OJB's datasource > > Hi there, > > Is there anyway to get access to the OJB's datasource (pooled connection) in > Persistant broker for straight SQL queries? > > Thx, Mark > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Getting access to OJB's datasource
Hi there, Is there anyway to get access to the OJB's datasource (pooled connection) in Persistant broker for straight SQL queries? Thx, Mark - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: repository_user.xml, reverse-db and field indexes
New information: Field descriptor indexes can begin with "0" (there's no complaints) but if I put a reference-descriptor with a foreign-key id = "6", OJB gets the bean for the previous field-id (as it starts counting with "1"). Ricardo. -Mensaje original- De: Ricardo Tercero Lozano [mailto:[EMAIL PROTECTED] Enviado el: lunes, 03 de marzo de 2003 18:24 Para: [EMAIL PROTECTED] Asunto: repository_user.xml, reverse-db and field indexes I found than if list of field descriptors inside a class descriptor in repository_user.xml don't work properly if field indexes begin with "0" (as generated by reverse-db) and reference descriptors are defined for some fields. Key values were loaded right, but some associated beans are loaded and some not. This behavior was found for a table with 4 references to another table (4 types of users of class UserBean). I use OJB 0.9.9. Ricardo. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: repository_user.xml, reverse-db and field indexes
Hi Ricardo, field index are not needed for a while. Please just drop the id="..." attributes. cheers, Thomas Ricardo Tercero Lozano wrote: I found than if list of field descriptors inside a class descriptor in repository_user.xml don't work properly if field indexes begin with "0" (as generated by reverse-db) and reference descriptors are defined for some fields. Key values were loaded right, but some associated beans are loaded and some not. This behavior was found for a table with 4 references to another table (4 types of users of class UserBean). I use OJB 0.9.9. Ricardo. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
repository_user.xml, reverse-db and field indexes
I found than if list of field descriptors inside a class descriptor in repository_user.xml don't work properly if field indexes begin with "0" (as generated by reverse-db) and reference descriptors are defined for some fields. Key values were loaded right, but some associated beans are loaded and some not. This behavior was found for a table with 4 references to another table (4 types of users of class UserBean). I use OJB 0.9.9. Ricardo. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OJB conf files in WEB-INF/classes
http://db.apache.org/ojb/ojb-properties.html [EMAIL PROTECTED] wrote: Hello, As specified in the deployment document, my OJB.properties and repository.xml files are in WEB-INF/classes folder. But OJB doesn't find this files! How could I specify this path in OJB? Thanks Sylvain - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OJB Clobbers Default Values with Null
Thanks for the replies. This would be a VERY nice feature to have. Just to use OJB, I've had to go through and modify tons of tables to take out simple default values and make triggers withs some extra logic in them. I don't want to simply take the columns out of the ojb descriptors because then I wouldn't have them for read in my app! I think some sort of "use-default-value=true" attribute as mentioned below would be a great help. It would be especially helpful if we could also modify that boolean dynamically through code. --- Thomas Mahler <[EMAIL PROTECTED]> wrote: > Hi Shannon, > > Shannon Ewing wrote: > > I think that should be a temp fix until something > better can be done. What > > really is needed is a flag in the repository that > can optionally be added to > > a column definition that indicates not to send > this column on an insert (and > > update too?) if there is no value. > > I agree! I I'm currently thinking of adding support > for such a solution. > It won't be difficult to implement. But as always I > like to design it > elegantly and this needs some inspiration (and even > more transpiration ;-). > > cheers, > Thomas > > >"CF" problem is similar to the one we > > have. Ours deals with OJB putting a value into our > primary key fields on > > insert when the value is auto-generated by the > database (in this case MS SQL > > Server). We could not use the "normal" way OJB > deals with this issue because > > our database does not support the concept of > general sequence key generation > > like Oracle, SAP DB, PostgreSQL, etc. Our fix was > to hack the two classes > > that deal with the generation and population of > insert statements to not > > include that column. Not good but necessary for > us. > > > > So, the best solution that would not only resolve > our issue but also "CF", > > would be to simply be able to flag the column to > not be included in inserts > > if there is no value. > > > > -Original Message- > > From: Mahler Thomas > [mailto:[EMAIL PROTECTED] > > Sent: Friday, February 28, 2003 2:23 AM > > To: 'OJB Users List' > > Subject: RE: OJB Clobbers Default Values with Null > > > > > > Hi again, > > > > > >>Hello, > >> > >>Way back in OJB 0.9.7 I brought this issue up and > I don't > >>think I got much response. I took an OJB hiatus > for a while > >>and now I'm back and have run up against this > problem again. > >>The problem is that when I insert a record, OJB > tries to > >>insert null values into fields that I did not > explicity set > >>in my object. So if I have specified default > values in my > >>database field, which I do quite a bit, those > default default > >>values never get used because the query that OJB > generates is > >>telling the database to explicitly set those > fields to null > >>instead of omitting those fields and letting the > db handle it. > >> > >>I find it really hard to believe that I'm the only > one that > >>has issues with this... but I don't see much > discussion on > >>it. Am I missing something obvious or does > anybody have any > >>good workarounds (besided implementing default > values on the > >>application/bean side) or has it been addressed in > 0.9.9? > > > > > > This is still not addressed in 0.9.9 and later! > > You can avoid writing to db columns by not > providing a field-descriptor for > > the attribute in question. > > > > You could either change an existing > class-descriptor at runtime, to > > add/remove field-descriptors, > > or use different repositories for read and write > phases. > > > > cheers, > > Thomas > > > > > >>Thanks! > >> > >> > >> > >>- > >>Do you Yahoo!? > >>Yahoo! Tax Center - forms, calculators, tips, and > more > >> > > > > > > > > > - > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > +-+ > > > This message may contain confidential and/or > privileged information. If you > > are not the addressee or authorized to receive > this for the addressee, you > > must not use, copy, disclose or take any action > based on this message or any > > information herein. If you have received this > message in error, please > > advise the sender immediately by reply e-mail and > delete this message. > > Thank you for your cooperation. > > > +-+ > > > > > - > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > - > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > __ Do you Yahoo!? Yahoo!
Re: What am I doing wrong? Not able to persist a 1:M relationship. SourceCode included...
Thomas, Thank you. I don't know what we'd do without your little pointers and tips. Everytime I browser through or contact this user list I end up smarter and smarter... Thanks again, Jeff On Monday 03 March 2003 01:57 am, you wrote: > Hi Jeffrey, > > The feature you are looking for is called cascading update. > You store the 1-side object and want all n-side objects to be persisted > as well. > To do this trick slightly patch the collection descriptor: >name="events" > element-class-ref="com.gilbert.Event" > orderby="_id" > sort="DESC" > auto-update="true" > > > > > Please also have a closer look to tutorial3.html, section on cascading > operations. > > cheers, > Thomas > > Jeffrey Gilbert wrote: > > I have the following two class files: > > > > package com.gilbert; > > import java.util.Collection; > > public class Applications { > > private int _id; > > private String name; > > private String description; > > private Collection events; // To hold many event objects > > > > public void set_id(int _id) { this._id = _id; } > > public int get_id() { return _id; } > > public String getName() { return name; } > > public void setName(String name) { this.name = name; } > > public String getDescription() { return description; } > > public void setDescription(String description) { > > this.description=description; > > } > > public Collection getEvents() { return events; } > > public void setEvents(Collection events) { events = events; } > > > > public Applications() { > > } > > } > > > > package com.gilbert; > > public class Event { > > protected int _id; > > protected event; > > protected int application_id; > > > > public void set_id(int _id) { this._id = _id; } > > public int get_id() { return _id; } > > public String getEvent() { return Event; } > > public void setEvent(String event) { this.event = event; } > > public int getApplication_id() { return application_id; } > > public void setApplication_id(int application_id) { > > this.application_id = application_id; > > } > > > > public Event() { > > } > > } > > > > I have the following user defined mappings: > > > > > class="com.gilbert.Event" > > table="Event"> > >> name="_id" > > column="ID" > > jdbc-type="INTEGER" > > primarykey="true" > > autoincrement="true" > > /> > >> name="event" > > column="EVENT" > > jdbc-type="VARCHAR" > > /> > >> name="application_id" > > column="APPLICATION_ID" > > jdbc-type="INTEGER" > > indexed="true" > > /> > > > > > > > > > class="com.gilbert.Applications" > > table="Applications"> > > > name="_id" > > column="ID" > > jdbc-type="INTEGER" > > primarykey="true" > > autoincrement="true" > > /> > >> name="name" > > column="NAME" > > jdbc-type="VARCHAR" > > /> > >> name="description" > > column="DESCRIPTION" > > jdbc-type="VARCHAR" > > /> > > > name="events" > > element-class-ref="com.gilbert.Event" > > orderby="_id" > > sort="DESC"> > > > > > > > > > > Now I use the following code in my program but nothing seems to persist. > > > > //Create new application object. > > Application application = new Application(); > > application.setName("test1"); > > application.setDescription("This is a test"); > > > > //Create new event object. > > Event newEvent = new Event(); > > newEvent.setEvent("test123"); > > > > //Load new event object in vector > > Vector e = new Vector(); > > e.add(newEvent); > > > > //Add Vector that contains event into application object. > > application.setEvents(e); > > > > // now perform persistence operations > > try { > > broker.beginTransaction(); > > broker.store(application); > > broker.commitTransaction(); > > } > > catch (PersistenceBrokerException pbe) > > { > > broker.abortTransaction(); > > } > > > > What am I doing wrong? Do I need to persist the event object before I > > persist the application object? Is my user defined mapping file okay? > > > > Thanks in advance, > > > > Jeff > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional co
OJB conf files in WEB-INF/classes
Hello, As specified in the deployment document, my OJB.properties and repository.xml files are in WEB-INF/classes folder. But OJB doesn't find this files! How could I specify this path in OJB? Thanks Sylvain - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: OJB test failures
Jakob (and Armin and Thomas as well) Thank you very much for working through this! Andy -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Sunday, March 02, 2003 7:02 AM To: OJB Users List Subject: Re: OJB test failures Hi Jakob, great work!! regards, Armin - Original Message - From: "Jakob Braeuchi" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Sunday, March 02, 2003 11:00 AM Subject: Re: OJB test failures > hi thomas, > > field conversion should be ok now. all conversion testcases pass. > i also fixed a minor glitch in collection proxy clear() which makes > MtoNMmapping pass as well. > > jakob > > Thomas Mahler wrote: > > > Hi all, > > > > Jakob Braeuchi wrote: > > > >> hi andrew, > >> > >> i changed Identity to do a convertToSql when called with an object, > >> no conversion takes place when called with pkValues. > >> with this change all conversion test are passed. i have a version > >> where conversion takes place during binding of the variables, but > >> this version fails on the referrer test :( > >> > >> should we drop conversion of pk values completely ? > > > > > > There are several users that use some kind of GUID objects as primary > > key attributes. Those GUID need FieldConversions to be mapped to a > > (e.g.) VARCHAR column. > > So dropping this feature is not an option. > > > > We have to make sure that FieldConversions are properly applied for pk > > fields too. > > > > cheers, > > Thomas > > > >> > >> jakob > >> > >> Andrew Gilbert wrote: > >> > >>> Armin, > >>> > >>> Thank you very much for this! I will build latest and re-test soon. > >>> The bummer is, it would be a major impediment to our use of OJB if > >>> we couldn't convert on pk fields. We use a custom GUID impl for the > >>> pk in many of our BO's and tables. > >>> > >>> Not sure I fully understand yet the Identity change. Sounds like you > >>> are saying internal state was inconsistent? > >>> > >>> > >>> > ## > I think the made changes are correct, because the conversion > was not transparent for the user of the Identity object. I suggest > never use converted (java --> sql) pk fields within Identity > (I don't know if code base is comply with this suggest, > maybe that's the reason for the hassle). > The conversion could be done when it's necessary. > But nevertheless I think there is a nasty bug when using > field conversion with pk fields. > > > >>> > >>> > >>> > >>> > >>> - > >>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>> For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >>> > >> > >> > >> - > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OJB and HSQLDB
Hello, I have a problem with HSQLDB, I use OJB 0.9.8. When I store an object with a primary key, I obtain this exception. Have you an idea ? Exception : DBMS:Hsqldb DRIVER: org.hsqldb.jdbcDriver PROTOCOL: jdbc SUBPROTOCOL: hsqldb DBALIAS: hsql://localhost:9001 USERNAME: sa PASSWORD: EAGER RELEASE: false at org.apache.ojb.broker.util.sequence.SequenceGenerator.getNextSequence(Sequen ceGenerator.java:92) at org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl.getUniqueId(Sequ enceManagerHiLoImpl.java:65) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getUniqueId(Persistence BrokerImpl.java:2272) at org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getUniqueId(Deleg atingPersistenceBroker.java:248) at org.apache.ojb.broker.metadata.ClassDescriptor.getAutoIncrementValue(ClassDe scriptor.java:1082) at org.apache.ojb.broker.metadata.ClassDescriptor.getKeyValuesForObject(ClassDe scriptor.java:931) at org.apache.ojb.broker.metadata.ClassDescriptor.getKeyValues(ClassDescriptor. java:908) at org.apache.ojb.broker.metadata.ClassDescriptor.getKeyValues(ClassDescriptor. java:883) at org.apache.ojb.broker.Identity.(Identity.java:191) ... 21 more Caused by: org.apache.ojb.broker.PersistenceBrokerException: Could not borrow connection from pool - org.apache.ojb.broker.metadata.JdbcConnectionDescriptor: JdbcConnectionDescriptor DBMS:Hsqldb DRIVER: org.hsqldb.jdbcDriver PROTOCOL: jdbc SUBPROTOCOL: hsqldb DBALIAS: hsql://localhost:9001 USERNAME: sa PASSWORD: EAGER RELEASE: false at org.apache.ojb.broker.accesslayer.StatementsForClassImpl.prepareStatement(St atementsForClassImpl.java:245) at org.apache.ojb.broker.accesslayer.StatementsForClassImpl.getPreparedStmt(Sta tementsForClassImpl.java:188) at org.apache.ojb.broker.accesslayer.StatementManager.getPreparedStatement(Stat ementManager.java:632) at org.apache.ojb.broker.accesslayer.JdbcAccess.executeQuery(JdbcAccess.java:24 0) at org.apache.ojb.broker.accesslayer.RsIterator.(RsIterator.java:249) at org.apache.ojb.broker.singlevm.RsIteratorFactoryImpl.createRsIterator(RsIter atorFactoryImpl.java:95) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getRsIteratorFromQuery( PersistenceBrokerImpl.java:2505) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getRsIteratorFromQueryE xtentAware(PersistenceBrokerImpl.java:1719) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getIteratorFromQuery(Pe rsistenceBrokerImpl.java:1599) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Pe rsistenceBrokerImpl.java:1250) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Pe rsistenceBrokerImpl.java:1405) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Pe rsistenceBrokerImpl.java:1431) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Pe rsistenceBrokerImpl.java:1418) at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getObjectByQuery(Persis tenceBrokerImpl.java:1818) at org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getObjectByQuery( DelegatingPersistenceBroker.java:275) at org.apache.ojb.broker.util.sequence.SequenceGenerator.getNextSequence(Sequen ceGenerator.java:57) ... 29 more Caused by: org.apache.ojb.broker.accesslayer.LookupException: Could not borrow connection from pool - org.apache.ojb.broker.metadata.JdbcConnectionDescriptor: JdbcConnectionDescriptor DBMS:Hsqldb DRIVER: org.hsqldb.jdbcDriver PROTOCOL: jdbc SUBPROTOCOL: hsqldb DBALIAS: hsql://localhost:9001 USERNAME: sa PASSWORD: EAGER RELEASE: false at org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl.getConnectionF romPool(ConnectionFactoryPooledImpl.java:69) at org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.lookupConnec tion(ConnectionFactoryAbstractImpl.java:89) at org.apache.ojb.broker.accesslayer.ConnectionManager.getConnection(Connection Manager.java:122) at org.apache.ojb.broker.accesslayer.StatementsForClassImpl.prepareStatement(St atementsForClassImpl.java:240) ... 44 more Caused by: java.util.NoSuchElementException at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPoo l.java:720) at org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl.getConnectionF romPool(ConnectionFactoryPooledImpl.java:65) ... 47 more
getCollectionByQuery and LONGVARCHAR type with oracle thin driver
Hi, Did sommeone succeeded into running getCollectionByQuery() on objects having a LONGVARCHAR field ? I am using Oracle thin driver with OJB 0.9.9 ORA-00997: illegal use of LONG datatype Here is my mapping for ths field : If I comment out the field descriptor for the LONGVARCHAR field, everything works fine. But if uncomment it I get the following exception : ORA-00997: illegal use of LONG datatype when doing a query like : Criteria crit = new Criteria(); crit.addEqualTo("name", "foo"); Query q = QueryFactory.newQuery(Myclass.class, crit, true); Collection c = broker.getCollectionByQuery(q); Is there a known work around for this ? Many thnaks, Thomas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OJB and JDOUserException : Object Exists
Hi all, I have an jdo enabled object that has an primary key id generated by a mysql auto incremented integer. Therefore i use the "org.apache.ojb.broker.util.sequence.SequenceManagerMySQLImpl" SequenceManager. I tried to disable the cache by setting: lFactory.setIgnoreCache( true); lFactory is the PersistenceManagerFactory. Then i executed the following code: (lA1 and lA2 are two valid objects) lManager.currentTransaction().begin(); lManager.makePersistent( lA1); lManager.currentTransaction().commit(); lManager.currentTransaction().begin(); (*) lManager.makePersistent( lA2); lManager.currentTransaction().commit(); the following exeption is throws at (*) : javax.jdo.JDOUserException: Object exists. Instance with the same primary key is already in the PersistenceManager cache. at com.sun.jdori.common.CacheManagerImpl.register(Unknown Source) at com.sun.jdori.common.PersistenceManagerImpl.register(Unknown Source) at com.sun.jdori.common.state.StateManagerImpl.initializeSM(Unknown Source) at com.sun.jdori.common.state.StateManagerImpl.makePersistent(Unknown Source) at com.sun.jdori.common.CacheManagerImpl.makePersistent(Unknown Source) at com.sun.jdori.common.PersistenceManagerImpl.makePersistentInternal(Unknown Source) at com.sun.jdori.common.PersistenceManagerImpl.makePersistent(Unknown Source) at com.sun.jdori.common.PersistenceManagerWrapper.makePersistent(Unknown Source) at axelera.gui.model.messaging.adaptor.AdaptorHome.main(AdaptorHome.java:145) What wrong here? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to use Map type for Collections?
Hi Thomas: I try to use the DMap Implementation. Like this: public class SimpleOrgForMap extends PersistentObject{ private DMap users ; public void addUsers(SimpleUserForMap pUser){ System.out.println("***Add Users For MapCollection."); if (users == null) { users = new DMapImpl(); } this.users.put(pUser.getOID(),pUser); } public DMap getUsers(){ System.out.println("***Get Users For MapCollection."); return this.users; } public void setUsers(DMap pMembers){ this.users = pMembers; } public SimpleOrgForMap() { } } But I don't know how to set 'collection-class' attribute of collection-descriptor element. Must I set the attribute? Thanks. > Hi ½²³Õ¦Ü, > > Why don't you simply use the ODMG DMap Implementation? > This will save you a lot of work! > > Thomas > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multithreading
Hi David, We are well aware that this is not safe in Java. We have only used it when it was not appropriate to construct a singleton in the static initializer. (We are using a lot of configuration stuff and the configuration is sometimes not available when certain factory classes get loaded). Singletons are only used for factories. The worst thing that can happen is that to threads work with two versions of a certain factory. Won't do much harm. So we don't care. cheers, Thomas David McReynolds wrote: Sorry if this has been asked before. I can't seem to get to the archives. In the source code for OJB I have noticed several uses of the Singleton pattern. Mostly, the code is of then form, { private static _instance; getInstance() { if(_instance == null) { _instance = getNewInstance(); } return _instance; } I am puzzled by this idiom because it has been documented as "broken" for the Java memory model with respect to multi-thread applications. http://www.javaworld.com/javaworld/javatips/jw-javatip67-p2.html states, "Using lazy instantiation for a concrete Singleton is not only unnecessary in Java, it's downright dangerous in the context of multithreaded applications." Ref: http://www.javaworld.com/javaworld/javatips/jw-javatip67.html? http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html http://www.javaworld.com/javaworld/jw-05-2001/jw-0525-double.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What am I doing wrong? Not able to persist a 1:M relationship. SourceCode included...
Hi Jeffrey, The feature you are looking for is called cascading update. You store the 1-side object and want all n-side objects to be persisted as well. To do this trick slightly patch the collection descriptor: name="events" element-class-ref="com.gilbert.Event" orderby="_id" sort="DESC" auto-update="true" > Please also have a closer look to tutorial3.html, section on cascading operations. cheers, Thomas Jeffrey Gilbert wrote: I have the following two class files: package com.gilbert; import java.util.Collection; public class Applications { private int _id; private String name; private String description; private Collection events; // To hold many event objects public void set_id(int _id) { this._id = _id; } public int get_id() { return _id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description=description; } public Collection getEvents() { return events; } public void setEvents(Collection events) { events = events; } public Applications() { } } package com.gilbert; public class Event { protected int _id; protected event; protected int application_id; public void set_id(int _id) { this._id = _id; } public int get_id() { return _id; } public String getEvent() { return Event; } public void setEvent(String event) { this.event = event; } public int getApplication_id() { return application_id; } public void setApplication_id(int application_id) { this.application_id = application_id; } public Event() { } } I have the following user defined mappings: primarykey="true" autoincrement="true" /> name="name" column="NAME" jdbc-type="VARCHAR" /> name="description" column="DESCRIPTION" jdbc-type="VARCHAR" /> name="events" element-class-ref="com.gilbert.Event" orderby="_id" sort="DESC"> Now I use the following code in my program but nothing seems to persist. //Create new application object. Application application = new Application(); application.setName("test1"); application.setDescription("This is a test"); //Create new event object. Event newEvent = new Event(); newEvent.setEvent("test123"); //Load new event object in vector Vector e = new Vector(); e.add(newEvent); //Add Vector that contains event into application object. application.setEvents(e); // now perform persistence operations try { broker.beginTransaction(); broker.store(application); broker.commitTransaction(); } catch (PersistenceBrokerException pbe) { broker.abortTransaction(); } What am I doing wrong? Do I need to persist the event object before I persist the application object? Is my user defined mapping file okay? Thanks in advance, Jeff - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to use Map type for Collections?
Hi ½²³Õ¦Ü, Why don't you simply use the ODMG DMap Implementation? This will save you a lot of work! Thomas ½²³Õ¦Ü wrote: > Hi! > I try to use user-defined collections to implement 1:n associations. I have read > tutorial3.html, and > code a sample program almost like as ArticleCollection class. Its name > MapCollection1.class : > <---> > package businessclass; > > import org.apache.ojb.broker.ManageableCollection; > import java.util.*; > > public class MapCollection1 extends HashMap implements ManageableCollection, > { > > public void add(SimpleUserForMap pMember) > { > this.put(pMember.getOID(),pMember); > } > > /** > * add a single Object to the Collection. This method is > * used during reading Collection elements from the > * database. Thus it is is save to cast anObject > * to the underlying element type of the collection. > */ > public void ojbAdd(java.lang.Object anObject) > { > if (anObject instanceof SimpleUserForMap){ > add((SimpleUserForMap) anObject); > } > } > > /** > * adds a Collection to this collection. Used in reading > * Extents from the Database. > * Thus it is save to cast otherCollection to this.getClass(). > */ > public void ojbAddAll( > ManageableCollection otherCollection) > { > this.putAll( > ((MapCollection1) otherCollection); > } > > /** > * returns an Iterator over all elements in the collection. > * Used during store and delete Operations. > */ > public java.util.Iterator ojbIterator() > { > return this.values().iterator(); > } > } > <---> > > Then I declare two objects SimpleUserForMap and SimpleOrgForMap. > SimpleOrgForMap has a MapCollection1 type property named "users" .Its elements are > SimpleUserForMap object. > They are: > > <---> > package businessclass; > > import persistentlayertest.PersistentObject; > > public class SimpleUserForMap extends PersistentObject{ > /** name*/ > private String name = null; > > public String getName() { > return this.name; > } > > public void setName(String pNewValue) { > this.name = pNewValue; > } > > private String organizationOID = ""; > > public String getOrganizationOID(){ > return this.organizationOID; > } > public void setOrganizationOID(String pNewValue){ > > this.organizationOID = pNewValue; > } > > private SimpleOrgForMap organization = null; > > public SimpleOrgForMap getOrganization(){ > return this.organization; > } > > public void setOrganization(SimpleOrgForMap pNewValue){ > this.organization = pNewValue; > setOrganizationOID(pNewValue.getOID()); > } > > public SimpleUserForMap() { > } > } > <---> > package businessclass; > > import persistentlayertest.PersistentObject; > import java.util.Collection; > import java.util.Vector; > import java.util.Map; > import java.util.HashMap; > import org.odmg.DMap; > import org.apache.ojb.odmg.collections.DMapImpl; > > public class SimpleOrgForMap extends PersistentObject{ > private MapCollection1 users ; > > public void addUsers(SimpleUserForMap pUser){ > System.out.println("***Add Users For MapCollection."); > if (users == null) > { > users = new MapCollection1(); > } > this.users.add(pUser); > } > public MapCollection1 getUsers(){ > System.out.println("***Get Users For MapCollection."); > return this.users; > } > > public void setUsers(MapCollection1 pMembers){ > this.users = pMembers; > } > public SimpleOrgForMap() { > } > } > <---> > > The repository is: > <---> > > > name="OID" > column="OID" > jdbc-type="CHAR" > primarykey="true" > /> > > name="users" > element-class-ref="businessclass.SimpleUserForMap" > collection-class="businessclass.MapCollection1" > > > > > > > > name="OID" > column="OID" > jdbc-type="CHAR" > primarykey="true" > /> > name="name" > column="name" > jdbc-type="VARCHAR" > /> > name="organizationOID" > column="organizationOID" > jd
Re: PersistenceBrokerAware and current transaction
Hi Bill, - Original Message - From: "V.B. Skrypnyk" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Monday, March 03, 2003 7:28 AM Subject: PersistenceBrokerAware and current transaction > Hi, > > I am trying to implement my own cascading deletes of sorts through > PersistenceBrokerAware beforeDelete callback. Strangely (?) I can't seem to > get the current transaction by calling: > > OJB.getInstance().currentTransaction() OJB isn't a singleton, thus when calling OJB.getInstance() you will get a new Implementation instance. regards, Armin > > so that I can add the affected dependent objects to it (so it may be saved). > I get the following exception: > > [java] org.odmg.DatabaseClosedException: Database is NULL, must have a DB > in order to create a transaction > > Is this correct behaviour? It's the same thread, shouldn't I be able to > retrieve the current transaction? > > Cheers, > --Bill. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: multithreading
Hi David, you are right, it's a vice implement singletons that way. Add this on my my todo-list (hope to get rid of this before 1.0). regards, Armin - Original Message - From: "David McReynolds" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 03, 2003 5:55 AM Subject: multithreading > Sorry if this has been asked before. I can't seem to get to the archives. > > In the source code for OJB I have noticed several uses of the Singleton > pattern. Mostly, the code is of then form, > > { > > private static _instance; > > getInstance() { > if(_instance == null) { > _instance = getNewInstance(); > } > > return _instance; > } > > I am puzzled by this idiom because it has been documented as "broken" for > the Java memory model with respect to multi-thread applications. > > http://www.javaworld.com/javaworld/javatips/jw-javatip67-p2.html states, > "Using lazy instantiation for a concrete Singleton is not only unnecessary > in Java, it's downright dangerous in the context of multithreaded > applications." > > Ref: > http://www.javaworld.com/javaworld/javatips/jw-javatip67.html? > http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html > http://www.javaworld.com/javaworld/jw-05-2001/jw-0525-double.html > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]