problem using anonymous fields...
Folks, Why java.org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Clas sDescriptor cld, Identity oid) doesn't resolve references? Here is a javadoc excerpt: /** * performs a primary key lookup operation against RDBMS and materializes * an object from the resulting row. Only skalar attributes are filled from * the row, references are not resolved. * @param oid contains the primary key info. * @param cld ClassDescriptor providing mapping information. * @return the materialized object, null if no matching row was found or if * any error occured. */ public Object materializeObject(ClassDescriptor cld, Identity oid) throws PersistenceBrokerException { It created problems when I am using anonymous fields. retVal = broker.getObjectByQuery( new QueryByIdentity(example)); returns null, but the record exists! Is there any workaround to keep using anonymous keys and be able to find object by example? Here is a class I am testing : class-descriptor class=beans.Tracking table=SDRTII field-descriptor name=diverseSuppNum column=DIVSUP# jdbc-type=DECIMAL primarykey=true access=anonymous / field-descriptor name=amount column=AMOUNT jdbc-type=DECIMAL / reference-descriptor name=diverseSupplier class-ref=beans.DiverseSupplier foreignkey field-ref=diverseSuppNum / /reference-descriptor /class-descriptor Thank you, -Sergey
Re: Problem with char mapping
Armin Thnak you for your elements. But what is the good solutions when I want to use char size 1 (as substitute of Boolean) and Long ? Andre Le Mercredi 21 Janvier 2004 18:12, Armin Waibel a écrit : Hi again, A Leg wrote: Armin I use db-ojb-1.0.rc4. ok, in final 1.0 BOOLEAN datatype should be supported (but there is currently no test case for that, so no guarantee ;-)) And it seem that the problem is similar for numeric where ojb accept only BigDecimal : [PersistentField] ERROR: while set field: object class[ org.compiere.mfg_scm.dbManager.MGT_Request target field: jobNum target field type: class java.lang.Long object value class: java.math.BigDecimal object value: 1] null I made the test with Long and with int, problem is the same if in database the column is Numeric. yep, OJB does the mapping as specified by sun and NUMERIC is mapped to BigDecimal. regards, Armin Andre Armin Waibel wrote: Hi Andre, A Leg wrote: Hi every body I have a variable name hold declare as char in code. (It was first a Boolean but I change as Boolean is not supported) Which version of OJB do you use? mapping is : field-descriptor name=hold column=HOLD jdbc-type=CHAR/ and in postgres the column is bpchar (size 1) I get the following errors (see belo). I have to declare it as String in my java code to get it work. But I would like to declare it as char. Does any body able to explain that and to give a solution ? Think you need a field-conversion, because sun's mapping convention say that CHAR was mapped to String See http://db.apache.org/ojb/jdbc-types.html Write your own String2CharFieldConversion. You can find many examples in source code (..broker.accesslayer.conversion package) regards, Armin Best regards Andre Legendre [PersistentField] ERROR: while set field: object class[ org.compiere.mfg_scm.dbManager.MGB_Request target field: hold target field type: char object value class: java.lang.String object value: N] null java.lang.IllegalArgumentException at sun.reflect.UnsafeCharacterFieldAccessorImpl.set(UnsafeCharacterFieldAc cessorImpl.java:68) at java.lang.reflect.Field.set(Field.java:519) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessI mpl.doSet(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.AbstractPersistentField.set( Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflect ion(Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(U nknown Source) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Unkn own Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Un known Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unkno wn Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery (Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery (Unknown Source) at org.compiere.mfg_scm.dbManager.TaskConsumer.showJob(Unknown Source) at org.compiere.mfg_scm.dbManager.DbManagerImpl.showJob(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja va:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso rImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) at sun.rmi.transport.Transport$1.run(Transport.java:148) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:144) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460 ) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.j ava:701) at java.lang.Thread.run(Thread.java:534) [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: PersistenceBrokerException during the execution of materializeObject: Error setting field:hold in object:org.compiere.mfg_scm.dbManager.MGB_Request Error setting field:hold in object:org.compiere.mfg_scm.dbManager.MGB_Request java.lang.IllegalArgumentException at sun.reflect.UnsafeCharacterFieldAccessorImpl.set(UnsafeCharacterFieldAc cessorImpl.java:68) at java.lang.reflect.Field.set(Field.java:519) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessI mpl.doSet(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.AbstractPersistentField.set( Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflect ion(Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(U
JDO and associations (1:n, m:n)
Hi there, I am trying to make a miniframework with OJB, based on its JDO plugin, so has to have business classes being persistent (almost transparently) and having a small application letting the user play with those persistent classes while viewing the state of the DB. (To be clear I try to have a very simple code for pedagogical purpose : this is like tutorial5 except that the class isn't Product but a set of classes generated from an UML diagram). All the basical operations work well but one : I can list, delete, insert objects but I cannot edit them... More precisely I can't edit them when they have references to other persistent objects. How do I proceed to edit one object ? I tried many ways :) First, my idea was to ask the user the id of the object (or everything which let me identify the one he wants), to get it from the database, and to modify a copy of it. Then when this is done, I begin a transaction, copy all the fields from the up-to-date copy to the original persistent instance (even the unmodified fiels) and commit. The problem is : the instance itself is updated correctly but the references are attempted to be reinserted automatically (even if unmodified) causing the database to reject it. As a matter of fact, those references have already been inserted so inserted them again is impossible : they share the same primary key (id). The second idea was to simply delete and then insert the copy after giving it the id of the deleted object. Here I got a JDOUserException for trying to insert an object with a key that already exist in the Persistence Manager cache... (does it means that JDO has got its own cache ? is this cache unable to see that the object was deleted just before ?) Then, I tried the tutorial-like way : that is to say to begin a transaction, get the object after getting the id from the user, let the user do what he wants with its fields and commit. This time, I got the same error as in the first procedure but quicker (so, is it a progress ? ;) ) : in fact, when I reach the commit, the first thing that happen is that my persistent layer wants to insert the references that my instance has, but as ever, because they already are in the datastore, it is impossible... So what ? Give up with editing what I stored and simply show how to insert and delete ? :) Thank you in advance. -- Hubert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Do I need to create reference objects when storing object?
Please help! In the previous versions of OJB it wasnt necessary to create reference object when storing object that has reference but when I try the same thing with OJB 1.0 RC5 the FK fields are set by OJB to null. Is creating the reference object the right thing to do or is there some way to disable this ojb functionality? Thank, Jure - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: deploy OJB with web application
Hi, ZZZ Liu wrote: I am using OJB rc5. Everything is fine when I use it for stand alone program. But when I try to use it in a web application (applciation server is resin 2.1.10), I got following error. From the log, we can see that there is a NullPointerException at org.apache.ojb.broker.metadata.RepositoryXmlHandler.getIsoLevel(Unknown Source) and from the debug message we can see that isolation-level: null. hmm, think something wrong with your file:/D:/gsnx/builds/hourly/dist/gsnx/conf/repository.xml file. Should be something like that: descriptor-repository version=1.0 isolation-level=read-uncommitted proxy-prefetching-limit=50 !-- include all used database connections -- database; !-- include ojb internal mappings here -- internal; !-- include user defined mappings here -- user; /descriptor-repository regards, Armin If I manually add isolation-level attribute to each class descriptor element in repository_internal.xml and all included repository_user.xml's, then it works. I don't think there is any document saying that we need to change repository_internal.xml. I am wondering whether anybody has ever had the same problem and what's the real cause and the soultion for it. Thanks in advance. Zhe === 84938 DEBUG [tcpConnection-9003-0] util.RequestUtils - Get module name for path /core/domain/party/partySearchReport.jsp 84938 DEBUG [tcpConnection-9003-0] util.RequestUtils - Module name found: default 84953 DEBUG [tcpConnection-9003-0] tiles.InsertTag - insert page='/core/fwk/mainLayout.jsp'. 88953 INFO [tcpConnection-9003-0] util.PropertyMessageResources - Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true [org.apache.ojb.broker.metadata.RepositoryPersistor] INFO: OJB Descriptor Repository: file:/D:/gsnx/builds/hourly/dist/gsnx/conf/repository.xml [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: startDoc [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: proxy-prefetching-limit: null [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: descriptor-repository [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: documentation [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:class-descriptor [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: isolation-level: null 89719 DEBUG [tcpConnection-9003-0] tiles.InsertTag - [ServletException in:/core/fwk/mainLayout.jsp] null' java.lang.ExceptionInInitializerError at org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.getDefaultKey(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.defaultPersistenceBroker(Unknown Source) at org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker(Unknown Source) at com.gsnx.core.server.persistence.ojb.OjbPersistenceManager.init(OjbPersistenceManager.java) at com.gsnx.core.server.persistence.PersistenceManagerFactory.getPersistenceManager(PersistenceManagerFactory.java) at com.gsnx.core.server.util.lang.TranslationUtil.cacheTranslation(TranslationUtil.java) at com.gsnx.core.server.util.lang.TranslationUtil.getTranslation(TranslationUtil.java) at com.gsnx.core.server.util.lang.TranslationUtil.message(TranslationUtil.java) at com.gsnx.core.server.util.lang.TranslationUtil.message(TranslationUtil.java) at com.gsnx.core.webui.fwk.util.HtmlUtil.resolveLabel(HtmlUtil.java) at _core._fwk._mainlayout__jsp._jspService(_mainlayout__jsp.java:73) at com.caucho.jsp.JavaPage.service(JavaPage.java:75) at com.caucho.jsp.Page.subservice(Page.java:506) at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182) at com.caucho.server.http.Invocation.service(Invocation.java:315) at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135) at com.caucho.server.http.QRequestDispatcher.include(QRequestDispatcher.java:362) at com.caucho.server.http.QRequestDispatcher.include(QRequestDispatcher.java:274) at com.caucho.jsp.QPageContext.include(QPageContext.java:547) at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:137) at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:177) at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756) at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881) at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473) at _core._domain._party._partysearchreport__jsp._jspService(_partysearchreport__jsp.java:82) at com.caucho.jsp.JavaPage.service(JavaPage.java:75) at com.caucho.jsp.Page.subservice(Page.java:506) at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182) at
RE: Problem with char mapping
Andre Write a char to boolean conversion class. See http://db.apache.org/ojb/jdbc-types.html for details. Wally -Original Message- From: André Charles Legendre [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 10:36 AM To: OJB Users List Subject: Re: Problem with char mapping Armin Thnak you for your elements. But what is the good solutions when I want to use char size 1 (as substitute of Boolean) and Long ? Andre Le Mercredi 21 Janvier 2004 18:12, Armin Waibel a écrit : Hi again, A Leg wrote: Armin I use db-ojb-1.0.rc4. ok, in final 1.0 BOOLEAN datatype should be supported (but there is currently no test case for that, so no guarantee ;-)) And it seem that the problem is similar for numeric where ojb accept only BigDecimal : [PersistentField] ERROR: while set field: object class[ org.compiere.mfg_scm.dbManager.MGT_Request target field: jobNum target field type: class java.lang.Long object value class: java.math.BigDecimal object value: 1] null I made the test with Long and with int, problem is the same if in database the column is Numeric. yep, OJB does the mapping as specified by sun and NUMERIC is mapped to BigDecimal. regards, Armin Andre Armin Waibel wrote: Hi Andre, A Leg wrote: Hi every body I have a variable name hold declare as char in code. (It was first a Boolean but I change as Boolean is not supported) Which version of OJB do you use? mapping is : field-descriptor name=hold column=HOLD jdbc-type=CHAR/ and in postgres the column is bpchar (size 1) I get the following errors (see belo). I have to declare it as String in my java code to get it work. But I would like to declare it as char. Does any body able to explain that and to give a solution ? Think you need a field-conversion, because sun's mapping convention say that CHAR was mapped to String See http://db.apache.org/ojb/jdbc-types.html Write your own String2CharFieldConversion. You can find many examples in source code (..broker.accesslayer.conversion package) regards, Armin Best regards Andre Legendre [PersistentField] ERROR: while set field: object class[ org.compiere.mfg_scm.dbManager.MGB_Request target field: hold target field type: char object value class: java.lang.String object value: N] null java.lang.IllegalArgumentException at sun.reflect.UnsafeCharacterFieldAccessorImpl.set(UnsafeCharacterFie ldAc cessorImpl.java:68) at java.lang.reflect.Field.set(Field.java:519) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAcc essI mpl.doSet(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.AbstractPersistentField.set( Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflect ion(Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(U nknown Source) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Unkn own Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Un known Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unkno wn Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery (Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery (Unknown Source) at org.compiere.mfg_scm.dbManager.TaskConsumer.showJob(Unknown Source) at org.compiere.mfg_scm.dbManager.DbManagerImpl.showJob(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja va:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc esso rImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) at sun.rmi.transport.Transport$1.run(Transport.java:148) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:144) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460 ) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.j ava:701) at java.lang.Thread.run(Thread.java:534) [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: PersistenceBrokerException during the execution of materializeObject: Error setting field:hold in object:org.compiere.mfg_scm.dbManager.MGB_Request Error setting field:hold in object:org.compiere.mfg_scm.dbManager.MGB_Request java.lang.IllegalArgumentException at sun.reflect.UnsafeCharacterFieldAccessorImpl.set(UnsafeCharacterFie ldAc cessorImpl.java:68) at java.lang.reflect.Field.set(Field.java:519) at
Problem with super
I keep getting the following error: Can't find member super in com.cci.model.pharma.impl.AOMObjectImpl The repository XML looks like this: !-- Mapping for Class com.cci.model.pharma.impl.AOMObjectImpl -- class-descriptor class=com.cci.model.pharma.impl.AOMObjectImpl table=AOMObject field-descriptor name=id column=id jdbc-type=VARCHAR primarykey=true access=readwrite / field-descriptor name=aOMPropertyContainer_id column=aOMPropertyContainer_id jdbc-type=VARCHAR access=anonymous / reference-descriptor name=aOMPropertyContainer class-ref=com.cci.model.pharma.impl.AOMPropertyContainerImpl refresh=true foreignkey field-ref=aOMPropertyContainer_id/ /reference-descriptor reference-descriptor name=super class-ref=com.cci.model.pharma.impl.AOMElementImpl refresh=true foreignkey field-ref=id/ /reference-descriptor /class-descriptor foreignkey field-ref=id/ /reference-descriptor /class-descriptor !-- Mapping for Class org.apache.ojb.odmg.collections.DListImpl_2 -- class-descriptor class=org.apache.ojb.odmg.collections.DListImpl_2 table=OJB_DLIST field-descriptor name=id column=ID jdbc-type=INTEGER primarykey=true autoincrement=true access=readwrite / field-descriptor name=size column=SIZE_ jdbc-type=INTEGER access=readwrite / collection-descriptor name=elements element-class-ref=org.apache.ojb.odmg.collections.DListEntry_2 inverse-foreignkey field-ref=dlistId/ /collection-descriptor /class-descriptor !-- Mapping for Class com.cci.model.pharma.impl.AOMPropertyContainerImpl -- class-descriptor class=com.cci.model.pharma.impl.AOMPropertyContainerImpl table=AOMPropertyContainer field-descriptor name=id column=id jdbc-type=VARCHAR primarykey=true access=readwrite / field-descriptor name=isPublic column=isPublic jdbc-type=INTEGER conversion=org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFie ldConversion access=readwrite / field-descriptor name=aOMObject_id column=aOMObject_id jdbc-type=VARCHAR access=anonymous / field-descriptor name=aOMType_id column=aOMType_id jdbc-type=VARCHAR access=anonymous / reference-descriptor name=aOMObject class-ref=com.cci.model.pharma.impl.AOMObjectImpl refresh=true foreignkey field-ref=aOMObject_id/ /reference-descriptor reference-descriptor name=aOMType class-ref=com.cci.model.pharma.impl.AOMTypeImpl refresh=true foreignkey field-ref=aOMType_id/ /reference-descriptor reference-descriptor name=super class-ref=com.cci.model.pharma.impl.AOMElementImpl refresh=true foreignkey field-ref=id/ /reference-descriptor collection-descriptor name=properties element-class-ref=com.cci.model.pharma.impl.AOMPropertyImpl /collection-descriptor /class-descriptor !-- Mapping for Class org.apache.ojb.broker.util.sequence.HighLowSequence -- class-descriptor class=org.apache.ojb.broker.util.sequence.HighLowSequence table=OJB_HL_SEQ field-descriptor name=tableName column=TABLENAME jdbc-type=VARCHAR primarykey=true access=readwrite / field-descriptor name=fieldName column=FIELDNAME jdbc-type=VARCHAR primarykey=true access=readwrite / field-descriptor name=maxKey column=MAX_KEY jdbc-type=INTEGER access=readwrite / field-descriptor name=grabSize column=GRAB_SIZE jdbc-type=INTEGER access=readwrite / field-descriptor name=version column=VERSION jdbc-type=INTEGER locking=true access=readwrite / /class-descriptor !-- Mapping for Class org.apache.ojb.odmg.collections.DListEntry -- class-descriptor class=org.apache.ojb.odmg.collections.DListEntry table=OJB_DLIST_ENTRIES field-descriptor name=id column=ID jdbc-type=INTEGER primarykey=true autoincrement=true access=readwrite / field-descriptor name=dlistId column=DLIST_ID jdbc-type=INTEGER access=readwrite / field-descriptor name=position column=POSITION_ jdbc-type=INTEGER access=readwrite / field-descriptor name=oid
Re: Problem with char mapping
Gelhar Thank you very much for this info. It will help me a lot. Best regards Andre Legendre Gelhar, Wallace Joseph wrote: Andre Write a char to boolean conversion class. See http://db.apache.org/ojb/jdbc-types.html for details. Wally -Original Message- From: André Charles Legendre [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 10:36 AM To: OJB Users List Subject: Re: Problem with char mapping Armin Thnak you for your elements. But what is the good solutions when I want to use char size 1 (as substitute of Boolean) and Long ? Andre Le Mercredi 21 Janvier 2004 18:12, Armin Waibel a écrit : Hi again, A Leg wrote: Armin I use db-ojb-1.0.rc4. ok, in final 1.0 BOOLEAN datatype should be supported (but there is currently no test case for that, so no guarantee ;-)) And it seem that the problem is similar for numeric where ojb accept only BigDecimal : [PersistentField] ERROR: while set field: object class[ org.compiere.mfg_scm.dbManager.MGT_Request target field: jobNum target field type: class java.lang.Long object value class: java.math.BigDecimal object value: 1] null I made the test with Long and with int, problem is the same if in database the column is Numeric. yep, OJB does the mapping as specified by sun and NUMERIC is mapped to BigDecimal. regards, Armin Andre Armin Waibel wrote: Hi Andre, A Leg wrote: Hi every body I have a variable name hold declare as char in code. (It was first a Boolean but I change as Boolean is not supported) Which version of OJB do you use? mapping is : field-descriptor name=hold column=HOLD jdbc-type=CHAR/ and in postgres the column is bpchar (size 1) I get the following errors (see belo). I have to declare it as String in my java code to get it work. But I would like to declare it as char. Does any body able to explain that and to give a solution ? Think you need a field-conversion, because sun's mapping convention say that CHAR was mapped to String See http://db.apache.org/ojb/jdbc-types.html Write your own String2CharFieldConversion. You can find many examples in source code (..broker.accesslayer.conversion package) regards, Armin Best regards Andre Legendre [PersistentField] ERROR: while set field: object class[ org.compiere.mfg_scm.dbManager.MGB_Request target field: hold target field type: char object value class: java.lang.String object value: N] null java.lang.IllegalArgumentException at sun.reflect.UnsafeCharacterFieldAccessorImpl.set(UnsafeCharacterFie ldAc cessorImpl.java:68) at java.lang.reflect.Field.set(Field.java:519) at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAcc essI mpl.doSet(Unknown Source) at org.apache.ojb.broker.metadata.fieldaccess.AbstractPersistentField.set( Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.buildWithReflect ion(Unknown Source) at org.apache.ojb.broker.accesslayer.RowReaderDefaultImpl.readObjectFrom(U nknown Source) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Unkn own Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Un known Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unkno wn Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery (Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery (Unknown Source) at org.compiere.mfg_scm.dbManager.TaskConsumer.showJob(Unknown Source) at org.compiere.mfg_scm.dbManager.DbManagerImpl.showJob(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja va:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcc esso rImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261) at sun.rmi.transport.Transport$1.run(Transport.java:148) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Transport.java:144) at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460 ) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.j ava:701) at java.lang.Thread.run(Thread.java:534) [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: PersistenceBrokerException during the execution of materializeObject: Error setting field:hold in object:org.compiere.mfg_scm.dbManager.MGB_Request Error setting field:hold in object:org.compiere.mfg_scm.dbManager.MGB_Request java.lang.IllegalArgumentException at sun.reflect.UnsafeCharacterFieldAccessorImpl.set(UnsafeCharacterFie ldAc cessorImpl.java:68) at java.lang.reflect.Field.set(Field.java:519) at
Nested primitive types
I've got the following problem, that i can solve with a custom implementation of PersistentField. I've got a simple the following objects: class A { int i; } class B { A a; } I store B and A in the same table using nested fields. The problem is that when i store an empty B object (with the 'a' field to null), a null is inserted into the column 'i'. That is fine, but when i read it, the AbstractPersistentField::setNestedObject creates an A object before setting not setting the null value to the 'i' field. So the next time the B object is stored, the 'a' field is not null anymore, and a 0 is inserted in the column 'i'. Can the test that is made to skip the storing of a primitive value if the object value is null can be made earlier so that the nested object is accessed (and created) only if necessary ? Regards - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Pbm on MtoNCollectionPrefetcher
Hello There is a problem on the MtoNCollectionPrefetcher . Description : Input a MtoN relation in an Oracle database All the ids are SQL NUMBER and are declared as BIGINT in the repository.xml. The problem is that the Prefetecher use a ReportQuery in the method prefetchRelationship but use the class descriptor ( in the associateBatched method ) for generating identity . Identity on Object A using the ReportQuery : 2 BigInteger ( using the JdbcTypesHelper and the MetaDatas of the statement ) Identity on Object A using the ClassDescriptor : 2 Long The equal method of the identity return false even with the same ids ... So access to the maps childMap and ownerIdsToLists ( in associateBatched ) cause NPE because returning null values . I think may be the mapping of the good type of the ReportQuery result is missing ??? Here is a part of the stack : org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.associateBatched( MtoNCollectionPrefetcher.java:363) at org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.prefetchRelations hip(MtoNCollectionPrefetcher.java:126) at org.apache.ojb.broker.core.QueryReferenceBroker$PBPrefetchingListener.prefet ch(QueryReferenceBroker.java:837) at org.apache.ojb.broker.core.QueryReferenceBroker$PBCollectionProxyListener.be foreLoading(QueryReferenceBroker.java:894) at org.apache.ojb.broker.accesslayer.CollectionProxy.beforeLoading(CollectionPr oxy.java:173) at org.apache.ojb.broker.accesslayer.CollectionProxy.getData(CollectionProxy.ja va:400) at org.apache.ojb.broker.accesslayer.CollectionProxy.iterator(CollectionProxy.j ava:230) B.R Thierry - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
contrib target
This looks like it has a problem... it is from a 2 day old checkout of CVS [EMAIL PROTECTED] db-ojb]$ ant contrib Buildfile: build.xml contrib: [tar] Building tar: /home/gus/projects/db-ojb/dist/${archive}-contrib.tar [gzip] Building: /home/gus/projects/db-ojb/dist/${archive}-contrib.tgz [delete] Deleting: /home/gus/projects/db-ojb/dist/${archive}-contrib.tar BUILD SUCCESSFUL Total time: 4 seconds [EMAIL PROTECTED] db-ojb]$ ls dist ${archive}-contrib.tgz db-ojb-1.0.rc5-junit.jar db-ojb-1.0.rc5-tools.jar db-ojb-1.0.rc5.jar db-ojb-1.0.rc5-src.jar db-ojb-1.0.rc5-tutorial.jar [EMAIL PROTECTED] db-ojb]$ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Pbm on MtoNCollectionPrefetcher
Hello Thierry, Here is comment of Jakob Braeuchi in OJB-DEV on the same issue : http://article.gmane.org/gmane.comp.jakarta.ojb.devel/5084 - Original Message - From: Thierry Hanot [EMAIL PROTECTED] To: 'OJB Users List' [EMAIL PROTECTED] Sent: Thursday, January 22, 2004 3:31 PM Subject: Pbm on MtoNCollectionPrefetcher Hello There is a problem on the MtoNCollectionPrefetcher . Description : Input a MtoN relation in an Oracle database All the ids are SQL NUMBER and are declared as BIGINT in the repository.xml. The problem is that the Prefetecher use a ReportQuery in the method prefetchRelationship but use the class descriptor ( in the associateBatched method ) for generating identity . Identity on Object A using the ReportQuery : 2 BigInteger ( using the JdbcTypesHelper and the MetaDatas of the statement ) Identity on Object A using the ClassDescriptor : 2 Long The equal method of the identity return false even with the same ids ... So access to the maps childMap and ownerIdsToLists ( in associateBatched ) cause NPE because returning null values . I think may be the mapping of the good type of the ReportQuery result is missing ??? Here is a part of the stack : org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.associateBatched( MtoNCollectionPrefetcher.java:363) at org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.prefetchRelations hip(MtoNCollectionPrefetcher.java:126) at org.apache.ojb.broker.core.QueryReferenceBroker$PBPrefetchingListener.prefet ch(QueryReferenceBroker.java:837) at org.apache.ojb.broker.core.QueryReferenceBroker$PBCollectionProxyListener.be foreLoading(QueryReferenceBroker.java:894) at org.apache.ojb.broker.accesslayer.CollectionProxy.beforeLoading(CollectionPr oxy.java:173) at org.apache.ojb.broker.accesslayer.CollectionProxy.getData(CollectionProxy.ja va:400) at org.apache.ojb.broker.accesslayer.CollectionProxy.iterator(CollectionProxy.j ava:230) B.R Thierry - 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]
[Fwd: Problems with super]
forwarded you question to the ojb user list. Thomas Original Message Subject: Problems with super Date: Thu, 22 Jan 2004 13:29:41 -0500 From: Ankur Gupta [EMAIL PROTECTED] To: [EMAIL PROTECTED] Hello Thomas, I have been having some problems using super to map an inheritance hierarchy. Seems like ojb isn't treating the reference descriptor as a special tag. I keep getting the following error: Can't find member super in com.cci.model.pharma.impl.AOMObjectImpl The repository XML looks like this: !-- Mapping for Class com.cci.model.pharma.impl.AOMElementImpl -- class-descriptor class=com.cci.model.pharma.impl.AOMElementImpl table=AOMElement field-descriptor name=id column=id jdbc-type=VARCHAR primarykey=true access=readwrite / field-descriptor name=name column=name jdbc-type=VARCHAR access=readwrite / /class-descriptor !-- Mapping for Class com.cci.model.pharma.impl.AOMObjectImpl -- class-descriptor class=com.cci.model.pharma.impl.AOMObjectImpl table=AOMObject field-descriptor name=id column=id jdbc-type=VARCHAR primarykey=true access=readwrite / reference-descriptor name=super class-ref=com.cci.model.pharma.impl.AOMElementImpl refresh=true foreignkey field-ref=id/ /reference-descriptor /class-descriptor Please let me know if I am overlooking something. Regards, Ankur Gupta Core Concept Inc. 1000 Abernathy Road Building 400, Suite 1010 Atlanta, GA 30328 p: 678-731- x 406 c: 678-478-3777 e: [EMAIL PROTECTED] -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Orion App-server
forwarded to the ojb-user list. Thomas Original Message Date: Thu, 22 Jan 2004 09:17:13 -0800 From: He, Paul (EDS) [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Thomas, I am just starting to use OJB recently. Oracle application server (Orion server) is our choice. I wonder if you have some examples I deploy an OJB application on Orion server. I really get confused on the configuration. Also, do I need to write a customized startup object as the instruction for Weblogic or Jboss? Thank you so much. Paul He A Representative of HSDD PLANO, TX Phone:+1-972-604-8855 mailto: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: FW: deploy OJB with web application
Armin, Thanks for your reply. Here is a portion of my repository.xml. I am not sure whether the missing attribute for proxy-prefetching-limit causes the problem? descriptor-repository version=1.0 isolation-level=read-uncommitted !-- include all used database connections -- database; !-- include ojb internal mappings here -- internal; Thanks, Zhe -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Thursday, January 22, 2004 3:28 AM To: OJB Users List Subject: Re: deploy OJB with web application Hi, ZZZ Liu wrote: I am using OJB rc5. Everything is fine when I use it for stand alone program. But when I try to use it in a web application (applciation server is resin 2.1.10), I got following error. From the log, we can see that there is a NullPointerException at org.apache.ojb.broker.metadata.RepositoryXmlHandler.getIsoLevel(Unknown Source) and from the debug message we can see that isolation-level: null. hmm, think something wrong with your file:/D:/gsnx/builds/hourly/dist/gsnx/conf/repository.xml file. Should be something like that: descriptor-repository version=1.0 isolation-level=read-uncommitted proxy-prefetching-limit=50 !-- include all used database connections -- database; !-- include ojb internal mappings here -- internal; !-- include user defined mappings here -- user; /descriptor-repository regards, Armin If I manually add isolation-level attribute to each class descriptor element in repository_internal.xml and all included repository_user.xml's, then it works. I don't think there is any document saying that we need to change repository_internal.xml. I am wondering whether anybody has ever had the same problem and what's the real cause and the soultion for it. Thanks in advance. Zhe === 84938 DEBUG [tcpConnection-9003-0] util.RequestUtils - Get module name for path /core/domain/party/partySearchReport.jsp 84938 DEBUG [tcpConnection-9003-0] util.RequestUtils - Module name found: default 84953 DEBUG [tcpConnection-9003-0] tiles.InsertTag - insert page='/core/fwk/mainLayout.jsp'. 88953 INFO [tcpConnection-9003-0] util.PropertyMessageResources - Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true [org.apache.ojb.broker.metadata.RepositoryPersistor] INFO: OJB Descriptor Repository: file:/D:/gsnx/builds/hourly/dist/gsnx/conf/repository.xml [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: startDoc [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: proxy-prefetching-limit: null [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: descriptor-repository [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: documentation [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG:class-descriptor [org.apache.ojb.broker.metadata.RepositoryXmlHandler] DEBUG: isolation-level: null 89719 DEBUG [tcpConnection-9003-0] tiles.InsertTag - [ServletException in:/core/fwk/mainLayout.jsp] null' java.lang.ExceptionInInitializerError at org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.getDefaultKey(Un known Source) at org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.defaultPersisten ceBroker(Unknown Source) at org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersistenceBroker(Unkn own Source) at com.gsnx.core.server.persistence.ojb.OjbPersistenceManager.init(OjbPersist enceManager.java) at com.gsnx.core.server.persistence.PersistenceManagerFactory.getPersistenceMan ager(PersistenceManagerFactory.java) at com.gsnx.core.server.util.lang.TranslationUtil.cacheTranslation(TranslationU til.java) at com.gsnx.core.server.util.lang.TranslationUtil.getTranslation(TranslationUti l.java) at com.gsnx.core.server.util.lang.TranslationUtil.message(TranslationUtil.java) at com.gsnx.core.server.util.lang.TranslationUtil.message(TranslationUtil.java) at com.gsnx.core.webui.fwk.util.HtmlUtil.resolveLabel(HtmlUtil.java) at _core._fwk._mainlayout__jsp._jspService(_mainlayout__jsp.java:73) at com.caucho.jsp.JavaPage.service(JavaPage.java:75) at com.caucho.jsp.Page.subservice(Page.java:506) at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182) at com.caucho.server.http.Invocation.service(Invocation.java:315) at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135) at com.caucho.server.http.QRequestDispatcher.include(QRequestDispatcher.java:36 2) at com.caucho.server.http.QRequestDispatcher.include(QRequestDispatcher.java:27 4) at
Re: FW: FW: FW: Cannot retrieve back just saved objects without committing transaction
Thanks a lot. I will try later. Zhe -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 21, 2004 12:38 AM To: OJB Users List Subject: Re: FW: FW: Cannot retrieve back just saved objects without committing transaction Hi Zhe, ZZZ Liu wrote: Hi, Armin Thank you very much for the fixing. But I have one more question. If the batch mode is turned on by calling broker.getConnectionManager().setBatchMode(true), db operations will not be applied to db until transaction is commited. In this case, I will still have the problem if I want to insert two records in a batch and then retrieve them back right away without committing the transaction. This looks differen from JDBC. After PreparedStatement.executeBatch, even the transaction is not commited, I believe I can still retrieve them back. Is there any paticular reason for the OJB batch mode implementation? Works in the same way as pur JDBC. You have to call PB.serviceConnectionManager.executeBatch() to execute the batch without committing the tx. regards, Armin Thanks, Zhe -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Sunday, January 18, 2004 8:57 AM To: OJB Users List Subject: Re: FW: Cannot retrieve back just saved objects without committing transaction Hi Zhe, I add your test case to test suite and fix the problem in CVS head. It will be included in upcoming 1.0. You can easy fix it by changing one line in ConnectionManagerImpl - see below. Thank you very much for test case and detailed description. regards, Armin RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManage rImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ConnectionManagerImpl.java 2 Nov 2003 13:21:08 - 1.9 +++ ConnectionManagerImpl.java 18 Jan 2004 16:47:35 - 1.10 @@ -101,7 +101,14 @@ this.jcd = MetadataManager.getInstance().connectionRepository().getDescriptor(pbKey); this.connectionFactory = ConnectionFactoryFactory.getInstance().createConnectionFactory(); this.platform = PlatformFactory.getPlatformFor(jcd); -setBatchMode(this.jcd.getBatchMode()); +/* +by default batch mode is not enabled and after use of a PB +instance, before instance was returned to pool, batch mode +was set to false again (PB implementation close method) +Be carefully in modify this behaviour, changes could cause +unexpected behaviour +*/ +setBatchMode(false); } ZZZ Liu wrote: It is a standalone program and the database is Oracle. Here is the sample code: Product product = new Product(); product.setProductCode(AAA); product.setDesc(BBB); PersistenceBroker broker = null; try { broker = PersistenceBrokerFactory.defaultPersistenceBroker(); broker.beginTransaction(); // assuming AAA is a new record that does not exist in database broker.store(product, ObjectModificationDefaultImpl.INSERT); Query query = new QueryByCriteria(Product.class, null); Collection all = broker.getCollectionByQuery(query); Iterator iter = all.iterator(); while (iter.hasNext()) { // AAA will not be printed System.out.println(iter.next()); } broker.commitTransaction(); } catch (Throwable t) { broker.abortTransaction(); t.printStackTrace(); } finally { try { broker.close(); } catch (Exception e) { } } // AAA will be in database after the program finishes. Thanks, Zhe -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Friday, January 16, 2004 12:53 AM To: OJB Users List Subject: Re: FW: Cannot retrieve back just saved objects without committing transaction Hi Zhe, ZZZ Liu wrote: === message truncated === __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]