Re: Problem in PersistenceBrokerImpl
Hi Edson, it's strange. I can find two places in code using getCollectionIterator(...), but can't figure out where the NPE was could be thrown. In PB.deleteCollections(...) a 'null' check is done (line 623). In PB.storeCollections(...) it is possible that null could be passed (line 862), but if we return null in getCollectionIterator will end up with a NPE. Maybe I'm overlooked something. Could shed light on this? regards, Armin Edson Carlos Ericksson Richter wrote: Yes, works fine if modifying the method to: private Iterator getCollectionIterator(CollectionDescriptor cds, Object collectionOrArray) { Iterator colIterator; if(collectionOrArray == null) { return null; } if (collectionOrArray instanceof ManageableCollection) { colIterator = ((ManageableCollection) collectionOrArray).ojbIterator(); } else if (collectionOrArray instanceof Collection) { colIterator = ((Collection) collectionOrArray).iterator(); } else if (collectionOrArray.getClass().isArray()) { colIterator = new ArrayIterator(collectionOrArray); } else { String fieldName = cds.getClassDescriptor().getClassNameOfObject() + "." + cds.getAttributeName(); throw new OJBRuntimeException( "Field '" + fieldName + "' " + collectionOrArray.getClass() + " can not be managed by OJB. Use Array, Collection or ManageableCollection instead !"); } return colIterator; } - Original Message - From: Edson Carlos Ericksson Richter To: 'OJB Users List' Sent: Tuesday, March 23, 2004 3:36 PM Subject: Problem in PersistenceBrokerImpl Hi! I've found a little bug in PersistenceBrokerImpl (latest CVS - downloaded 10 min ago), that can cause a NPE when storing: private Iterator getCollectionIterator(CollectionDescriptor cds, Object collectionOrArray) { Iterator colIterator; if (collectionOrArray instanceof ManageableCollection) { colIterator = ((ManageableCollection) collectionOrArray).ojbIterator(); } else if (collectionOrArray instanceof Collection) { colIterator = ((Collection) collectionOrArray).iterator(); } else if (collectionOrArray.getClass().isArray()) { colIterator = new ArrayIterator(collectionOrArray); } else { String fieldName = cds.getClassDescriptor().getClassNameOfObject() + "." + cds.getAttributeName(); throw new OJBRuntimeException( "Field '" + fieldName + "' " + collectionOrArray.getClass() + " can not be managed by OJB. Use Array, Collection or ManageableCollection instead !"); } return colIterator; } The problem occur when collectionOrArray is null. I'm trying to put a test like: if(collectionOrArray==null) { return null; } as solution. I'll let you know if this solves. Thanks, Edson Richter --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
M:N with different number of PK and FK in relation table and buildPrefetchCriteriaMultipleKeys
*** Behaviour changed since 1.0rc5 *** I'm getting AIOOBE then executing a query. The collection descriptor causing the problem is: As you can see, I've two primary key referencing to this (M side) class, and only one referencing the other class (N side). This worked in rc5. Today, I've updated to latest CVS (1.0.0). I don't know how to fix. The complete exception is: java.lang.ArrayIndexOutOfBoundsException: 1 at org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.buildPrefetchCrit eriaMultipleKeys(MtoNCollectionPrefetcher.java:338) at org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.buildPrefetchCrit eria(MtoNCollectionPrefetcher.java:259) at org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.buildPrefetchQuer y(MtoNCollectionPrefetcher.java:115) at org.apache.ojb.broker.accesslayer.CollectionPrefetcher.buildPrefetchQueries( CollectionPrefetcher.java:93) at org.apache.ojb.broker.accesslayer.MtoNCollectionPrefetcher.prefetchRelations hip(MtoNCollectionPrefetcher.java:68) at org.apache.ojb.broker.core.QueryReferenceBroker.performRetrievalTasks(QueryR eferenceBroker.java:277) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe ferenceBroker.java:146) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe ferenceBroker.java:203) at org.apache.ojb.broker.core.QueryReferenceBroker.getCollectionByQuery(QueryRe ferenceBroker.java:223) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getCollectionByQuery(Persis tenceBrokerImpl.java:1054) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery( DelegatingPersistenceBroker.java:331) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getCollectionByQuery( DelegatingPersistenceBroker.java:331) at br.com.mgr.brokers.ojbBroker.CommonOperationsBroker.getAllFromCriteria(Commo nOperationsBroker.java:237) at br.com.mgr.brokers.ojbBroker.CommonOperationsBroker.getAllFromCriteria(Commo nOperationsBroker.java:227) at br.com.mgr.brokers.ojbBroker.TituloBrokerImpl.getTitulos(TituloBrokerImpl.ja va:205) at br.com.mgr.plugins.financeiro.titulo.TituloUC.getTitulos(TituloUC.java:608) at br.com.mgr.plugins.financeiro.titulo.ListaTitulosImpl.atualizar(ListaTitulos Impl.java:338) at br.com.mgr.plugins.financeiro.titulo.ListaTitulosImpl.actionPerformed(ListaT itulosImpl.java:173) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButto n.java:1839) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:4 20) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener .java:245) at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231) at java.awt.Component.processMouseEvent(Component.java:5100) at java.awt.Component.processEvent(Component.java:4897) at java.awt.Container.processEvent(Container.java:1569) at java.awt.Component.dispatchEventImpl(Component.java:3615) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128) at java.awt.Container.dispatchEventImpl(Container.java:1613) at java.awt.Window.dispatchEventImpl(Window.java:1606) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja va:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java :151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) Best regards, Edson Richter --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004 smime.p7s Description: S/MIME cryptographic signature
Re: Newbie Proxy problem
Of course, I forget to metion the mandatory interfaces: public interface TestAIF { } public interface TestBIF { } then public class TestA implements TestAIF { } public class TestB implements TestBIF { } Best regards, Edson Richter - Original Message - From: Edson Carlos Ericksson Richter To: OJB Users List Sent: Tuesday, March 23, 2004 3:48 PM Subject: Re: Newbie Proxy problem I'll try to do show in a sample: public class TestA { public int idA; public java.util.List allB; } public class TestB { public int idB; public int idReferenceToA; public TestA referenceToA; } in XML: I get this sample from my projects (just changed the field/table/bean names, and simplified the beans). This works fine (may be I made some typo when changing names, so this sample could/couldn't run as is). But the main ideia is there. If you are using JavaBeans like acessors (like I do), don't forget to implement getter/setters for your objects. Best regards, Edson Richter - Original Message - From: Mauricio Montblanch To: OJB Users List Sent: Tuesday, March 23, 2004 3:16 PM Subject: Re: Newbie Proxy problem Nop, it did not work, have you any example Edson Carlos Ericksson Richter wrote: >As far as you have explained, you should not get ClassCastException. >First let's go analize your code: > >1) Product implements InterfaceProduct. >2) ProductGroup have a products list. Ok, have you set the collection-class in the collection-descriptor to ManageableArrayList? If you have not, do it, because default is RemovalAwareCollection (you can't make cast from Collection to List, or you will get ClassCastException). > >Without more details is hard to give you better ideais about what's can be going wrong. > >Best regards, > >Edson Richter > > - Original Message - > From: Mauricio Montblanch > To: OJB Users List > Sent: Friday, March 19, 2004 11:54 AM > Subject: Newbie Proxy problem > > > Hi I am trying to use a dynamic proxy in a 1:n relation (loading a list) > but a I can 't figure out how make it work (I get a > java.lang.ClassCastException when I try to get the any object), can > anyone give me a simple example of how to use a dynamic proxy. > > Detail > > Clases: > > Product > InterfaceProduct (Interface) > ProductGroup (contains List products) > > XML: > > .. > > . > . > > > > > so, when y get a product Group y get a list of products filled with > objects of the type (InterfaceProduct) > > and I can say > > InterfaceProduct i=(InterfaceProduct) ptoducts.get(0); > without errors > > but how I can materialize the Product Object > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.624 / Virus Database: 401 - Release Date: 15/3/2004 > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem in PersistenceBrokerImpl
Yes, works fine if modifying the method to: private Iterator getCollectionIterator(CollectionDescriptor cds, Object collectionOrArray) { Iterator colIterator; if(collectionOrArray == null) { return null; } if (collectionOrArray instanceof ManageableCollection) { colIterator = ((ManageableCollection) collectionOrArray).ojbIterator(); } else if (collectionOrArray instanceof Collection) { colIterator = ((Collection) collectionOrArray).iterator(); } else if (collectionOrArray.getClass().isArray()) { colIterator = new ArrayIterator(collectionOrArray); } else { String fieldName = cds.getClassDescriptor().getClassNameOfObject() + "." + cds.getAttributeName(); throw new OJBRuntimeException( "Field '" + fieldName + "' " + collectionOrArray.getClass() + " can not be managed by OJB. Use Array, Collection or ManageableCollection instead !"); } return colIterator; } - Original Message - From: Edson Carlos Ericksson Richter To: 'OJB Users List' Sent: Tuesday, March 23, 2004 3:36 PM Subject: Problem in PersistenceBrokerImpl Hi! I've found a little bug in PersistenceBrokerImpl (latest CVS - downloaded 10 min ago), that can cause a NPE when storing: private Iterator getCollectionIterator(CollectionDescriptor cds, Object collectionOrArray) { Iterator colIterator; if (collectionOrArray instanceof ManageableCollection) { colIterator = ((ManageableCollection) collectionOrArray).ojbIterator(); } else if (collectionOrArray instanceof Collection) { colIterator = ((Collection) collectionOrArray).iterator(); } else if (collectionOrArray.getClass().isArray()) { colIterator = new ArrayIterator(collectionOrArray); } else { String fieldName = cds.getClassDescriptor().getClassNameOfObject() + "." + cds.getAttributeName(); throw new OJBRuntimeException( "Field '" + fieldName + "' " + collectionOrArray.getClass() + " can not be managed by OJB. Use Array, Collection or ManageableCollection instead !"); } return colIterator; } The problem occur when collectionOrArray is null. I'm trying to put a test like: if(collectionOrArray==null) { return null; } as solution. I'll let you know if this solves. Thanks, Edson Richter --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004 smime.p7s Description: S/MIME cryptographic signature
Re: Newbie Proxy problem
I'll try to do show in a sample: public class TestA { public int idA; public java.util.List allB; } public class TestB { public int idB; public int idReferenceToA; public TestA referenceToA; } in XML: I get this sample from my projects (just changed the field/table/bean names, and simplified the beans). This works fine (may be I made some typo when changing names, so this sample could/couldn't run as is). But the main ideia is there. If you are using JavaBeans like acessors (like I do), don't forget to implement getter/setters for your objects. Best regards, Edson Richter - Original Message - From: Mauricio Montblanch To: OJB Users List Sent: Tuesday, March 23, 2004 3:16 PM Subject: Re: Newbie Proxy problem Nop, it did not work, have you any example Edson Carlos Ericksson Richter wrote: >As far as you have explained, you should not get ClassCastException. >First let's go analize your code: > >1) Product implements InterfaceProduct. >2) ProductGroup have a products list. Ok, have you set the collection-class in the collection-descriptor to ManageableArrayList? If you have not, do it, because default is RemovalAwareCollection (you can't make cast from Collection to List, or you will get ClassCastException). > >Without more details is hard to give you better ideais about what's can be going wrong. > >Best regards, > >Edson Richter > > - Original Message - > From: Mauricio Montblanch > To: OJB Users List > Sent: Friday, March 19, 2004 11:54 AM > Subject: Newbie Proxy problem > > > Hi I am trying to use a dynamic proxy in a 1:n relation (loading a list) > but a I can 't figure out how make it work (I get a > java.lang.ClassCastException when I try to get the any object), can > anyone give me a simple example of how to use a dynamic proxy. > > Detail > > Clases: > > Product > InterfaceProduct (Interface) > ProductGroup (contains List products) > > XML: > > .. > > . > . > > > > > so, when y get a product Group y get a list of products filled with > objects of the type (InterfaceProduct) > > and I can say > > InterfaceProduct i=(InterfaceProduct) ptoducts.get(0); > without errors > > but how I can materialize the Product Object > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.624 / Virus Database: 401 - Release Date: 15/3/2004 > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004
Problem in PersistenceBrokerImpl
Hi! I've found a little bug in PersistenceBrokerImpl (latest CVS - downloaded 10 min ago), that can cause a NPE when storing: private Iterator getCollectionIterator(CollectionDescriptor cds, Object collectionOrArray) { Iterator colIterator; if (collectionOrArray instanceof ManageableCollection) { colIterator = ((ManageableCollection) collectionOrArray).ojbIterator(); } else if (collectionOrArray instanceof Collection) { colIterator = ((Collection) collectionOrArray).iterator(); } else if (collectionOrArray.getClass().isArray()) { colIterator = new ArrayIterator(collectionOrArray); } else { String fieldName = cds.getClassDescriptor().getClassNameOfObject() + "." + cds.getAttributeName(); throw new OJBRuntimeException( "Field '" + fieldName + "' " + collectionOrArray.getClass() + " can not be managed by OJB. Use Array, Collection or ManageableCollection instead !"); } return colIterator; } The problem occur when collectionOrArray is null. I'm trying to put a test like: if(collectionOrArray==null) { return null; } as solution. I'll let you know if this solves. Thanks, Edson Richter ---Outgoing mail is certified Virus Free.Checked by AVG anti-virus system (http://www.grisoft.com).Version: 6.0.637 / Virus Database: 408 - Release Date: 20/3/2004 smime.p7s Description: S/MIME cryptographic signature
Re: Newbie Proxy problem
Nop, it did not work, have you any example Edson Carlos Ericksson Richter wrote: As far as you have explained, you should not get ClassCastException. First let's go analize your code: 1) Product implements InterfaceProduct. 2) ProductGroup have a products list. Ok, have you set the collection-class in the collection-descriptor to ManageableArrayList? If you have not, do it, because default is RemovalAwareCollection (you can't make cast from Collection to List, or you will get ClassCastException). Without more details is hard to give you better ideais about what's can be going wrong. Best regards, Edson Richter - Original Message - From: Mauricio Montblanch To: OJB Users List Sent: Friday, March 19, 2004 11:54 AM Subject: Newbie Proxy problem Hi I am trying to use a dynamic proxy in a 1:n relation (loading a list) but a I can 't figure out how make it work (I get a java.lang.ClassCastException when I try to get the any object), can anyone give me a simple example of how to use a dynamic proxy. Detail Clases: Product InterfaceProduct (Interface) ProductGroup (contains List products) XML: .. . . so, when y get a product Group y get a list of products filled with objects of the type (InterfaceProduct) and I can say InterfaceProduct i=(InterfaceProduct) ptoducts.get(0); without errors but how I can materialize the Product Object - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.624 / Virus Database: 401 - Release Date: 15/3/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
access documentation in metadata
Hello, who can help me? How is it possible to access the documentation in metadata. MetadataManger, ClassDescriptor and FieldDescriptor no problem! But where are the documentation infos? FieldDescription Stefan Sayk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Strange behaviour: Oracle sequence.nextval
Hi Klaus, this could happen the first time a sequence was used, e.g. SequenceManager doesn't accept 0 as PK value and obtain a new PK value from the DB. Here is an example: First time call (DB sequence does not exist, OJB create it on the fly) 1080055631853|150|0|statement||select SEQ_SALAD.nextval from dual 1080055631853|0|0|statement||drop sequence SEQ_SALAD 1080055631853|0|0|statement||create sequence SEQ_SALAD 1080055631953|100|0|statement||select SEQ_SALAD.nextval from dual 1080055632033|0|0|statement|INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES (?,?,?,?) |INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES ('1','NEW FISH','0','') 1080055632053|0|0|commit|| 1080055632053|0|0|statement||select SEQ_SALAD.nextval from dual 1080055632063|0|0|statement|INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES (?,?,?,?) |INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES ('2','MORE NEW FISH!','0','') 1080055632063|0|0|commit|| run the test again (sequence already established in DB) 1080055974686|100|0|statement||select SEQ_SALAD.nextval from dual 1080055974776|10|0|statement|INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES (?,?,?,?) |INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES ('3','NEW FISH','0','') 1080055974796|10|0|commit|| 1080055974796|0|0|statement||select SEQ_SALAD.nextval from dual 1080055974796|0|0|statement|INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES (?,?,?,?) |INSERT INTO FISH (foodId,name,calories,typeOfWater) VALUES ('4','MORE NEW FISH!','0','') 1080055974796|0|0|commit|| regards, Armin Richarz, Klaus (Computer Service) wrote: Hi, I am using OJB 1.0rc5 with Oracle8. When I try to store a simple object, the following SQL queries are executed (p6spy.log): 1080045456718|15|0|statement||select TURBINE_USER_SEQ.nextval from dual 1080045456843|0|0|statement|SELECT LAST_NAME,LOGIN_NAME,FIRST_NAME,USER_ID,PASSWORD_VALUE,EMAIL FROM TURBINE_USER WHERE USER_ID = ? |SELECT LAST_NAME,LOGIN_NAME,FIRST_NAME,USER_ID,PASSWORD_VALUE,EMAIL FROM TURBINE_USER WHERE USER_ID = '40049' 1080045456859|16|0|statement||select TURBINE_USER_SEQ.nextval from dual 1080045457265|406|0|statement|INSERT INTO TURBINE_USER (USER_ID,EMAIL,FIRST_NAME,LAST_NAME,LOGIN_NAME,PASSWORD_VALUE) VALUES (?,?,?,?,?,?) |INSERT INTO TURBINE_USER (USER_ID,EMAIL,FIRST_NAME,LAST_NAME,LOGIN_NAME,PASSWORD_VALUE) VALUES ('40050','','Klaus','Richarz','neu01','BxlwjRzIFIOb2Bj9wn1EZlLw') Why is "select TURBINE_USER_SEQ.nextval from dual" executed two times ? repository.xml (snippet) Thanks in advance, Klaus Richarz Hamburger Berater Team GmbH Hamburg, Germany - 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]
Primary Key from Insert-Round 2
Armin, you are correct. The same connection object is being used by the insert and the PK query. I went back to my test app, closing the statement for the insert before creating a new statement for the PK query, and it worked there. However, the problem remains in OJB: the PK query returns nothing. FYI, I am now on OJB 1.5. Am having to run with compiled source since the Jakarta version is not debug enabled. Let me focus precisely on the problem. I have modified JdbcAccessImpl.executeInsert() to include the statements needed to retrieve the PK from the insert. I know it works because I've executed it with test code without OJB. This code is for my own testing purposes and once I have solved the problem, I will revert to the release version JAR files. Here's the function as I'm testing it. Note the statements under harvestReturnValues() are the test code as would be executed by SequenceManagerNativeImpl. The ResultSet contains null. public void executeInsert(ClassDescriptor cld, Object obj) throws PersistenceBrokerException { if(logger.isDebugEnabled()) logger.safeDebug("executeInsert", obj); PreparedStatement stmt = null; try { stmt = broker.serviceStatementManager().getInsertStatement(cld); if (stmt == null) { logger.error("getInsertStatement returned a null statement"); throw new PersistenceBrokerException("getInsertStatement returned a null statement"); } broker.serviceStatementManager().bindInsert(stmt, cld, obj); if (logger.isDebugEnabled()) logger.debug("executeInsert: " + stmt); stmt.executeUpdate(); // Harvest any return values. harvestReturnValues(cld.getInsertProcedure(), obj, stmt); // This is the code that returns null for the PK. Works in test system, not with OJB. Connection connection = stmt.getConnection(); stmt.close(); Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery("SELECT SCOPE_IDENTITY()"); while (rs.next()) { long val = rs.getLong(1); System.out.println("PK=" + val); } } catch (PersistenceBrokerException e) { logger.error( "PersistenceBrokerException during the execution of the insert: " + e.getMessage(), e); throw e; } catch (SQLException e) { logger.error( "SQLException during the execution of the insert (for a " + cld.getClassOfObject().getName() + "): " + e.getMessage(), e); /** * throw a specific type of runtime exception for a key constraint. */ if (SQL_STATE_KEY_VIOLATED.equals(e.getSQLState())) { throw new KeyConstraintViolatedException(e); } else { throw new PersistenceBrokerSQLException(e); } } finally { broker.serviceStatementManager().closeResources(stmt, null); } } I'm now wondering if my problem is related to how the connection is configured. I've played with a few settings, but maybe someone else would catch it. Here's the OJB Properties: # OJB.properties -- configuration of the OJB runtime environment # Version: 1.0 # (c) 2001, 2002, 2003 Apache Software Foundation # Author: Thomas Mahler and many others # # # repository file settings # # The repositoryFile entry tells OJB to use this file as as its standard mapping # repository. The file is looked up from the classpath. # repositoryFile=C:\\devel\\eclipse\\workspace\\digitalccs\\webApplication\\WEB-INF\\repository.xml # # If the useSerializedRepository entry is set to true, OJB tries to load a # serialized version of the repository for performance reasons. # if set to false, OJB always loads the xml file. # Setting this flag to true will accelerate the startup sequence of OJB. # If set to true changes to the repository.xml file will only be detected # after maually deleting the repository.xml.serialized file. useSerializedRepository=false # # If Repository serialization is used the entry serializedRepositoryPath defines the # directory where the Repository is written to and read from. # this entry is used only when the useSerializedRepository flag is set to true # serializedRepositoryPath=. # # # PersistenceBrokerFactory / PersistenceBroker # # Th
Re: Object not PersistenceCapable error
Thanks, i'll check! On Tue, 2004-03-23 at 23:15, Brian McCallister wrote: > This usually happens if you are running against a class file (bytecode) > that was not enhanced via the JDO bytecode enhancer. I suspect that the > enhancer wasn't run, or there is a problem in the .jdo files for that > class. > > -Brian > > On Mar 23, 2004, at 10:01 AM, Philippe Guillard wrote: > > > I've got a JDOUserException/Object not PersistenceCapable error, Can > > somebody tell me in which direction i should look for my error? > > > > I only copied and adapt a working class to another one for another DB > > table. So the repository.xml is there, don't have enhanced class > > problems since i use JDO 1.0.1 for these both 2 new classes, they also > > look similar in terms of column types used, don't need to give the path > > cause it is in same directory and i use inside cocoon.(i use cocoon > > with > > mysql, sun JDO 1.0.1) > > > > Thanks for help. > > Phil > > > > > > - > > 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: Object not PersistenceCapable error
This usually happens if you are running against a class file (bytecode) that was not enhanced via the JDO bytecode enhancer. I suspect that the enhancer wasn't run, or there is a problem in the .jdo files for that class. -Brian On Mar 23, 2004, at 10:01 AM, Philippe Guillard wrote: I've got a JDOUserException/Object not PersistenceCapable error, Can somebody tell me in which direction i should look for my error? I only copied and adapt a working class to another one for another DB table. So the repository.xml is there, don't have enhanced class problems since i use JDO 1.0.1 for these both 2 new classes, they also look similar in terms of column types used, don't need to give the path cause it is in same directory and i use inside cocoon.(i use cocoon with mysql, sun JDO 1.0.1) Thanks for help. Phil - 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]
Object not PersistenceCapable error
I've got a JDOUserException/Object not PersistenceCapable error, Can somebody tell me in which direction i should look for my error? I only copied and adapt a working class to another one for another DB table. So the repository.xml is there, don't have enhanced class problems since i use JDO 1.0.1 for these both 2 new classes, they also look similar in terms of column types used, don't need to give the path cause it is in same directory and i use inside cocoon.(i use cocoon with mysql, sun JDO 1.0.1) Thanks for help. Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Packed Field (DB2/400) Mapping
Hello, I am having a problem with OJB mapping of DB2/400 Packed Field. I mapped Packed Field in DB2/400 to DECIMAL with Java type BigDecimal. When I read records from database, it is fine. But when I try to update the record using OJB, it generates a SQL with that Packed Filed as null value. For example. I have a BigDecimal aField = 12345, but in SQL, 1080015521538|1222|0|statement|UPDATE CRPIBMS SET MSACFL=?,MSCHBY=?,MSCHDT=?,MSCHTM=?,MSDADM=?,MSDATE=?,MSDATT=?,MSDBY=?,MSDCNS=?,MSDDT=?,MSDFAM=?,MSDORD=?,MSDREF=?,MSDRL1=?,MSDRL2=?,MSDRL3=?,MSDTM=?,MSFLG1=?,MSFLG2=?,MSFLG3=?,MSFROM=?,MSACC2=?,MSACCT=?,MSEPIS=?,MSFCID=?,MSUREF=?,MSRSTS=?,MSSTFL=?,MSSTS=?,MSTEXT=?,MSTIME=?,MSTO=?,MSTYPE=?,MSVBY=?,MSVDT=?,MSVTM=? WHERE MSID = ? |UPDATE CRPIBMS SET MSACFL='',MSCHBY='',MSCHDT='2004-02-11',MSCHTM='16:32:00',MSDADM='Y',MSDATE='2004-02-11',MSDATT='Y',MSDBY='',MSDCNS='',MSDDT='2004-02-11',MSDFAM='',MSDORD='',MSDREF='Y',MSDRL1='',MSDRL2='',MSDRL3='',MSDTM='16:32:00',MSFLG1='',MSFLG2='',MSFLG3='',MSFROM='LAB',MSACC2='',MSACCT='00055616',MSEPIS='1',MSFCID='100',MSUREF='2305',MSRSTS='F',MSSTFL='1',MSSTS='R',MSTEXT='ABNORMAL',MSTIME='16:32:00',MSTO='SMSWEB',MSTYPE='O',MSVBY='SMSWEB',MSVDT='2004-03-22',MSVTM='20:18:38' WHERE MSID = '1' with Packed Field MSACC2=''. Actually, it should be MSACC2='12345'. This cause SQL exception that this colume does not allow null value. Thank you for your help!
RE: soft-deleting objects
I am using this in a complex app (due to idiot admin users deleting stuff they shouldnt!). All objects have a boolean (mapped to int) "deleted". For all queries i look for objects with deleted=false. For relationships, i wrote a querycustomizer which adds deleted=false to collections. (see below example) It;s very simple and works a treat! If you have a 'base' bean, which all other beans inherit, you can put the 'deleted' attribute there, and can use a delete method for deleting any beans! (note: i dont use extents for this in the repository, just map it for all beans) -Original Message- From: Brian McCallister [mailto:[EMAIL PROTECTED] Sent: 23 March 2004 14:01 To: OJB Users List Subject: Re: soft-deleting objects If you have a "deleted" style flag in the database for the soft delete you can probably accomplish this via a query customizer. If you mean to not flag the delete in the database at all, but only treat it as such in the application -- that is a bit trickier, but can probably be done via pb callbacks/row readers. -Brian On Mar 23, 2004, at 6:21 AM, Tino Schöllhorn wrote: > Hi, > > I want to implement something like a soft-delete: > > Objects should be marked as "deleted" in its corresponing table and > OJB should just ignore them when it is materializing or querying them. > > Where would be the best point to start when I want to implement this > feature? I just played around with the RowReader-Concept - but I have > the feeling that this is not the right place to start, because I think > I have to modify the queries OJB is submitting to the database. > > Any ideas? > > Regards > Tino > > > > - > 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: soft-deleting objects
I have implemented the very same thing via a custom RowReader. I just extended the default RowReader, and read in the value from that super. After that, I just my criteria to see if I should avoid it, and return based on that. Here is my method that I implemnted that extended RowReaderDefaultImpl public Object readObjectFrom(Map row) throws PersistenceBrokerException { Object o = super.readObjectFrom(row); if (o instanceof AuditableBusinessObject) { if (((AuditableBusinessObject)o).getDeletedDate() != null) return null; } return o; } Hope this helps. -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Tino Schöllhorn Sent: Tuesday, March 23, 2004 6:21 AM To: [EMAIL PROTECTED] Subject: soft-deleting objects Hi, I want to implement something like a soft-delete: Objects should be marked as "deleted" in its corresponing table and OJB should just ignore them when it is materializing or querying them. Where would be the best point to start when I want to implement this feature? I just played around with the RowReader-Concept - but I have the feeling that this is not the right place to start, because I think I have to modify the queries OJB is submitting to the database. Any ideas? Regards Tino - 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: soft-deleting objects
If you have a "deleted" style flag in the database for the soft delete you can probably accomplish this via a query customizer. If you mean to not flag the delete in the database at all, but only treat it as such in the application -- that is a bit trickier, but can probably be done via pb callbacks/row readers. -Brian On Mar 23, 2004, at 6:21 AM, Tino Schöllhorn wrote: Hi, I want to implement something like a soft-delete: Objects should be marked as "deleted" in its corresponing table and OJB should just ignore them when it is materializing or querying them. Where would be the best point to start when I want to implement this feature? I just played around with the RowReader-Concept - but I have the feeling that this is not the right place to start, because I think I have to modify the queries OJB is submitting to the database. Any ideas? Regards Tino - 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]
Strange behaviour: Oracle sequence.nextval
Hi, I am using OJB 1.0rc5 with Oracle8. When I try to store a simple object, the following SQL queries are executed (p6spy.log): 1080045456718|15|0|statement||select TURBINE_USER_SEQ.nextval from dual 1080045456843|0|0|statement|SELECT LAST_NAME,LOGIN_NAME,FIRST_NAME,USER_ID,PASSWORD_VALUE,EMAIL FROM TURBINE_USER WHERE USER_ID = ? |SELECT LAST_NAME,LOGIN_NAME,FIRST_NAME,USER_ID,PASSWORD_VALUE,EMAIL FROM TURBINE_USER WHERE USER_ID = '40049' 1080045456859|16|0|statement||select TURBINE_USER_SEQ.nextval from dual 1080045457265|406|0|statement|INSERT INTO TURBINE_USER (USER_ID,EMAIL,FIRST_NAME,LAST_NAME,LOGIN_NAME,PASSWORD_VALUE) VALUES (?,?,?,?,?,?) |INSERT INTO TURBINE_USER (USER_ID,EMAIL,FIRST_NAME,LAST_NAME,LOGIN_NAME,PASSWORD_VALUE) VALUES ('40050','','Klaus','Richarz','neu01','BxlwjRzIFIOb2Bj9wn1EZlLw') Why is "select TURBINE_USER_SEQ.nextval from dual" executed two times ? repository.xml (snippet) Thanks in advance, Klaus Richarz Hamburger Berater Team GmbH Hamburg, Germany - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
soft-deleting objects
Hi, I want to implement something like a soft-delete: Objects should be marked as "deleted" in its corresponing table and OJB should just ignore them when it is materializing or querying them. Where would be the best point to start when I want to implement this feature? I just played around with the RowReader-Concept - but I have the feeling that this is not the right place to start, because I think I have to modify the queries OJB is submitting to the database. Any ideas? Regards Tino - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]