How to delete single objects in a referenced collection?
I'm using two classes/tables in a 1:n reference with PerstistenceBroker API. In the first table I have the machines and in the second one the currently logged on persons. In the EMPLOYEES table I'm using a PK of two columns (PERSONALID / MACHINEID). I'm not using ID. When a person logs off, it is not deleted from EMPLOYEES table when using .store(obj). The object contains the reduced collection of employees. If the machine is removed, then all looged on persons are removed, too. So my workaround is first .delete(oldObj), second .store(newObj) in a transaction. I'd rather use only store(newObj). But how to get it working? Class/collection descriptors look like this: class-descriptor class=com.aaa.bbb.ccc.ddd.Machine table=MACHINE // some field descriptors collection-descriptor name=employees element-class-ref=com.aaa.bbb.ccc.ddd.Employee auto-retrieve=true auto-update=true auto-delete=true orderby=personalid sort=ASC inverse-foreignkey field-ref=deviceID / /collection-descriptor /class-descriptor class-descriptor class=com.aaa.bbb.ccc.ddd.Employee table=EMPLOYEE field-descriptor name=familyName column=FAMILYNAME jdbc-type=VARCHAR primarykey=false autoincrement=false / field-descriptor name=firstName column=FIRSTNAME jdbc-type=VARCHAR primarykey=false autoincrement=false / field-descriptor name=personalID column=PERSONALID jdbc-type=VARCHAR primarykey=true autoincrement=false / field-descriptor name=roles column=ROLES jdbc-type=VARCHAR primarykey=false autoincrement=false / field-descriptor name=deviceID column=DEVICEID jdbc-type=VARCHAR primarykey=true autoincrement=false / /class-descriptor Cheers, Frank
Re: Oracle Driver jdbc10.1.0.2
Don Lyon wrote: I ran into a similar problem using JBoss as the managed environment. Could we add that to the list for 1.0.2? Hello Don, thank you for your report. protected static final String UNWRAP_CONN_METHOD_NAMES[] = getUnderlyingConnection /* JBoss */ [...] protected static final String UNWRAP_PS_METHOD_NAMES[] = getUnderlyingStatement /* JBoss */ I have added your patch to CVS for 1.0.x branch and 1.1 trunk. Should be out with 1.0.2 soon. If you could please test and report your results to the list. Thanks, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: composite foreign key references
hi bobby, http://marc.theaimsgroup.com/?l=ojb-userm=110504711807796w=4 an example can be found in NoPkReferenceTest jakob Bobby Lawrence schrieb: Jakob - Where can I find info about this new feature? Jakob Braeuchi wrote: hi bobby, your problem could be solved by the new relationship-definitions based on non-pk-fields. this feature is available in the cvs trunk for ojb 1.1 Armin Waibel schrieb: Hi, Project --1:n -- PrimaryInvestigator (PI) PK fields for Project: label fiscalYears why is 'id' not the PK in Project? In PI FK are: projectId fiscalYear projectId id not a PK in Project, you have to use a 'labelId'. As a side-note, be really careful when using anonymous fields for fields other than 1:1 FK. http://db.apache.org/ojb/docu/guides/advanced-technique.html#How+do+ regards, Armin Bobby Lawrence wrote: Using the PersistenceBroker API... I have a class that has a 1:n relationship - a project can have many principal investigators. The class descriptors look like this: class-descriptor class=org.jlab.mis.services.mics.client.generated.Project table=projects field-descriptor name=id column=PROJECT_ID jdbc-type=VARCHAR/ field-descriptor name=label column=REPO_CODE jdbc-type=VARCHAR primarykey=true access=anonymous / field-descriptor name=fiscalYear column=FISCAL_YEAR jdbc-type=VARCHAR primarykey=true / field-descriptor name=name column=PROJECT_NAME jdbc-type=VARCHAR / collection-descriptor name=primaryInvestigators element-class-ref=org.jlab.mis.services.mics.client.generated.PrimaryInvestigator auto-retrieve=false inverse-foreignkey field-ref=projectId / inverse-foreignkey field-ref=fiscalYear / /collection-descriptor /class-descriptor class-descriptor class=org.jlab.mis.services.mics.client.generated.PrimaryInvestigator table=pis field-descriptor name=id column=PERSON_ID jdbc-type=VARCHAR primarykey=true/ field-descriptor name=firstName column=FIRSTNAME jdbc-type=VARCHAR / field-descriptor name=lastName column=LASTNAME jdbc-type=VARCHAR / field-descriptor name=email column=EMAIL jdbc-type=VARCHAR / field-descriptor name=fiscalYear column=FISCAL_YEAR jdbc-type=VARCHAR access=anonymous primarykey=true/ field-descriptor name=projectId column=PROJECT_ID jdbc-type=VARCHAR access=anonymous / /class-descriptor The problem is, whenever OJB tries to retrieve a collection of Primary Investigators, it never uses the correct value for the composite primary key. The debugging output looks like this: [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeQuery : QueryByCriteria from class org.jlab.mis.services.mics.client.generated.PrimaryInvestigator where [projectId = 13179, fiscalYear = 13179] As you can see, it is using the exact same value for the projectId and fiscalYear attributes. What am I doing wrong? - 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: feature request?
hi bobby, tom, isn't this already solved by http://marc.theaimsgroup.com/?l=ojb-userm=110504711807796w=4 jakob Thomas Dudziak schrieb: I've added a feature request for something similar: http://issues.apache.org/scarab/issues/id/OJB312 Please add comments to the issue to describe your wish. regards, Tom - 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: feature request?
Have you tried it with the simple usecase of changing the order of FKs vs. PKs, e.g. with a unit test ? If that works, then the CR is already finished. I just wanted to make it an official CR so that the people that wanted this feature can register themselves at it for notification. regards, Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Excalibur Integration
Hi, is there a way to reuse existing connections for the whole OJB setup? I've implemented a ConnectionFactory for OJB as Excalibur component, but when I create a new database and open it (as stated in the tutorials) the repository_database.xml part is always expected. Are there any workarounds? (Best would be a complete reuse of existing connections without having to specify a repository_database.xml) Or maybe is there some way to put the repository_database.xml in a jar-file (which is possible for the entiry repository.xml but only for the whole file...) Regards Markus Wolf -- emedia-solutions wolf Wedeler Landstrasse 63 22559 Hamburg (040) 550 083 70 web: http://www.emedia-solutions-wolf.de mail: [EMAIL PROTECTED] pgp: http://wwwkeys.de.pgp.net signature.asc Description: OpenPGP digital signature
Re: feature request?
hi tom, no, this scenario is not part of the testcase. but i expect it to work, because you can declare any field to be the referenced field. but that only what i do expect ;) jakob Thomas Dudziak schrieb: Have you tried it with the simple usecase of changing the order of FKs vs. PKs, e.g. with a unit test ? If that works, then the CR is already finished. I just wanted to make it an official CR so that the people that wanted this feature can register themselves at it for notification. regards, Tom - 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: feature request?
Jakob - Is the target-field-ref attribute available in OJB 1.0.1? --Bobby Jakob Braeuchi wrote: hi bobby, tom, isn't this already solved by http://marc.theaimsgroup.com/?l=ojb-userm=110504711807796w=4 jakob Thomas Dudziak schrieb: I've added a feature request for something similar: http://issues.apache.org/scarab/issues/id/OJB312 Please add comments to the issue to describe your wish. regards, Tom - 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] -- Bobby Lawrence MIS Application Developer Jefferson Lab (www.jlab.org) Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Excalibur Integration
Markus Wolf wrote: is there a way to reuse existing connections for the whole OJB setup? I've implemented a ConnectionFactory for OJB as Excalibur component, but when I create a new database and open it (as stated in the tutorials) the repository_database.xml part is always expected. Are there any workarounds? (Best would be a complete reuse of existing connections without having to specify a repository_database.xml) Or maybe is there some way to put the repository_database.xml in a jar-file (which is possible for the entiry repository.xml but only for the whole file...) Without going into the re-use issue I can just report that there is no problem placing the different repository*.xml files in a JAR. Just make sure the DTD is there to make XML-validation possible. The files are loaded without path so place the in the root of your JAR. Regards, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: feature request?
the answer is: no jakob Bobby Lawrence schrieb: Jakob - Is the target-field-ref attribute available in OJB 1.0.1? --Bobby Jakob Braeuchi wrote: hi bobby, tom, isn't this already solved by http://marc.theaimsgroup.com/?l=ojb-userm=110504711807796w=4 jakob Thomas Dudziak schrieb: I've added a feature request for something similar: http://issues.apache.org/scarab/issues/id/OJB312 Please add comments to the issue to describe your wish. regards, Tom - 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: feature request?
OK - then I guess OJB 1.1 - do you have a targeted release date? --Bobby Jakob Braeuchi wrote: the answer is: no jakob Bobby Lawrence schrieb: Jakob - Is the target-field-ref attribute available in OJB 1.0.1? --Bobby Jakob Braeuchi wrote: hi bobby, tom, isn't this already solved by http://marc.theaimsgroup.com/?l=ojb-userm=110504711807796w=4 jakob Thomas Dudziak schrieb: I've added a feature request for something similar: http://issues.apache.org/scarab/issues/id/OJB312 Please add comments to the issue to describe your wish. regards, Tom - 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] -- Bobby Lawrence MIS Application Developer Jefferson Lab (www.jlab.org) Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: feature request?
hi bobby, in case you really expect an answer to this question, here it is: ojb 1.1 will be releasd when it's finished ;) jakob Bobby Lawrence schrieb: OK - then I guess OJB 1.1 - do you have a targeted release date? --Bobby Jakob Braeuchi wrote: the answer is: no jakob Bobby Lawrence schrieb: Jakob - Is the target-field-ref attribute available in OJB 1.0.1? --Bobby Jakob Braeuchi wrote: hi bobby, tom, isn't this already solved by http://marc.theaimsgroup.com/?l=ojb-userm=110504711807796w=4 jakob Thomas Dudziak schrieb: I've added a feature request for something similar: http://issues.apache.org/scarab/issues/id/OJB312 Please add comments to the issue to describe your wish. regards, Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: feature request?
Well - then I guess this feature doesn't help me unless I want to be working w/ a beta version of OJB --B Jakob Braeuchi wrote: hi bobby, tom, isn't this already solved by http://marc.theaimsgroup.com/?l=ojb-userm=110504711807796w=4 jakob Thomas Dudziak schrieb: I've added a feature request for something similar: http://issues.apache.org/scarab/issues/id/OJB312 Please add comments to the issue to describe your wish. regards, Tom - 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] -- Bobby Lawrence MIS Application Developer Jefferson Lab (www.jlab.org) Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: getReportQueryIteratorByQuery - Converting result object to Value Object with reflection
hi mike, you could also convert the row into a map using [attribute, value] and pass this map to the constructor of the VO. the getters/setter of the VO could the access the map. the map could also be created by the VO itself based on attributes and the row. hth jakob Mike Young schrieb: I have come up with some sort of solution that doesn't use reflection. I would be greatful if anybody can improve it, as my solution rather relies heavily on the premise that the attributes are capitalized in the same manner as the properties of the VO i.e. attrEmpId / property setEmpId(). My attempt is as follows ... row = broker.getReportQueryIteratorByQuery(query); while (row.hasNext()) { for(int i=0; iattrSubString.length; i++){ Object[] data = (Object[]) row.next(); Object arg = data[i]; String methodName = set+attrSubString[i]; EmpVO empVO = new EmpVO(); try { MethodUtils.invokeMethod(pickValueVO,methodName,arg); } catch (Exception e) { throw e; } result.add(empVO); } } On Sun, 06 Mar 2005 18:02:29 +1100, Mike Young wrote: Hi, I am trying to write a data access object that will return the results of a Report Query back as a Collection of Value List Objects based on the table row and the columns required. If I have a table employee with three columns (empid, empname, empsurname). And I have a Value Object EmpVo with appropriate getters and setters (i.e. getEmpId,setEmpId,getEmpName and so on). And for example I would like to carry out a select that returns only specific columns ... e.g. select distinct empsurname from employee or select empname,empsurname from employee My DAO is as follows ... * @param Criteria * @param (String)sortOrder - comma separated list of data columns to return * @param (String)sortOrder - comma separated list of columns to sort by * @return Iterator of ValueObject (-EmployeeValueVO) public Collection findManyByCritRpt(Criteria criteria,String attributes){ PersistenceBroker broker = null; Iterator row = null; Object[] obj = null; Collection result = new Vector(); broker = ServiceLocator.getInstance().findBroker(); ReportQueryByCriteria query = QueryFactory.newReportQuery(PickValueVO.class, criteria, distinct); // Create Column List ( turns comma separated values into String array) String[] attrSubString = TwoSqUtils.ExtractSubString(attributes.trim(),','); query.setAttributes(attrSubString); row = broker.getReportQueryIteratorByQuery(query); while (row.hasNext()) { result.add(row.next()); // *** TURN ROW into VALUE Object Here *** // // *** set(attrSubString[x]) ***// } return result; } // end findManyByCritRpt How would I go about using reflection and my attrSubString array (which lists the column names in the select) to call the appropriate setter in my Value Object and then create a (Vector) list of these Value Objects ? I am guessing I need to use the commons.beanutils class, however this is as far as I can get as I am quite new to java (3mths). Could some one help me fill in the gaps please? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to delete single objects in a referenced collection?
Hiller, Frank RD-AS2 wrote: In the first table I have the machines and in the second one the currently logged on persons. In the EMPLOYEES table I'm using a PK of two columns (PERSONALID / MACHINEID). I'm not using ID. When a person logs off, it is not deleted from EMPLOYEES table when using .store(obj). The object contains the reduced collection of employees. In the database, is the column EMPLOYEE.PERSONALID a foreign key or reference to another table? If you a dropping people from this table the sequence of things in the transaction could be important. If the removal aware collection is trying to delete EMPLOYEE when personalId is either 0/null or references a deleted tuple, I guess you will run into problems. There is also no object-level cache consistency in the PB API, so it could simply be that you are reading the object back from cache when testing? Use P6Spy to check what SQL statements are beeing sent to the database. Regards, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: feature request?
How difficult would it be to backport this feature to the 1.0 branch ? Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: feature request?
hi tom, this feature has an impact on many parts of ojb (metadata, sql-generation, accesslayer). see http://marc.theaimsgroup.com/?l=ojb-devm=110504521613856w=2 another issue is that a refactored SqlQueryStatement some time ago, so we would have to integrate this feature into the old version of SqlQueryStatement. jakob Thomas Dudziak schrieb: How difficult would it be to backport this feature to the 1.0 branch ? Tom - 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: feature request?
A pity. I could really make good use of it with the XDoclet module. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Oracle Driver jdbc10.1.0.2
Martin, It looks like unwrapping the connection in initializeJdbcConnection() is causing another problem for managed connections in JBoss. Trying to setStatementCacheSize throws the exception: Caused by: java.sql.SQLException: Statement Caching cannot be enabled for this logical connection. at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269) at oracle.jdbc.driver.OracleConnection.setStatementCacheSize(OracleConnection.j ava:4151) This wasn't a problem previously since those methods weren't available on the WrappedConnection object. I'm not sure what the solution is. If statement caching is not allowed for any pooled connections, maybe bypass unwrapping the Connection in this method. Or, if it's just some managed environments that have problems, maybe log the exception and move on instead of rethrowing PlatformException. try { // Set number of cached statements and enable implicit caching METHOD_SET_STATEMENT_CACHE_SIZE.invoke(oraConn, PARAM_STATEMENT_CACHE_SIZE); METHOD_SET_IMPLICIT_CACHING_ENABLED.invoke(oraConn, PARAM_BOOLEAN_TRUE); } catch (Exception e) { logger.debug(PlatformOracle9iImpl could not enable statement caching.); } What do you think? Don -Original Message- From: Martin Kalén [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 16, 2005 5:41 AM To: OJB Users List Subject: Re: Oracle Driver jdbc10.1.0.2 Don Lyon wrote: I ran into a similar problem using JBoss as the managed environment. Could we add that to the list for 1.0.2? Hello Don, thank you for your report. protected static final String UNWRAP_CONN_METHOD_NAMES[] = getUnderlyingConnection /* JBoss */ [...] protected static final String UNWRAP_PS_METHOD_NAMES[] = getUnderlyingStatement /* JBoss */ I have added your patch to CVS for 1.0.x branch and 1.1 trunk. Should be out with 1.0.2 soon. If you could please test and report your results to the list. Thanks, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this communication in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by e-mail, and delete the original message.
Re: DBCP, Oracle9i Blob/Clob broken
Nice work, many thanks. cheers danilo Danilo Tommasina wrote: I ended up implementing a custom DBCP connection factory that is using a BasicDataSource instead of a PooledDataSource. Since the documentation of the DBCP stuff is really ugly I didn't find out what the difference really is between the PooledDataSource and the BasicDataSource. Fact is that with the BasicDataSource based implementation the problem with the MAX_OPEN_CURSORS is solved, because a fixed-size PreparedStatement cache is used. I had a look in DBCP CVS and the BasicDataSource is really only a specialiced implementation of PooledDataSource with more user-friendly getter/setters. It will use AbandonedObjectPool or GenericObjectPool for connection storage. With PooledDataSource you can choose any underlying pool you want and just supply a factory that could eg return your own pool implementations. (But you have no nice setter like setMaxIdle, since you can't rely on any specifics on the object pool.) I think it makes sence to keep PooledDataSource in OJB, which enables the configuration to be more generic in OJB1.1. However, I was able to work around the MAX_OPEN_CURSORS error by adding a check in the default DBCP connection factory: if platform is Oracle9i then don't use DBCP PreparedStatement caching. After fixing so that the factory calls initializeJdbcConnection properly, this allows the Oracle9i platform impl to manage the statement caching. Note that it is necessary to implement/override also the releaseAllResources() method for closing the pooled connections on application shutdown. This is now fixed in the DBCP factory in CVS. These changes are only in OJB_1_0_RELEASE branch yet, I will now merge them with head. Regards, Martin - 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]