OJB 1.0.4 ODMG implementation
Hi, I just played around with ODMG and tried to execute the following OQL: "select x from myClass where attribute is not in ( select distinct y.id from anotherClass )" During OQLQuery q.create(oql) OJB writes a message to stderr with "unexpected token (select)" and throws an Exception: java.lang.NoSuchMethodError: org.apache.ojb.odmg.oql.OQLParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V at org.apache.ojb.odmg.oql.OQLParser.argList(Unknown Source) at org.apache.ojb.odmg.oql.OQLParser.inExpr(Unknown Source) at org.apache.ojb.odmg.oql.OQLParser.quantifierExpr(Unknown Source) at org.apache.ojb.odmg.oql.OQLParser.andExpr(Unknown Source) at org.apache.ojb.odmg.oql.OQLParser.orExpr(Unknown Source) at org.apache.ojb.odmg.oql.OQLParser.whereClause(Unknown Source) at org.apache.ojb.odmg.oql.OQLParser.selectQuery(Unknown Source) at org.apache.ojb.odmg.oql.OQLParser.buildQuery(Unknown Source) at org.apache.ojb.odmg.oql.OQLQueryImpl.create(Unknown Source) at org.apache.ojb.odmg.oql.OQLQueryImpl.create(Unknown Source) Am I right in assuming, that OJB does not support such subqueries? Retrieving the Collection from the subquery and then explicitely generating an not in expression does the job, however the subquery result could be quite large. Best regards Bernd Längerich
AW: OJB Development Activity
Armin wrote: > Sorry for the delay. I took a few "sabbatical weeks" from OJB > to spend > more time with my (newborn) daughter and currently I have > some problems > with my eyes, which makes it difficult to work on OJB. Armin, congrats to your newborn family member, all the best to all of your family and take care of your eyes. Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: what's with OJB Project?
Armin Waibel writes: > Well, it depends on the community. Currently it seems that only a few > people are able to (interested in) spend time for OJB. I will > continue > my work on OJB. I would like to say thank you for your efforts. I would also like to offer my best to support OJB in future but I have to check with the company policy first. Maybe I can contribute to the project, as I already made some efforts to "enhance" OJB for our companies purposes. Best regards Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: Question regarding metadata handling in ojb 1.0.4
Armin Waibel wrote: > Since ClassB is an "extent" of ClassA the merge of the repositories > isn't enough. The merge method is intended to merge/add new classes > without dependencies to already registered classes. > You could try to use the ClassDescriptor.addExtent(...) method to > register a new "extent": > > MetadataManager mm = MetadataManager.getInstance(); > DescriptorRepository dr = > mm.readDescriptorRepository("my/additional/plugin_repository.xml"); > mm.mergeDescriptorRepository(dr); > //then lookup the repository > DescriptorRepository repo = mm.getRepository(); > // lookup the CLD of ClassA > ClassDescriptor cldA = repo.getDescriptorFor(ClassA.class); > // add the new extent > cldA.addExtent(ClassB); > > I never tried this ;-) Heureka, it works! Thanks Armin. I am now a big step further. As all informations regarding the registration of the extent classes could be in the additional repository file to merge, it should be possible to add these lines of code to ojb, but I am unaware if this will break other things. Next 3 weeks are holiday, so maybe I will have a look inside ojbs sourcecode. Best regards Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question regarding metadata handling in ojb 1.0.4
Hi, I am trying to find some information regarding metadata merging in the following scenario: We have a base application with some classes, db tables and a repository_user.xml that describes the mapping. Lets say we have a base class BasePersistentClassA and some classes that are based which are included as extent classes in the xml file. This application is running. No we develop an optional plugin with a class PluginPersistentClassB that is based on BasePersistentClassA of the application. I can now write an additional repository.xml and merge it with: MetadataManager mm = MetadataManager.getInstance(); DescriptorRepository dr = mm.readDescriptorRepository("my/additional/plugin_repository.xml"); mm.mergeDescriptorRepository(dr); However I am failing to get the correct contents regarding the extent-class definitions of the base class. I tried to include the following to plugin_repository.xml: ... Something is strange, as the following code fragment does not delete anything at the first broker.deleteByQuery() and fails at the second one: Criteria crit = new Criteria(); crit.addNotEqualTo("ojbConcreteClass",BaseApplicationClassX.class.getName()); Query q = QueryFactory.newQuery(Transaction.class,crit); broker.deleteByQuery(q); // SELECT DISTINCT ACC_TAID FROM ACC_TA ReportQueryByCriteria subquery = new ReportQueryByCriteria(BasePersistentClassA .class,null); subquery.setAttributes(new String[] { "id" }); subquery.setDistinct(true); Criteria crit = new Criteria(); crit.addNotIn("externalID",subquery); Query q = QueryFactory.newQuery(Another.class,crit); broker.deleteByQuery(q); It seems that the extent definitions from dr are not merged and even corrupt the existing definitions of the application, as trying to access all classes from the database results in an NullPointerException: 2007.07.26 17:40:33,375 [0/ServiceRequestDispatcher-P=3/T=7-running:1/1/1] INFO cleardb: start java.lang.NullPointerException at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement$TableAlias.hashCode(Unknown Source) at java.util.HashMap.hash(Unknown Source) at java.util.HashMap.put(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.splitCriteria(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlSelectStatement.(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.getSubQuerySQL(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSubQuery(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendParameter(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendInCriteria(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendCriteria(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendSQLClause(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.asSQLStatement(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendClause(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.appendWhereClause(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlDeleteByQuery.buildStatement(Unknown Source) at org.apache.ojb.broker.accesslayer.sql.SqlQueryStatement.getStatement(Unknown Source) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeDelete(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.deleteByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.deleteByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.deleteByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.deleteByQuery(Unknown Source) [...] If I include the table="" part, I get the NullPointerException at: so it seems that the existing class definition is not merged with the additional data but overwritten. Ommiting the extent-class-definitions from the additional xml file, I can access all classes of the base application, but not of the plugin. As we have several plugins, we dont want any dependencies from the base application to the plugins. Any hints are appreciated. Best regards Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: SequenceManagerHighLowImpl
Bernd "Ingrid" Laengerich wrote: > OK, I played around a little bit and overwrote the afterStore > method (empty implementation, however it never gets called!? > What am I missing? I placed a breakpoint in my code, but it > never reaches it. OK, searching around a little bit, I found in JdbcAccessImpl: protected void assignAutoincrementIdentityColumns(ClassDescriptor cld, Object target) throws SequenceManagerException { // if database Identity Columns are used, query the id from database // other SequenceManager implementations will ignore this call if(cld.useIdentityColumnField()) broker.serviceSequenceManager().afterStore(this, cld, target); } This seems to be the only place where this method is called directly, except it is called via reflection. I will just write a refresh method, as the locations are countable where such inserts of alien data rows are used. Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: SequenceManagerHighLowImpl
Hi Armin, thanks again for your response. Armin wrote: > Längerich wrote: > > Is it sufficient/possible to overwrite the afterStore() > method of the > > sequence manager? > > Yep it's possible. Assume you want to lookup the > HLSequence-object for > the current used (fixed) field and invalidate the current > used PK value > or declare that the next sequence value has to greater than this to > avoid duplicate PK values. Think this should work (except if an > concurrent thread request the next value before the current > thread can > invalidate it). OK, I played around a little bit and overwrote the afterStore method (empty implementation, however it never gets called!? What am I missing? I placed a breakpoint in my code, but it never reaches it. My code is somhehow simple, writeing a line to stderr to see if anything happens at all. If the code is of any interest: http://rafb.net/p/hknTM276.html Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SequenceManagerHighLowImpl
Hi, I have some problems with OJB (PB-API) and the sequence manager. I derived a new sequence manager from the shipped HighLowImpl, that checks for every grab size with SequenceManagerHelper.getMaxForExtent() for the max id of the field. This works fine with data added externally, but I have a situation where the original HighLowImpl and my version fails: Given the scenario, where the application has created an instance of the sequence manager for the PK field and inserts some data with fixed field contents from another source, with a pk field contents of any value in the current range of prefetched ids (grabsize), I get a dup key constraints error when the sequence manager reaches these rows. The background is, that we store each row to a primary data base and a backup data base. Whenever the computer with the primary data base crashes, it can be restored from an automatic backup, but this will be up to several hours old, so we recover the missing data from the backup data base and store them to the primary db (using OJB PB-Api). Is there any way of forcing the sequence manager to be recreated? At the moment I have a workaround with fetching grabSize ids with Identity oid = broker.serviceIdentity().buildIdentity(Object newPersistentObject); Is it sufficient/possible to overwrite the afterStore() method of the sequence manager? Best regards Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: Problem/misunderstanding with ObjectCache, multiple databases and ObjectModification, 1.0.4
Hi Armin, thank you for your fast response. Armin Waibel writes: > You are right, OJB find the object in the cache (because you operate > with the same objects on different DB's using a shared cache) and > indicate to update the object instead of insert. > > Do you really need a shared cache on your "backup" broker? I would > recommend to use a "per broker cache" (for backup-broker) > http://db.apache.org/ojb/docu/guides/objectcache.html#ObjectCachePerBrokerImpl >Then OJB will not find the object in the cache of backup-broker and >perform a DB select. Okay, thanks for the clarification. I was not aware, that the ObjectCacheDefaultImpl is shared amongst all connections as I declared the cache at connection level, but reading the words "global" and "static Map" in the documentation really helps :-). As we create a broker on demand and discard it after single use, the per broker cache is not helpful at all, so I will use ObjectCacheEmptyImpl. Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem/misunderstanding with ObjectCache, multiple databases and ObjectModification, 1.0.4
Hi, I have some problems understanding (and using) the concept of the cache when using multiple databases and determining the object modification level at the store method. Assume we have two databases A and B with one being the default and one being the backup database. Both connections are configured using the cache: Given the following code sequence with empty databases, I have some problems: AnObject someObject = new AnObject(); [...] PersistenceBroker defaultBroker = PersistenceBrokerFactory.defaultPersistenceBroker(); defaultbroker.store(someObject); // resulting in an INSERT to the default DB [...] defaultBroker.store(someObject); // resulting in an UPDATE to the default DB PersistenceBroker backupBroker = PersistenceBrokerFactory.createPersistenceBroker(new PBKey("backup")); backupBroker.store(someObject); // resulting in an UPDATE to the backup DB, which fails as there is no such row in the DB As far as I understand the code from PersistanceBrokerImpl, it should query the cache and/or the DB: /* if PK values are set, lookup cache or db to see whether object needs insert or update */ if (!insert) { insert = objectCache.lookup(oid) == null && !serviceBrokerHelper().doesExist(cld, oid, obj); } store(obj, oid, cld, insert); The insert should be false, as the PK fields are not null, and the objectCache for the backupBroker should give null. I traced with P6Spy, but I can't detect a SELECT to determine the existence of the row, so I assume the objectCache.lookup(oid) returns true. Any hints? Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Merging data from two data bases
"Ingrid" Längerich writes: > The code I tried is like this: OK, I found out that Iterator it = masterbroker.getReportQueryIteratorByQuery(masterquery); Collection taids = new Vector(); while (it.hasNext()) { Object obj = ((Object[])it.next())[0]; taids.add(obj); } is working. Is there a better way to achieve the same result? Bernd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Merging data from two data bases
Hi, given is a master data base and a backup data base. All entries are stored to the master data base and to the backup. If anything fails (computer crashes) at startup I want to merge the data from the backup with the data of the master database. The code I tried is like this: masterbroker = PersistenceBrokerFactory.defaultPersistenceBroker(); ReportQueryByCriteria masterquery = QueryFactory.newReportQuery(Transaction.class,new Criteria()); masterquery.setAttributes(new String[] {"id"}); masterquery.setDistinct(true); Collection taids = masterbroker.getCollectionByQuery(masterquery); log.info("Master DB has "+taids.size()+" transactions"); Criteria crit = new Criteria(); crit.addNotIn("id",taids); backupbroker = PersistenceBrokerFactory.createPersistenceBroker(new PBKey(jcdalias)); Query query = QueryFactory.newQuery(Transaction.class,crit); Collection tas = backupbroker.getCollectionByQuery(query); if (tas.size()>0) { log.warn("Backup DB has "+tas.size()+" transactions not stored in the master DB"); } for (Iterator iter = tas.iterator(); iter.hasNext();) ... The problem is when I reach the line Collection taids = masterbroker.getCollectionByQuery(masterquery); I get a strange exception: org.apache.ojb.broker.PersistenceBrokerException: Unexpected error while try to read 'ojbConcretClass' field from result set using column name CLASS_NAME main class was de.actosoft.accept.process.Transaction at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.extractOjbConcreteClass(Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectArrayFrom(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source) at org.apache.ojb.broker.accesslayer.ChainingIterator.next(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery(Unknown Source) [...] The strange thing is the 'ojbConcretClass' where the repository_user.xml says: [...] The SQL generated and executed looks fine (except that it contains redundant where clause parts): 1165921756841|-1||resultset|SELECT DISTINCT A0.ACC_TAID FROM ACC_TA A0 WHERE ( A0.CLASS_NAME IN (...)) AND (A0.CLASS_NAME IN (...)|ACC_TAID = 1 If I remove the line masterquery.setAttributes(new String[] {"id"}); everything works fine but I get all object instances instead of just a collection of ids. Any hints? Is there any way to do what I want? I used db-ojb-1.0.4.jar and MS-SQL 2000. Mit freundlichen Grüßen i.A. Bernd Längerich Softwareentwicklung act'o-soft GmbH Payment Systems World Wide Business Center Habichtstrasse 41 22305 Hamburg Phone: 00 49 40 61135432 Fax: 00 49 40 61135429 Mobile: - eMail: [EMAIL PROTECTED] www.actosoft-payment-systems.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
1.03 PB-API broker.deleteBy() and QueryByCriteria problem
Hi, a criteria with path expressions like in the OJB queries reference guide example (http://db.apache.org/ojb/docu/guides/query.html#Query+by+Criteria) does not work for me with broker.deleteByQuery(q). Using Microsoft SQL Server, the resulting statement of the example Criteria crit = new Criteria(); crit.addEqualTo("productGroup.groupName", "Liquors"); Query q = QueryFactory.newQuery(Article.class, crit); Collection results = broker.getCollectionByQuery(q); results in the correct JOIN in the SELECT statement, but using: broker.deleteByQuery(q); results in a statement, where the path expression ist not expanded but the statement executed is something like DELETE FROM Artikel WHERE KategorieName='Liquors' but I expected something like DELETE FROM Artikel WHERE Kategorie_Nr IN (SELECT Kategorie_Nr FROM Kategorien WHERE KategorieName='Liquors') Any hints? Mit freundlichen Grüßen i.A. Bernd Längerich -- www.actosoft.de - Key Solutions for Retail - ac news Marktgeflüster ac news Marktgeflüster Smarter Fashion - neue Geschäftsmodelle und integrierte Lösungen für die Fashion Value Chain +++ Das Seminar am 12.09.2006 im Zeughaus Neuss +++ Weitere Infos unter: www.microsoft.com/germany/events/fashion __ act'o-soft GmbH Informationssysteme * Enger Str. 12 * D-33824 Werther (Westf.) Tel.: +49-5203-9744-40 * Fax: +49-5203-9744-41 * eMail: [EMAIL PROTECTED] Sitz der Gesellschaft ist Werther (Westf.) * Amtsgericht Gütersloh * HRB 5242 Geschäftsführer: Christian Malachowski * Dipl.-Ing. Michael Schramm ___ ___ This e-mail including any attachments may contain information that is legally privileged and confidential. It constitutes non-public information intended to be conveyed only to the designated recipient(s). If you are not an intended recipient please delete this e-mail and any attachments and do not read, copy, or retransmit it and please notify act'o-soft GmbH by return mail, e-mail or at +49/5203/974440. The unauthorized use, dissemination, distribution or reproduction of this e-mail, including attachments, is prohibited and may be unlawful. ___ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]