how to re-read repository.xml file without restarting software?
Hi, How to re-read repository.xml file without restarting software? This would nice to have when developing software. Thanks, Joose - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reportQuery and functions in query
To make this question simpler, how to do reportquery where: queryArguments[0] ="id"; queryArguments[1] ="sum(foo.bar * foo.quux *)"; Thanks, Joose Joose Vettenranta kirjoitti 23.11.2007 kello 14.59: Hi, I have query that has like SELECT sum(foo) FROM bar; and that works ok. Problem comes with following syntax: SELECT sum(foo * quux) FROM bar; Code goes something like this: query=new org .apache.ojb.broker.query.ReportQueryByCriteria(ibizobj.getClass(), criteria); queryArguments[0]="id"; queryArguments[7]="sum(orderItems.unitPrice * orderItems.amount)"; query.setAttributes(queryArguments); groupArguments[0]="id"; query.addGroupBy(groupArguments); query.setPathOuterJoin("orderItems"); and outcome: SELECT looks like this on server: SELECT ...sum(orderItems.unitPrice * orderItems.amount)... and respone: "adding missing FROM" and "orderItems not found".. it should do something like SELECT sum(A2.unitPrice * A2.amount).. Is this feature that is not implemented in 1.0.4 or am I missing something? Thanks, Joose - 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]
reportQuery and functions in query
Hi, I have query that has like SELECT sum(foo) FROM bar; and that works ok. Problem comes with following syntax: SELECT sum(foo * quux) FROM bar; Code goes something like this: query=new org.apache.ojb.broker.query.ReportQueryByCriteria(ibizobj.getClass(), criteria); queryArguments[0]="id"; queryArguments[7]="sum(orderItems.unitPrice * orderItems.amount)"; query.setAttributes(queryArguments); groupArguments[0]="id"; query.addGroupBy(groupArguments); query.setPathOuterJoin("orderItems"); and outcome: SELECT looks like this on server: SELECT ...sum(orderItems.unitPrice * orderItems.amount)... and respone: "adding missing FROM" and "orderItems not found".. it should do something like SELECT sum(A2.unitPrice * A2.amount).. Is this feature that is not implemented in 1.0.4 or am I missing something? Thanks, Joose - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
problem with collection
Hello, I'm trying to update my class but it does not remove removed items from the collection. So, when I add new items to the collection, in DB there are copies of those old instances. So, when restarting application, it fetches too many instances (old ones and new ones). May 17 15:50:33 kanta1 postgres[17491]: [113-1] LOG: statement: SELECT 1 May 17 15:50:33 kanta1 postgres[17491]: [114-1] LOG: statement: UPDATE ibiz_invoices SET global_id=397,client=' May 17 15:50:33 kanta1 postgres[17491]: [114-7] 12345-67890',order_description='',payment_terms=35,notification_time=8,i nterest='9.500',notification_payment='10.00' WHERE id = May 17 15:50:33 kanta1 postgres[17491]: [114-8] 39 May 17 15:50:33 kanta1 postgres[17491]: [115-1] LOG: statement: commit;begin; This only happens if I have first created the original object and then tried to update it. So if I restart my application and try this again to same object, then it removes references. code: dao.begin(); ibizobj.setId(id); ibizobj=dao.retrieve(ibizobj); col = ibizobj.getOrderItems(); // col == java.util.Collection print (col.size()); // outputs 5 col.clear(); print (col.size()); // outputs 0 dao.update(ibizobj); //nothing is deleted from db dao-code: dao.update == broker.store(bean, ObjectModificationDefaultImpl.UPDATE); repository: table="ibiz_invoices"> ... delete="true" auto-update="true" element-class-ref="com.intertechnika.ibiz.invoices.InvoiceItem"> table="ibiz_invoice_items"> ... type="INTEGER" access="anonymous" /> ref="com.intertechnika.ibiz.invoices.Invoice" auto-retrieve="true" auto-update="false" auto-delete="false"> Only thing that seems to work is to do it like this: dao.begin(); ibizobj.setId(id); ibizobj=dao.retrieve(ibizobj); col = ibizobj.getOrderItems(); // col == java.util.Collection //PSEUDO CODE STARS HERE foreach orderItem do dao.remove(orderItem); //PSEUDO CODE ENDS HERE dao.update(ibizobj); //nothing is deleted from db Using ojb 1.0.1 and java 1.4.2 I tried to look from release notes that if this is a bug that is fixed, but did not find anything. Thanks, Joose Vettenranta
Using proxy and requirements for java-files
Hi, I want to use generic proxy for "lazy loading" 1:n connections. Say I have class Foo Do I need to have also Interface for class Foo to make proxy to work? Say like Interface IntFoo or does the generic proxy thingie work without that custom Interface? Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: feature or a bug?
I have in repository like this: proxy="dynamic"> and then net.vettenranta.Everything1 doesn't have anything special defined for that Interface. what I read from documentation, it should use outer left join for those fields automaticly if extent is used. but it doesn't. I don't know does it matter, but I'm not retrieving collection, I'm retrieving Iterator. - Joose Joose Vettenranta kirjoitti 19.12.2005 kello 16:31: Hi, I'm using interface to get lot's of data from different tables.. But I have a problem. query.addOrderBy(field); it orders by result, but per table, not whole result. When looking at postgresql query log, I see that it is implemented like this: SELECT ... FROM bar1 orderBy fieldID; SELECT ... FROM bar2 orderBy fieldID; SELECT ... FROM bar3 orderBy fieldID; so, of course it won't sort it right.. wouldn't it work better, if it would generate it like this: SELECT .. FROM bar1 UNION SELECT .. FROM bar2 UNION SELECT .. FROM bar2 order by fieldID; or have I configured it wrong? - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
feature or a bug?
Hi, I'm using interface to get lot's of data from different tables.. But I have a problem. query.addOrderBy(field); it orders by result, but per table, not whole result. When looking at postgresql query log, I see that it is implemented like this: SELECT ... FROM bar1 orderBy fieldID; SELECT ... FROM bar2 orderBy fieldID; SELECT ... FROM bar3 orderBy fieldID; so, of course it won't sort it right.. wouldn't it work better, if it would generate it like this: SELECT .. FROM bar1 UNION SELECT .. FROM bar2 UNION SELECT .. FROM bar2 order by fieldID; or have I configured it wrong? - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with interface
Thomas Dudziak kirjoitti 29.11.2005 kello 14:32: Can I fix this somehow or do I have to use global unique id as primary key? This depends on how you mapped these types. Please post your repository xml file. Well, I solved problem already.. I renamed current unique id (primary key) as "classId" (and removed primary key) and created new id (primary key) which sequence is common for every class in that current interface. So now it works. - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with interface
Hi, I have like this: public class A implements Foo { private Integer id; ... getter/setter.. } public class B implements Foo { private Integer id; ... getter/setter.. } public interface Foo { public Integer getId(); public void setId(); } Both A and B has unique id's.. so both can have values with id=5; When I do query to that Interface, I get values for class B objects from class A objects if ID value is the same. Can I fix this somehow or do I have to use global unique id as primary key? Thanks, Joose ps. using ojb 1.0.1 -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: collection-descriptor and 2 id's
Hi, I was reading code repository and saw that in there, there is support for non PK-fields as TARGET_FIELD_REF in the CollectionDescriptor.java. It's in revision 1.33, but is it going to be backported to 1.0 and if not, when is 1.1 going to be released and how compatible is 1.1 with 1.0? Thanks, Joose Joose Vettenranta kirjoitti 26.8.2005 kello 11:12: Hi, I have a class that has 2 unique ID field. like id and global_id id is for just that table and global_id is common for every object in the database and so unique in that way. But I want to have Collection that points to that global_id and not to id. Normal Collection is done like this: ref="net.vettenranta.LogEntry"> But that of course won't work. So reading documents, I saw fk-pointing-to-this-class but it is used for m:n connections, not for this stuff. So, how to make collection work with the second unique ID and with another collection with normal ID? There should be a way to speficy to which field that collection is referrring to. Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
collection-descriptor and 2 id's
Hi, I have a class that has 2 unique ID field. like id and global_id id is for just that table and global_id is common for every object in the database and so unique in that way. But I want to have Collection that points to that global_id and not to id. Normal Collection is done like this: ref="net.vettenranta.LogEntry"> But that of course won't work. So reading documents, I saw fk-pointing-to-this-class but it is used for m:n connections, not for this stuff. So, how to make collection work with the second unique ID and with another collection with normal ID? There should be a way to speficy to which field that collection is referrring to. Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to make search
Hi, I tried to make generic search using ojb, but didn't work how I was planning it to work, naturally =) I have framework created so that class that I'm searching is passed to that generic search function, so only fields has to be checked. My idea was this (pseudo code): Criteria crit = new Criteria(); foreach search-field as field { Criteria crit2 = new Criteria(); crit2.addLike (field, "%" + getValue(field) + "%"); crit.addOrCriteria (crit2); } --- problem is that when field is integer, it transformed to: SELECT . Where field like %value%; I tried also adding ' signs to like field, but it worked ok with integers but not ok with strings. Is here SQL-injection possibility?? but what I want is to have "%value%". Of course what I really want is to have some sort of check so that it would check 1) that field exists 2) to make Like operation to work ok with every object type. There was some sort of OJBSearchFilter, but what I understood from javadoc, it's nothing to be used here. Pointers, helps? Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
BUG(?): 2 classes, same table name, different database
If this is a bug, hope some developer knows how to fix this. for now, I made this "glue" solution, I just add database in front of every table name. like db1_admin db2_admin and then ojb doesn't mix up those data. more information: in db1: create table admin ( uid varchar(20) not null, password varchar(20) not null, primary key(uid)); in db2: create table admin ( id serial, login varchar(30) not null, password varchar(30) not null, email varchar(100), primary key(id)); so when trying to fetch admin from db2 it tries to take uid also and SqlException happenens (see below) Thanks, Joose 15.11.2004 kello 13:57, Joose Vettenranta kirjoitti: So, is this a bug in OJB? So one software, 2 database 2 classes 2 different kind of table, but they are both named same => table <-> class mapping is not working - Joose 12.11.2004 kello 09:43, Joose Vettenranta kirjoitti: I forgot to say, that I have different dbuser and different connection for both of dabases. And both connection is described with jdbc-connection-descriptor -element and using : Thanks, Joose 12.11.2004 kello 09:33, Joose Vettenranta kirjoitti: Hi, I have 2 databases, let's call them db1 and db2 in db1 I have table called admin in db2 I have also table called admin but they are not like each other, they have different kind of table structure. for db1 I have a class to access table admin, let's call it net.vettenranta.db1.AdminImpl; for db2 I have a class to access table admin, let's call it net.vettanranta.db2.Admin; Now, here is the problem: when I try to get data from db2 it tries also get db1's fields (most likely same happens to db1 class, but have not tried yet) which causes error: Caused by: java.sql.SQLException: ERROR: No such attribute a0.uid So, is it possible to tell ojb that "heyy, it's this db2.Admin reference you have to use from repository, not db1.AdminImpl"? Using ojb1.0.1 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
auto-retrieve="false" and retrieving that
Hi, I have a collection which has auto-retrieve="false". Now I need that information, how can I make it to retrieve it? I tried using broker.getAllReferences (obj) but it didn't work. or do I just have to use getCollectionByQuery? Using ojb101 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
BUG(?): 2 classes, same table name, different database
So, is this a bug in OJB? So one software, 2 database 2 classes 2 different kind of table, but they are both named same => table <-> class mapping is not working - Joose 12.11.2004 kello 09:43, Joose Vettenranta kirjoitti: I forgot to say, that I have different dbuser and different connection for both of dabases. And both connection is described with jdbc-connection-descriptor -element and using : Thanks, Joose 12.11.2004 kello 09:33, Joose Vettenranta kirjoitti: Hi, I have 2 databases, let's call them db1 and db2 in db1 I have table called admin in db2 I have also table called admin but they are not like each other, they have different kind of table structure. for db1 I have a class to access table admin, let's call it net.vettenranta.db1.AdminImpl; for db2 I have a class to access table admin, let's call it net.vettanranta.db2.Admin; Now, here is the problem: when I try to get data from db2 it tries also get db1's fields (most likely same happens to db1 class, but have not tried yet) which causes error: Caused by: java.sql.SQLException: ERROR: No such attribute a0.uid So, is it possible to tell ojb that "heyy, it's this db2.Admin reference you have to use from repository, not db1.AdminImpl"? Using ojb1.0.1 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: 2 classes, same table name, different database
I forgot to say, that I have different dbuser and different connection for both of dabases. And both connection is described with jdbc-connection-descriptor -element and using : Thanks, Joose 12.11.2004 kello 09:33, Joose Vettenranta kirjoitti: Hi, I have 2 databases, let's call them db1 and db2 in db1 I have table called admin in db2 I have also table called admin but they are not like each other, they have different kind of table structure. for db1 I have a class to access table admin, let's call it net.vettenranta.db1.AdminImpl; for db2 I have a class to access table admin, let's call it net.vettanranta.db2.Admin; Now, here is the problem: when I try to get data from db2 it tries also get db1's fields (most likely same happens to db1 class, but have not tried yet) which causes error: Caused by: java.sql.SQLException: ERROR: No such attribute a0.uid So, is it possible to tell ojb that "heyy, it's this db2.Admin reference you have to use from repository, not db1.AdminImpl"? Using ojb1.0.1 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
2 classes, same table name, different database
Hi, I have 2 databases, let's call them db1 and db2 in db1 I have table called admin in db2 I have also table called admin but they are not like each other, they have different kind of table structure. for db1 I have a class to access table admin, let's call it net.vettenranta.db1.AdminImpl; for db2 I have a class to access table admin, let's call it net.vettanranta.db2.Admin; Now, here is the problem: when I try to get data from db2 it tries also get db1's fields (most likely same happens to db1 class, but have not tried yet) which causes error: Caused by: java.sql.SQLException: ERROR: No such attribute a0.uid So, is it possible to tell ojb that "heyy, it's this db2.Admin reference you have to use from repository, not db1.AdminImpl"? Using ojb1.0.1 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Bug in Cache?
Hi, actually changing the code is in this case very very difficult, so the question is, can this be accomplished using ojb? Something like making reference-descriptor readonly or something? Problem, I save referenceId and ojb cache won't make connection between id and reference object. Thanks, Joose 28.10.2004 kello 11:17, Joose Vettenranta kirjoitti: I think I know why this is happening. I save to tableB just a id of tableC not the object of tableC. So I have to change my program so it saves objectC and not id of objectC. - Joose 28.10.2004 kello 10:40, Joose Vettenranta kirjoitti: Hi, I think I found a bug from Cache. I Think I have like this: Table A [1:n] Table B [1:1] Table C [1:n] Table D when using DefaultCacheImpl or ObjectCachePerClassImpl it works funny. When I store data it works ok, data is stored to database, but when I want to retrieve data from database I just get TableA and TableB on the object I just inserted. But when I restart my application, all of the data is loaded like it should. When using ObjectCachePerBrokerImpl it works ok, but then it won't cache that much. So data is not retrieved like it should when I retrieve data after inserting it, unless I restart tomcat in meanwhile. It looks very much as a bug. So when I insert data only table A and table B is retrieved, but when retrieving data after restart, also C and D is loaded. In repository.xml in every reference-descriptor and collection-descriptor there is auto-retrieve="true" Is this a bug? Using ojb 1.0.1 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Bug in Cache?
I think I know why this is happening. I save to tableB just a id of tableC not the object of tableC. So I have to change my program so it saves objectC and not id of objectC. - Joose 28.10.2004 kello 10:40, Joose Vettenranta kirjoitti: Hi, I think I found a bug from Cache. I Think I have like this: Table A [1:n] Table B [1:1] Table C [1:n] Table D when using DefaultCacheImpl or ObjectCachePerClassImpl it works funny. When I store data it works ok, data is stored to database, but when I want to retrieve data from database I just get TableA and TableB on the object I just inserted. But when I restart my application, all of the data is loaded like it should. When using ObjectCachePerBrokerImpl it works ok, but then it won't cache that much. So data is not retrieved like it should when I retrieve data after inserting it, unless I restart tomcat in meanwhile. It looks very much as a bug. So when I insert data only table A and table B is retrieved, but when retrieving data after restart, also C and D is loaded. In repository.xml in every reference-descriptor and collection-descriptor there is auto-retrieve="true" Is this a bug? Using ojb 1.0.1 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Bug in Cache?
Hi, I think I found a bug from Cache. I Think I have like this: Table A [1:n] Table B [1:1] Table C [1:n] Table D when using DefaultCacheImpl or ObjectCachePerClassImpl it works funny. When I store data it works ok, data is stored to database, but when I want to retrieve data from database I just get TableA and TableB on the object I just inserted. But when I restart my application, all of the data is loaded like it should. When using ObjectCachePerBrokerImpl it works ok, but then it won't cache that much. So data is not retrieved like it should when I retrieve data after inserting it, unless I restart tomcat in meanwhile. It looks very much as a bug. So when I insert data only table A and table B is retrieved, but when retrieving data after restart, also C and D is loaded. In repository.xml in every reference-descriptor and collection-descriptor there is auto-retrieve="true" Is this a bug? Using ojb 1.0.1 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ReportQuery using multiple tables
Hi, 19.10.2004 kello 09:40, [ Muliawan Sjarif ] kirjoitti: Before the query is executed add the following lines: query.addGroupBy("name"); query.addGroupBy("value"); Yes, that did the trick. Stil, it's not adding enough tables to FROM part of SQL-clause. It is working, but it's not very good formed SQL it's creating. So still there is just FROM tableB you can refer to ojb's doc for further details: /db-ojb-1.0.1/doc/docu/guides/query.html That didn't help to that multiple tables to FROM (although, I checked from the website same file). - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ReportQuery using multiple tables
Hi, did not work. Why, well: 1. It didn't do correct SQL, it did like this: SELECT count(A0.name),A0.name,A0.value FROM tableB A0 WHERE ( tableA.foo = '1') AND (tableB.Aid = tableB.id) which is not, correct... it causes error because name and value is not grouped. 2. in FROM there is missing tableA which causes in PostgreSQL a NOTICE but works. But some another db might not work. Source is like this: Criteria crit = new Criteria(); crit.addEqualTo("tableA.foo", "1"); Criteria crit2 = new Criteria(); crit2.addEqualTo("tableB.Aid", "tableA.id"); crit.addAndCriteria (crit2); ReportQueryByCriteria query = new ReportQueryByCriteria(Item.class, crit); query.setAttributes(new String[] {"count(name)", "name", "value"}); Correct SQL should be like: SELECT COUNT(name),name,value FROM tableA, tableB WHERE tableB.Aid = tableA.id AND tableA.foo=1 GROUP BY name,value; - Joose 15.10.2004 kello 16:18, [ Muliawan Sjarif ] kirjoitti: Almost correct except a few things: 1. Instead of tableB, use your reference to tableB.class in tableA.class 2. setColumns has been deprecated. Use setAttributes instead. On Fri, 15 Oct 2004 13:09:48 +0300, Joose Vettenranta <[EMAIL PROTECTED]> wrote: Hi, I have tested that following SQL-clause works: select count(tableB.name),tableB.name,tableB.value from tableA, tableB where tableB.Aid = tableA.id and tableA.foo=1 group by name,value; But how to create it with reportQuery? Something like this? ReportQueryByCriteria query; Criteria crit; crit = new Criteria(); crit.addEqualTo("foo", "1"); query = new ReportQueryByCriteria(tableA.class, crit); query.setColumns(new String[] { "count(tableB.name)", "tableB.name", "tableB.value" }); broker.getReportQueryIteratorByQuery(query); documentation about ReportQuery is not very good.. Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "It is your attitude, and not your aptitude, that determines your altitude" - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ReportQuery using multiple tables
Hi, I have tested that following SQL-clause works: select count(tableB.name),tableB.name,tableB.value from tableA, tableB where tableB.Aid = tableA.id and tableA.foo=1 group by name,value; But how to create it with reportQuery? Something like this? ReportQueryByCriteria query; Criteria crit; crit = new Criteria(); crit.addEqualTo("foo", "1"); query = new ReportQueryByCriteria(tableA.class, crit); query.setColumns(new String[] { "count(tableB.name)", "tableB.name", "tableB.value" }); broker.getReportQueryIteratorByQuery(query); documentation about ReportQuery is not very good.. Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pbapi + select from multiple tables
Of course if I put that it's not auto-fetched. But how can I command it to fetch collection from object? Collection col = bean.getCollection() ... then what? - Joose 21.8.2004 kello 10:08, Joose Vettenranta kirjoitti: No, I don't... I could do it, but then I have a problem, how do I prevent it to load all of that info when fetching one? if I have BAR is like tree and FOO is just a list where 1 entry belongs to one node. So if I have collection on auto-fetch and reference as auto-fetch, then what ever I fetch from BAR or FOO, every entry in BAR and FOO is fetched. Right? - Joose 20.8.2004 kello 15:12, Clóvis Wichoski kirjoitti: Hi, in your BAR class you don't declare a collection for FOO, and a collection for BAR childs? Joose Vettenranta wrote: I have like FOO and BAR classes and it's 1:n connection.. There can be lot's of FOO pointing to same BAR id and BAR has parent id which points to BAR itself now I would like to fetch something from that tree.. My first idea was this: in SQL: select * from FOO,BAR where BAR.parent= and BAR.id=FOO.bar_id; but now that I was writing this, can I some how fetch the subtree from BAR? basicely BAR is a tree where there is 1 root element and then childs and their childs .. etc.. I tried to look at http://db.apache.org/ojb/docu/guides/query.html but couldn't find anything to help me. of course one option could be to make a recursive function to go through whole tree, maybe it's what I have to do... Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - 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] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: pbapi + select from multiple tables
No, I don't... I could do it, but then I have a problem, how do I prevent it to load all of that info when fetching one? if I have BAR is like tree and FOO is just a list where 1 entry belongs to one node. So if I have collection on auto-fetch and reference as auto-fetch, then what ever I fetch from BAR or FOO, every entry in BAR and FOO is fetched. Right? - Joose 20.8.2004 kello 15:12, Clóvis Wichoski kirjoitti: Hi, in your BAR class you don't declare a collection for FOO, and a collection for BAR childs? Joose Vettenranta wrote: I have like FOO and BAR classes and it's 1:n connection.. There can be lot's of FOO pointing to same BAR id and BAR has parent id which points to BAR itself now I would like to fetch something from that tree.. My first idea was this: in SQL: select * from FOO,BAR where BAR.parent= and BAR.id=FOO.bar_id; but now that I was writing this, can I some how fetch the subtree from BAR? basicely BAR is a tree where there is 1 root element and then childs and their childs .. etc.. I tried to look at http://db.apache.org/ojb/docu/guides/query.html but couldn't find anything to help me. of course one option could be to make a recursive function to go through whole tree, maybe it's what I have to do... Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - 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] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
pbapi + select from multiple tables
I have like FOO and BAR classes and it's 1:n connection.. There can be lot's of FOO pointing to same BAR id and BAR has parent id which points to BAR itself now I would like to fetch something from that tree.. My first idea was this: in SQL: select * from FOO,BAR where BAR.parent= and BAR.id=FOO.bar_id; but now that I was writing this, can I some how fetch the subtree from BAR? basicely BAR is a tree where there is 1 root element and then childs and their childs .. etc.. I tried to look at http://db.apache.org/ojb/docu/guides/query.html but couldn't find anything to help me. of course one option could be to make a recursive function to go through whole tree, maybe it's what I have to do... Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extent problem
Hi, it seems that when I try to get Child it also get's SuperChild.. even though I haven't said that it should get superchild. All I want is to get just Child not superCHild.. Perhaps it's not possible to get like this? You'll need to add a field called 'ojbConcreteClass' so that OJB knows which class to instantiate. Or you can super-references (in which case you don't need to duplicate the fields from Child in SuperChild in the repository file). See here for details on these strategies: http://db.apache.org/ojb/docu/guides/advanced- technique.html#Mapping+Inheritance+Hierarchies I solved it so, that I made 3 classes abstarct A B extends A C extends A and in code I call B or C not A. But still, B and C can't use same table name. Oh well, can't have everything. Problem is that now I have to change every class to use C instead of using A or B. What I would like to do like this: A B extends A and use B where B's extra stuff is needed and A where it's not needed. This way I can change just few files to use B and use A elsewhere. Now I have to change everything to use B. Also I don't know whether two connections on the same database works. You might run into problems with the cache. You should definitly have a look at the different cache implementations provided with OJB: Yes, this was a problem and solved in CVS. - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extent problem
Hi, it seems that when I try to get Child it also get's SuperChild.. even though I haven't said that it should get superchild. All I want is to get just Child not superCHild.. Perhaps it's not possible to get like this? How about if I do Child interface and SuperChild implements Child and ChildImpl implements Child could it work then? - Joose 13.8.2004 kello 16:50, Thomas Dudziak kirjoitti: Joose Vettenranta wrote: I did this and it did not work. I get this: java.lang.NullPointerException ... java.lang.VerifyError: Class net.vettenranta.super.Child overrides final method jdoReplaceFlags.()V at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:256) at org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:30) at org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:98) at org.apache.ojb.broker.metadata.RepositoryXmlHandler.startElement(Repos it oryXmlHandler.java:199) . using: 1.0rc6 Hmm, can't help you with the JDO stuff. You should post this error again (with the URL to your doc/tutorial) in a new thread with JDO in the message label (to attract the JDO experts). Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extent problem
Hi, I actually solved that JDO, problem but now my problems continue... I made that superchild and child has same table name.. superchild uses different connection than connection using child object. But when I try to fetch Child, it actually tries to get SuperChild and not Child -> SQL-error. Is this feature or have I done something wrong? - Joose 13.8.2004 kello 16:50, Thomas Dudziak kirjoitti: Joose Vettenranta wrote: I did this and it did not work. I get this: java.lang.NullPointerException ... java.lang.VerifyError: Class net.vettenranta.super.Child overrides final method jdoReplaceFlags.()V at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:256) at org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:30) at org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:98) at org.apache.ojb.broker.metadata.RepositoryXmlHandler.startElement(Repos it oryXmlHandler.java:199) . using: 1.0rc6 Hmm, can't help you with the JDO stuff. You should post this error again (with the URL to your doc/tutorial) in a new thread with JDO in the message label (to attract the JDO experts). Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extent problem
You have to specify the extent-class as the first sub-tag of class-descriptor (see http://db.apache.org/ojb/docu/guides/repository.html#class-descriptor for details). Also, you have to duplicate all fields/references/collections from Child in SuperChild, currently they are not automatically 'inherited' in the descriptor of the sub class. I did this and it did not work. I get this: java.lang.NullPointerException ... java.lang.VerifyError: Class net.vettenranta.super.Child overrides final method jdoReplaceFlags.()V at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:256) at org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:30) at org.apache.ojb.broker.util.ClassHelper.getClass(ClassHelper.java:98) at org.apache.ojb.broker.metadata.RepositoryXmlHandler.startElement(Reposit oryXmlHandler.java:199) . using: 1.0rc6 I would recommend that you use the OJB and JDO Xdoclet modules (OJB module is part of OJB, the JDO module can be downloaded from http://xdoclet.sourceforge.net/xdoclet/index.html) to generate these two files, they will make things a lot easier for you. Have to look into it. - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extent problem
Hi, everything else except SuperChild is in http://joose.iki.fi/ojb/ SuperChild.java I already pasted. repository.xml: packages.jdo about SuperChild I already posted. - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extent problem
12.8.2004 kello 15:03, Thomas Dudziak kirjoitti: Joose Vettenranta wrote: Clarifying myself: I want to have just one table in SQL called child. And software eather uses Child or SuperChild (same table name in both). I tried moving (repository.xml) extent-class to superclass, but didn't help. I don't know about JDO, but you probably have to specify both Child and SuperChild in both the jdo file and the repository file. I have Child in jdo and it works ok but Superchild I told what kind it is: - Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extent problem
Clarifying myself: I want to have just one table in SQL called child. And software eather uses Child or SuperChild (same table name in both). I tried moving (repository.xml) extent-class to superclass, but didn't help. - Joose 12.8.2004 kello 14:50, Joose Vettenranta kirjoitti: Hi, I'm having problems on using extent-class and extending java-classes.. I have like this: class SuperChild extends Child { private int age; // getters and setters } class Child { private int id; private Parent parent; private String name; } and in jdo-file I have: and it goes OK enhancing. repository.xml: and result is: org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: Can not init Identity for given object [EMAIL PROTECTED] What could be wrong? Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
extent problem
Hi, I'm having problems on using extent-class and extending java-classes.. I have like this: class SuperChild extends Child { private int age; // getters and setters } class Child { private int id; private Parent parent; private String name; } and in jdo-file I have: and it goes OK enhancing. repository.xml: and result is: org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException: Can not init Identity for given object [EMAIL PROTECTED] What could be wrong? Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
about extent class
Hi, I was looking at extent-class and what I didn't get was how it really works.. So here is an exmaple: I have 1:n relation (parent:childs).. and I want to create superchild.. like 1:n (parent:superchild) is it possible to do just in SQL: CREATE TABLE super_child ( id integer, name varchar(50), age integer, parent_id integer, PRIMARY KEY(id), FOREIGN KEY (parent_id) REFERENCES parent(id)); and in repository.xml just this: and of course class-descriptor for Child would have (id, name and parent field-descriptors and reference-descriptors). Or do I just have to copy&paste whole child to superChild? Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: persistence broker and cache and different connection
Seems like I got it to work. Changed from OJB.properties to cache per Broker. - Joose 3.8.2004 kello 15:56, Joose Vettenranta kirjoitti: Hi, I have my software running as 2 instance.. using connection-descriptor A and B both A and B uses same classes. problem: if I create something on A it is cached - good, ok if I create something on B it is cached - good, ok but problem is that A and B's cache is the same. So if I look at bean with connection B and it is previously viewed by connection A, then A's value is shown, always.. So, how can I make that cache persistent to connections? So that when I do like: dao.retrieve(bean(3), fromTableA) != dao.retrieve (bean(3), fromTableB); both ones are the same, even though the database is different. Using persistentbroker and ojb 1.0.rc6 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
persistence broker and cache and different connection
Hi, I have my software running as 2 instance.. using connection-descriptor A and B both A and B uses same classes. problem: if I create something on A it is cached - good, ok if I create something on B it is cached - good, ok but problem is that A and B's cache is the same. So if I look at bean with connection B and it is previously viewed by connection A, then A's value is shown, always.. So, how can I make that cache persistent to connections? So that when I do like: dao.retrieve(bean(3), fromTableA) != dao.retrieve (bean(3), fromTableB); both ones are the same, even though the database is different. Using persistentbroker and ojb 1.0.rc6 Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
how to change auto-retrieve for a query?
Hi, I want to retrieve lot's of data and not to retrieve it's childs (1:n relationship). I'm using like: PersistenceManager persistenceManager = pmf.getPersistenceManager(); PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); QueryByCriteria query = QueryFactory.newQuery (beanClass, criteria, true); Collection results = broker.getCollectionByQuery(query); broker.close(); return results; but what do I have to say that it does not retreive beanClasses childs? Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: removing a child from 1:n [SOLVED] [WORKING]
I just wanted to say, that I got it to work.. I did it so, that in the Child i made delete -variable which is checked on update-action (not very good if there is million child). So my DAO.update() is like this now: public void update(Parent bean, JdoPMF pmf) { PersistenceManager persistenceManager = pmf.getPersistenceManager(); PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); Iterator it = bean.getChilds().iterator(); broker.beginTransaction(); while (it.hasNext()) { Child child = it.next(); if (child.getDelete()) { broker.delete(child); it.remove(); } } broker.store(bean, ObjectModificationDefaultImpl.UPDATE); broker.commitTransaction(); broker.close(); } and it works. Thanks, Joose 26.7.2004 kello 11:36, Joose Vettenranta kirjoitti: 24.7.2004 kello 21:09, Jakob Braeuchi kirjoitti: hi joose, i assume you're using pb-api now. please check the following doku: http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto- xxx+setting Seems like auto-update does only INSERT or UPDATE. and auto-delete removes everything. So seems like I just have to do PersistenceBroker.delete(...) to every deleted child to get them deleted. Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: removing a child from 1:n
24.7.2004 kello 21:09, Jakob Braeuchi kirjoitti: hi joose, i assume you're using pb-api now. please check the following doku: http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto- xxx+setting Seems like auto-update does only INSERT or UPDATE. and auto-delete removes everything. So seems like I just have to do PersistenceBroker.delete(...) to every deleted child to get them deleted. Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: removing a child from 1:n
Hi, this is how I understood the documentation: If auto-delete="true" and I want to remove parent and all childs, it is removed. But if only one child is going to be deleted, I have to do delete to each child itself? So auto-update does not support deleting one child from the Collection.. It's eather everything or none. So, I have to do Delete queue to DAO and on update delete those in the queue. Thanks, Joose 24.7.2004 kello 21:09, Jakob Braeuchi kirjoitti: hi joose, i assume you're using pb-api now. please check the following doku: http://db.apache.org/ojb/docu/guides/basic-technique.html#1%3An+auto- xxx+setting hth jakob Joose Vettenranta schrieb: Hi, how do I remove one child from 1:n mapping? Do I just do dao.remove (thatCurrentChild, factory), or can I somehow "mark" certain childs to be deleted on dao.update(bean, factory)? My software is found from http://joose.iki.fi/ojb/ Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - 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] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
removing a child from 1:n
Hi, how do I remove one child from 1:n mapping? Do I just do dao.remove (thatCurrentChild, factory), or can I somehow "mark" certain childs to be deleted on dao.update(bean, factory)? My software is found from http://joose.iki.fi/ojb/ Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this a bug?
That sounds interesting.. I never got to DELETE to go that far, so I really don't know. I think my original DAO had problem with not understunding relations.. Maybe it was a JDO thing and not told in JDO that there is relation - but I didn't find any good documentation about JDO. This PBApi seems to work ok for insert/update/delete .. I'm trying now to do select. Thanks, Joose 24.7.2004 kello 14:37, Jakob Braeuchi kirjoitti: hi joose, yes PBApi is PersistenceBroker-API. PBApi is the low-level api and thus it does not provide the advanced stufff of otm and jdo. btw. when using your old dao i do have a problem in remove(). the two children are deleted as expected but the second one is added again ?! -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is this a bug?
Well, it might have been.. I don't know what you ment with PbApi, so I think you were refeerring to PersistenceBroker .. So I wrote DAO again using only that and guess what.. it seems to work.. I updated my test script to do UPDATE also and did a for-loop of repeating those for 100 times.. Seems to work! So there was nothing wrong with my mappings or anything, it was the DAO thingie which was broken. 24.7.2004 kello 14:03, Jakob Braeuchi kirjoitti: the PbApi hint was not too useful for you i think ;) anyway i was playing with your sample a little bit and found some issues. i have to admit that i'm neither an otm- nor a jdo-crack, so there may be better solutions. - the collection descriptor in parent should be defined otm-dependent="true". I actually removed that and put auto-retrieve="yes" auto-update="yes" and auto-remove="yes" and seems to work - the pk of child must NOT be readonly. you are right, because if it's readonly, then when inserting, it will create new primarykey for that entry = bad Thanks for the help, Joose ps. I'll upgrade my webpage soon to have current working setting so you can evaluate if it's good enough for perhaps some example of 1:n mapping? -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Is this a bug?
Hi, like you have seen, I've tried and tried to make 1:n mapping to work. Now I did exactly how tutorials and docs showed but still it's not working correctly. I used and just like showed in docs/howto's/tutorial but still no luck. It seems that it doesn't care in which order it inserts / deletes stuff from database => BUG? It seems to execute sql-clauses in somewhat random order. I have set up webpage to what I did and what was the result. Webpage is http://joose.iki.fi/ojb/ ojb is 1.0.rc6 Could this be a bug or is this just feature not yet supported? Can I somehow make it manually to retrieve/delete in correct order? Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Still can't get 1:n to work.
Hi, I did complete clear from scratch and found out very odd behavior. I explained whole thing in http://joose.iki.fi/ojb/ Check the results.. It makes those sql-clauses (INSERT or DELETE) in random(?) order. It seem to every second time to create files in OK order but every other time in wrong order. Like you can't add children for parent before that parent exists. Thanks, Joose 23.7.2004 kello 19:43, Carlos Chávez kirjoitti: Hi Joose. Joose Vettenranta Escribio :-) I checked that sample files I got and checked the website and googled like maniac.. And still not getting anywhere.. Is it realy this difficult or have I just missed something? I have now tried about 30h to make this work but still no luck. Current status: - Getting data from database to beans [just does select too many times and get's next sequence, but not really a problem yet] - Updating data does does not work: + it does UPDATE to file_categories (Category) but INSERT on category_names (CategoryName) + does not have correct category_id while doing INSERT (which it should never do) - Deleting data does not work (referential integrity violation) + it tries to delete first from file_categories (Category) -> referential error because there is data in category_names (CategoryName) - Inserting data does not work + it does not pass category_id to category_names (CategoryName) + does INSERT to the category_names (CategoryName) before file_categories (Category) -> if category_id would be passed -> referential error I made database simplier to like this: CREATE TABLE file_categories ( ID SERIAL. PRIMARY KEY (ID)); CREATE TABLE category_names ( ID SERIAL, CATEGORY_ID INTEGER NOT NULL, NAME VARCHAR(50), PRIMARY KEY (ID), FOREIGN KEY (CATEGORY_ID) REFERENCES file_categories (ID)); Category.java has: ... private int id; pricate Collection names = new ArrayList(); ... setters/getters for id setters/getters for names public addNames (CategoryName name) { names.add (name); } ... CategoryName.java has: private int id; private int category_id; private String name; and I have getters/setters for everyone of those - repository.xml default-connection="true" platform="PostgreSQL" subprotocol="postgresql"> className="org.apache.ojb.broker.util.sequence.SequenceManagerNextValI mp l"/> table="FILE_CATEGORIES"> primarykey="true" nullable="false" default-fetch="true" autoincrement="true" column="ID" sequence-name="file_categories_id_seq" jdbc-type="INTEGER" access="readonly"/> element-class-ref="net.vettenranta.category.bean.CategoryName" collection- class="org.apache.ojb.broker.util.collections.ManageableArrayList" otm-dependent="true"> in "" i think this is a problem: the field category_id does not exist in the table FILE_CATEGORIES, although the field category_id exist in the table CATEGORY_NAMES. This is what I would do: Rename the field "ID" to "CATEGORY_ID" in table file_categories, well of course made the chandes in the repoitory.xml There are other attribute in for the "collection-descriptor" element like "auto-update" and "auto-delete" try put to true the value of this attribute. Cheers, Carlos Chávez. table="CATEGORY_NAMES"> primarykey="true" nullable="false" default-fetch="true" column="ID" jdbc-type="INTEGER" autoincrement="true" sequence-name="category_names_id_seq" access="readonly"/> nullable="false" default-fetch="true" column="CATEGORY_ID" jdbc-type="INTEGER" /> default-fetch="true" column="NAME" jdbc-type="VARCHAR"/> --- -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * -
Re: Example of 1:n
Well, I was happy too early. It seems like it does the insert in different order on different run. I updated both result on webpage. Sometimes it does INSERT child first and sometimes INSERT parent first. Seems like ojb is not working correctly or I have something wrong somewhere. (I also removed access="readonly" from repository.xml) - Joose 23.7.2004 kello 18:37, Joose Vettenranta kirjoitti: I got it to work little better. I had to change package.jdo, but now in DELETE it goes not so well... (I'll update webpage in few minutes) - Joose 23.7.2004 kello 18:22, Joose Vettenranta kirjoitti: Hi, I forgot to say, that I think the problem is in repository.xml or in packages.jdo but what I've seen and tried, the problem can be in cosmic radiation. - Joose Hello! I did summary to the web: http://joose.iki.fi/ojb/ I'm using version 1.0rc6 of ojb There should be every source code and configuration file and log files from the test run. If you can help me to make that work, I'll buy you a beer when you are in Finland next time =) -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Example of 1:n
I got it to work little better. I had to change package.jdo, but now in DELETE it goes not so well... (I'll update webpage in few minutes) - Joose 23.7.2004 kello 18:22, Joose Vettenranta kirjoitti: Hi, I forgot to say, that I think the problem is in repository.xml or in packages.jdo but what I've seen and tried, the problem can be in cosmic radiation. - Joose Hello! I did summary to the web: http://joose.iki.fi/ojb/ I'm using version 1.0rc6 of ojb There should be every source code and configuration file and log files from the test run. If you can help me to make that work, I'll buy you a beer when you are in Finland next time =) -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Example of 1:n
Hi, I forgot to say, that I think the problem is in repository.xml or in packages.jdo but what I've seen and tried, the problem can be in cosmic radiation. - Joose Hello! I did summary to the web: http://joose.iki.fi/ojb/ I'm using version 1.0rc6 of ojb There should be every source code and configuration file and log files from the test run. If you can help me to make that work, I'll buy you a beer when you are in Finland next time =) -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Example of 1:n
Hello! I did summary to the web: http://joose.iki.fi/ojb/ I'm using version 1.0rc6 of ojb There should be every source code and configuration file and log files from the test run. If you can help me to make that work, I'll buy you a beer when you are in Finland next time =) Thanks, Joose 23.7.2004 kello 13:44, Brian McCallister kirjoitti: O/R mapping in general is complex =) Don't sweat the learning curve. Once I get some breakfast I'll look over your config and see if I can see anything. -Brian On Jul 23, 2004, at 6:16 AM, Joose Vettenranta wrote: Thanks, I got that and tried to implemet thing according to that file, but still not getting simple 1:n to work. I have also read the basic-technique.html file many times from top to bottom, bottom to top left to right and right to left.. With search with copy-pasting and I think I even tried calling ghostbusters to come and help me to get this simple 1:n relation to work -> but no luck. Eather this is very very complex thing or I'm just stupid and can't even implement something this simple. -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Example of 1:n
Thanks, I got that and tried to implemet thing according to that file, but still not getting simple 1:n to work. I have also read the basic-technique.html file many times from top to bottom, bottom to top left to right and right to left.. With search with copy-pasting and I think I even tried calling ghostbusters to come and help me to get this simple 1:n relation to work -> but no luck. Eather this is very very complex thing or I'm just stupid and can't even implement something this simple. - Joose 22.7.2004 kello 15:57, Brian McCallister kirjoitti: I have a bunch of sample code online from a presentation I gave a few months ago. It includes different relation types, and IIRC, class-per-table inheritance. http://kasparov.skife.org/ojb-phillyjug.tar.gz -Brian On Jul 22, 2004, at 8:52 AM, Thomas Dudziak wrote: Joose Vettenranta wrote: is there anywhere working example how 1-to-many relation should work? I have now tried 3days to get it to work and I'm not able to get it to work. Have you checked the documentation: http://db.apache.org/ojb/docu/guides/basic-technique.html -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Still can't get 1:n to work.
I checked that sample files I got and checked the website and googled like maniac.. And still not getting anywhere.. Is it realy this difficult or have I just missed something? I have now tried about 30h to make this work but still no luck. Current status: - Getting data from database to beans [just does select too many times and get's next sequence, but not really a problem yet] - Updating data does does not work: + it does UPDATE to file_categories (Category) but INSERT on category_names (CategoryName) + does not have correct category_id while doing INSERT (which it should never do) - Deleting data does not work (referential integrity violation) + it tries to delete first from file_categories (Category) -> referential error because there is data in category_names (CategoryName) - Inserting data does not work + it does not pass category_id to category_names (CategoryName) + does INSERT to the category_names (CategoryName) before file_categories (Category) -> if category_id would be passed -> referential error I made database simplier to like this: CREATE TABLE file_categories ( ID SERIAL. PRIMARY KEY (ID)); CREATE TABLE category_names ( ID SERIAL, CATEGORY_ID INTEGER NOT NULL, NAME VARCHAR(50), PRIMARY KEY (ID), FOREIGN KEY (CATEGORY_ID) REFERENCES file_categories (ID)); Category.java has: ... private int id; pricate Collection names = new ArrayList(); ... setters/getters for id setters/getters for names public addNames (CategoryName name) { names.add (name); } ... CategoryName.java has: private int id; private int category_id; private String name; and I have getters/setters for everyone of those - repository.xml primarykey="true" nullable="false" default-fetch="true" autoincrement="true" column="ID" sequence-name="file_categories_id_seq" jdbc-type="INTEGER" access="readonly"/> element-class-ref="net.vettenranta.category.bean.CategoryName" collection- class="org.apache.ojb.broker.util.collections.ManageableArrayList" otm-dependent="true"> primarykey="true" nullable="false" default-fetch="true" column="ID" jdbc-type="INTEGER" autoincrement="true" sequence-name="category_names_id_seq" access="readonly"/> nullable="false" default-fetch="true" column="CATEGORY_ID" jdbc-type="INTEGER" /> default-fetch="true" column="NAME" jdbc-type="VARCHAR"/> --- -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Example of 1:n
Hi, is there anywhere working example how 1-to-many relation should work? I have now tried 3days to get it to work and I'm not able to get it to work. Thanks, Joose -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Foreignkey problem
Hi, using db-ojb-1.0.rc6.jar and jdo 1.0.1 I'm trying to make simple thing to work. But it seems to just add those in wrong order and causes referency error. I've been googling and trying different configurations but only thing I get is different error message. Questin is, how to get this thing to work? Database get's this much: Jul 22 10:29:45 cellula postgres[31986]: [18] LOG: query: begin; Jul 22 10:29:45 cellula postgres[31986]: [19] LOG: query: select nextval('file_categories_id_seq') Jul 22 10:29:45 cellula postgres[31986]: [20] LOG: query: select nextval('category_names_id_seq') Jul 22 10:29:45 cellula postgres[31986]: [21] LOG: query: SELECT 1 Jul 22 10:29:45 cellula postgres[31986]: [22] LOG: query: rollback; begin; Jul 22 10:29:45 cellula postgres[31986]: [23] LOG: query: SELECT 1 Jul 22 10:29:45 cellula postgres[31986]: [24] LOG: query: end With this setup I get this error message: org.apache.ojb.jdori.sql.OjbStoreFatalInternalException: org.apache.ojb.jdori.sql.OjbStoreManager.insert NestedThrowables: org.apache.ojb.broker.metadata.MetadataException: Can't find member 'file_categories' in net.vettenranta.category.bean.CategoryName Caused by: org.apache.ojb.broker.metadata.MetadataException: Can't find member 'file_categories' in net.vettenranta.category.bean.CategoryName Caused by: java.lang.NoSuchFieldException: file_categories . NestedThrowablesStackTrace: org.apache.ojb.broker.metadata.MetadataException: Can't find member 'file_categories' in net.vettenranta.category.bean.CategoryName . Caused by: java.lang.NoSuchFieldException: file_categories ... I have (in postgresql) tables: -- create table file_categories ( id serial, parent integer not null, primary key(id), foreign key(parent) references file_categories (id)); create table category_names ( id serial, category_id integer not null, lang_id integer not null, name varchar(50), primary key(id), foreign key(category_id) references file_categories(id)); -- repository.xml: -- auto-retrieve="true" auto-update="false" auto-delete="true"> refresh="true" auto-retrieve="true" auto-update="true" auto-delete="true"> -- package.jdo: -- -- Category.java: -- public class Category implements Serializable { protected int parent; private int id; private Collection names = new ArrayList(); public Category () { parent = 0; } public void setId (int id) { this.id = id; } public int getId () { return this.id; } public void setParent (int parent) { this.parent = parent; } public int getParent () { return this.parent; } public void setNames (Collection names) { this.names = names; } public void addNames (CategoryName name) { names.add (name); } public Collection getNames() { return this.names; } } -- CategoryName.java: -- public class CategoryName implements Serializable { private int id; private String name; private int lang; private int category; public CategoryName () { this.lang=1; } public int getId () { return id; } public String getName () { return name; } public int getLang () { return lang; } public int getCategory () { return this.category; } public void setId (int id) { this.id = id; } public void setLang (int lang) { this.lang = lang; } public void setName (String name) { this.name = name; } public void setCategory (int category) { this.category = category; } } -- -- "Always remember that you are unique, just like everyone else!" * http://iki.fi/joose/ * [EMAIL PROTECTED] * +358 44 561 0270 * - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]