Re: question about synchronization in 1:n relationships
Hi, first of all, thanks for help and giving me the hints to the docs. My goal is to avoid keeping objects in my application which are unsynchronized with the db. So far I understood setting the refresh-attribute in collection-descriptor to "true" results in refreshing all referenced objects in the collection when the object is loaded from cache or database. Whereas using the two-level-cache only is a performance improvement to keep the number of db-lookups small. It doesn't prevent the application from having unsynchronized data. Maybe you could give me a hint if my conclusions described above are correct in termns of understanding how refresh and two-level-cache works? Regards, Abid Alessandro Colantoni schrieb: Hi Abid. Do you mean that you want automatically refreshed the events collection, without any lookup to the cache or not?. If you want the collection to be refreshed on look up you can use collection-descriptor refresh attribute or the two level cache http://db.apache.org/ojb/docu/guides/repository.html#collection-descriptor http://db.apache.org/ojb/docu/guides/objectcache.html#two-level I dont't think you could avoid a lookup, anyway a first idea could be to make it hidden to the eventType user. For example you could hide the lookup in the method getEvents of the class EventType Regards Alessandro On Wed, Oct 22, 2008 at 10:00 AM, Abid Hussain <[EMAIL PROTECTED]>wrote: Hello everybody, I except not to be the first one to ask this question, but haven't found anything in the archives. My question is about synchronization resp. caching of 1:n relations. Let's say, we have two entities: class Event { int id; int eventTypeId; EventType eventType; // ... other fields } class EventType { int id; Collection events; // ... other fields } So, there is a 1:n relationship between EventType and Event - EventType is on the 1-side and Event is on the n-side. Let's look at the following: (1) We fetch an EventType (called evType) from DB incl. all the associated Events. (2) Another user deletes an Event from the DB which was associated with the previously fetched EventType. (3) At this point, an Event is included in the evType's events-collection which doesn't exist any more cause it was deleted in (2). Is there any caching or synchronization mechanism to avoid the problem in (3)? Regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
question about synchronization in 1:n relationships
Hello everybody, I except not to be the first one to ask this question, but haven't found anything in the archives. My question is about synchronization resp. caching of 1:n relations. Let's say, we have two entities: class Event { int id; int eventTypeId; EventType eventType; // ... other fields } class EventType { int id; Collection events; // ... other fields } So, there is a 1:n relationship between EventType and Event - EventType is on the 1-side and Event is on the n-side. Let's look at the following: (1) We fetch an EventType (called evType) from DB incl. all the associated Events. (2) Another user deletes an Event from the DB which was associated with the previously fetched EventType. (3) At this point, an Event is included in the evType's events-collection which doesn't exist any more cause it was deleted in (2). Is there any caching or synchronization mechanism to avoid the problem in (3)? Regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: question about storing objects
Hi Armin, thanks for help. Just to be sure that I got the point: When there is a 'proxy="dynamic"' in the class-descriptor, proxies are always used when more than one object is queried? I thought that proxies are only used when retrieving a collection through a relation (1:n or m:n, e.g. ShoppingCart.getArticles() - see below)... Regards, Abid Armin Waibel schrieb: Hi Abid, Abid Hussain wrote: Hi again, I think this issue has to something with the materialization of objects (when using proxies). But I thought that proxies are only used, when retrieving a corresponding collection of an object (in 1:n and m:n relations, e.g. ShoppingCart.getArticles()...). What I'm doing when using findAll() (see below) is something like SELECT * FROM . I thought, in this case no proxies are used??? You are using dynamic proxies for all Account_2 objects: The query result collection isn't a proxy object. Instead each result object is a proxy object of persistence capable object (Account_2 object). In most cases this doesn't have an performance advantage. If you now store each of these objects without materialization (e.g. your log.debug() force the materialization of the object) OJB thinks that the object didn't change and skip the update. regards, Armin Regards, Abid Abid Hussain schrieb: Hi everybody, I have written a storeAll()-method in a dao to store all given objects in one transaction (you find the code at the end of this mail). Now please have a look at the following lines of code: Account_2DAO dao1 = new Account_2DAO("DB1"); Collection accounts = dao1.findAll(Account_2.class); logger.debug(accounts); Account_2DAO dao2 = new Account_2DAO("DB2"); dao2.storeAll(accounts); As you see, that there are two daos initialized. The first (dao1) retrieves all objects (using findAll()) from a database (DB1). The second (dao2) stores all retrieved objects into another database (DB2). The findAll()-method works fine. But the storeAll()-method only works when the line of code logger.debug(accounts); is called. If not, no data is inserted. Any ideas what's going wrong (you find the class-descriptor file below)? Regards, Abid Code of storeAll(): public void storeAll(Collection valueObjects) throws PersistentStoringException { if (valueObjects != null) { try { broker.beginTransaction(); for (T valueObject : valueObjects) { broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } catch (Exception e) { broker.abortTransaction(); throw new PersistentStoringException( "Error while storing objects.\n" + e); } finally { if (broker != null && !broker.isClosed()) broker.close(); } } } Class-descriptor of Account_2: - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: question about storing objects
Hi again, I think this issue has to something with the materialization of objects (when using proxies). But I thought that proxies are only used, when retrieving a corresponding collection of an object (in 1:n and m:n relations, e.g. ShoppingCart.getArticles()...). What I'm doing when using findAll() (see below) is something like SELECT * FROM . I thought, in this case no proxies are used??? Regards, Abid Abid Hussain schrieb: Hi everybody, I have written a storeAll()-method in a dao to store all given objects in one transaction (you find the code at the end of this mail). Now please have a look at the following lines of code: Account_2DAO dao1 = new Account_2DAO("DB1"); Collection accounts = dao1.findAll(Account_2.class); logger.debug(accounts); Account_2DAO dao2 = new Account_2DAO("DB2"); dao2.storeAll(accounts); As you see, that there are two daos initialized. The first (dao1) retrieves all objects (using findAll()) from a database (DB1). The second (dao2) stores all retrieved objects into another database (DB2). The findAll()-method works fine. But the storeAll()-method only works when the line of code logger.debug(accounts); is called. If not, no data is inserted. Any ideas what's going wrong (you find the class-descriptor file below)? Regards, Abid Code of storeAll(): public void storeAll(Collection valueObjects) throws PersistentStoringException { if (valueObjects != null) { try { broker.beginTransaction(); for (T valueObject : valueObjects) { broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } catch (Exception e) { broker.abortTransaction(); throw new PersistentStoringException( "Error while storing objects.\n" + e); } finally { if (broker != null && !broker.isClosed()) broker.close(); } } } Class-descriptor of Account_2: -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
question about storing objects
Hi everybody, I have written a storeAll()-method in a dao to store all given objects in one transaction (you find the code at the end of this mail). Now please have a look at the following lines of code: Account_2DAO dao1 = new Account_2DAO("DB1"); Collection accounts = dao1.findAll(Account_2.class); logger.debug(accounts); Account_2DAO dao2 = new Account_2DAO("DB2"); dao2.storeAll(accounts); As you see, that there are two daos initialized. The first (dao1) retrieves all objects (using findAll()) from a database (DB1). The second (dao2) stores all retrieved objects into another database (DB2). The findAll()-method works fine. But the storeAll()-method only works when the line of code logger.debug(accounts); is called. If not, no data is inserted. Any ideas what's going wrong (you find the class-descriptor file below)? Regards, Abid Code of storeAll(): public void storeAll(Collection valueObjects) throws PersistentStoringException { if (valueObjects != null) { try { broker.beginTransaction(); for (T valueObject : valueObjects) { broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } catch (Exception e) { broker.abortTransaction(); throw new PersistentStoringException( "Error while storing objects.\n" + e); } finally { if (broker != null && !broker.isClosed()) broker.close(); } } } Class-descriptor of Account_2: -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: updating objects
Hi Armin, thanks for help. I guess, you don't mean 1.0.5 by next major version, maybe 1.1? Is there already a date for the release of the next major version available? Best regards, Abid Armin Waibel schrieb: Hi Abid, Abid Hussain wrote: Hi everybody, I've a table with quite a lot of columns. When using broker.update(object) all columns are updated. Is there a way to only update the columns which actually changed? I'm looking for something like UPDATE MyTable SET MyTableColumn = WHERE ID=xxx. Anyone got an idea? Sorry, with the current version of OJB this is not possible (next major version will support this). regards, Armin Regards, Abid - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
updating objects
Hi everybody, I've a table with quite a lot of columns. When using broker.update(object) all columns are updated. Is there a way to only update the columns which actually changed? I'm looking for something like UPDATE MyTable SET MyTableColumn = WHERE ID=xxx. Anyone got an idea? Regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what's with OJB Project?
Hi, I also would like to take the opportunity to say that OJB really is VERY stable and the configuration effort is tolerable. I'm using it for about two years and till now never encountered a bug (hope this won't change!). It's a great tool, and it's a pity that it seems to be so hard to develop it further. Best regards, Abid Manukyan, Sergey schrieb: Folks, It has been a while since last release of 1.0.4. I have been a user of ojb since 1.0.2... for about 4 years... but going forward concerns me. With no new releases I would like to ask how does the perspective looks for this project? Is work currently being done? Why such a big gap in releases? Are there still plans to ship 1.1? Regards, -Sergey -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
java.net.SocketException: Connection reset
Hello everybody, I'm using OJB in my web applicatin now for more than one year, and it did really fine. But since some time an exception occurs which I can't figure out. Obviously the connection to the backend was reset. May it be the case that the db connection timed out? Anybody got an idea what I can do about this? I found this issue in jira but I'm not sure if it's the same case as mine: http://issues.apache.org/jira/browse/OJB-70?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel Best regards, Abid Here's the stack trace: ERROR: [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] * SQLException during execution of sql-statement: * sql statement was 'SELECT A0.Id,A0.modul_Name,A0.LP,A0.Zuordnung,A0.Ziele,A0.Inhalte,A0.Literatur,A0.Voraussetzung,A0.Modulpruefung,A0.Selbststudium,A0.Form_Teilnahme,A0.Sprache,A0.Aufwand_Gesamt,A0.Dauer,A0.Haeufigkeit,A0.Sonst_Verantwortliche FROM Modul_2 A0 WHERE A0.Id = ?' * Exception message is [An I/O error occured while sending to the backend.] * Vendor error code [0] * SQL state code [08006] * Target class is 'modulverwaltung.beans.Module_2' * PK of the target object is [id] * The root stack trace is --> * java.net.SocketException: Connection reset at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123) at org.postgresql.core.PGStream.flush(PGStream.java:494) at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:631) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:174) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240) at com.p6spy.engine.logging.P6LogPreparedStatement.executeQuery(P6LogPreparedStatement.java:172) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.materializeObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getPlainDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unknown Source) at modulverwaltung.persistence.Module_2DAO.findByPrimaryKey(Module_2DAO.java:73) at modulverwaltung.action.ShowModule.performAction(ShowModule.java:32) at modulverwaltung.controller.Controller.doGet(Controller.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: report query in order by
Hi again, thank you Vasily for the workaround. But as you said in you mailinglist-posting, it would be more desireable to use code like QueryByCriteria.addOrderBy(ReportQuery)...:-( Maybe there will be a proper way to solve the problem sometime...:-) Regards, Abid Vasily Ivanov schrieb: Hi Abid, It was me who posted that question. I also posted an improvement request into Jira: https://issues.apache.org/jira/browse/OJB-104 There is a workaround in there. Have a look. Regards, Vasily On 10/23/06, Abid Hussain <[EMAIL PROTECTED]> wrote: Hi everybody, the following problem was already posted in the mailinglist in March 06. <-- I've got two classes: class Parent: int id String data Collection children class Child: int id String data int parentId Parent parent I need to get collection of parents sorted by the number of children, but I didn't find any way to put ReportQuery to "ORDER BY" statement. --> The problem is that there is no method in QueryByCriteria like QueryByCriteria.addOrderBy(ReportQuery), so there wasn't found a proper solution in the mailinglist when the problem was posted. I've got the same problem and am asking if there is a solution maybe in ojb 1.0.5? Regards, Abid Hussain -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - 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] -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
report query in order by
Hi everybody, the following problem was already posted in the mailinglist in March 06. <-- I've got two classes: class Parent: int id String data Collection children class Child: int id String data int parentId Parent parent I need to get collection of parents sorted by the number of children, but I didn't find any way to put ReportQuery to "ORDER BY" statement. --> The problem is that there is no method in QueryByCriteria like QueryByCriteria.addOrderBy(ReportQuery), so there wasn't found a proper solution in the mailinglist when the problem was posted. I've got the same problem and am asking if there is a solution maybe in ojb 1.0.5? Regards, Abid Hussain -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ojb 1.x and number of ojb-users
Hello everybody, I have two questions which do not concern about the usage of OJB: 1. On the OJB-homepage it says that the work for OJB 1.x has started in 11/2005 (http://db.apache.org/ojb/news.html). I just wondered about this, because the last entry on the page is from 12/2005. Are there any updates planned in the close future? 2. Is there any reliable figures about how many people use OJB? I'm just asking because when I talk to other developers about O/R-Mapping they mostly only know Hibernate and I wonder how OJB's standing is upon developers. Regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: store collections
Hi Armin, How can it happen that you try to insert ojb-proxied objects? If the proxy object isn't materialized OJB assume that nothing has changed and skip the store. Because I wanted to copy values from one database to another. So I first retrieved the values from the local DB and then tried to store them in the live-system DB. But when the problem only comes up with proxied objects then it is all right, I then just let the object being materialized by using the debug()-method and then copy it. Like Josef said, the code seems to be ok. Thanks a lot for quick help. Best regards, Abid Because, when I change the code to this: public void storeAll(Collection valueObjects) { if (valueObjects != null) { broker.beginTransaction(); for (Iterator i = valueObjects.iterator(); i.hasNext();) Object valueObject = i.next(); --> logger.debug(valueObject); broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } ...it works because the object is loaded from the database when calling the debug()-method. It seems that the broker has nothing to store in the method without the logging-statement seen below. But is there any other way to solve this problem? Regards, Abid Abid Hussain schrieb: Hi everybody, I want to implement a method which stores not only one object but a collection of objects. I tried this one: public void storeAll(Collection valueObjects) { if (valueObjects != null) { broker.beginTransaction(); for (Iterator i = valueObjects.iterator(); i.hasNext();) Object valueObject = i.next(); broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } ...but it doesn't work, not one object is stored into the database. Anybody got an idea? Regards, Abid - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: store collections
Hi again, I forgot to tell that the problem seems to have to do with the using of proxies. Because, when I change the code to this: public void storeAll(Collection valueObjects) { if (valueObjects != null) { broker.beginTransaction(); for (Iterator i = valueObjects.iterator(); i.hasNext();) Object valueObject = i.next(); --> logger.debug(valueObject); broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } ...it works because the object is loaded from the database when calling the debug()-method. It seems that the broker has nothing to store in the method without the logging-statement seen below. But is there any other way to solve this problem? Regards, Abid Abid Hussain schrieb: Hi everybody, I want to implement a method which stores not only one object but a collection of objects. I tried this one: public void storeAll(Collection valueObjects) { if (valueObjects != null) { broker.beginTransaction(); for (Iterator i = valueObjects.iterator(); i.hasNext();) Object valueObject = i.next(); broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } ...but it doesn't work, not one object is stored into the database. Anybody got an idea? Regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
store collections
Hi everybody, I want to implement a method which stores not only one object but a collection of objects. I tried this one: public void storeAll(Collection valueObjects) { if (valueObjects != null) { broker.beginTransaction(); for (Iterator i = valueObjects.iterator(); i.hasNext();) Object valueObject = i.next(); broker.store(valueObject, ObjectModification.INSERT); } broker.commitTransaction(); } ...but it doesn't work, not one object is stored into the database. Anybody got an idea? Regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: CRITERIA_SELECT_ALL is null
Sorry, my fault. Seems to be that it value of CRITERIA_SELECT_ALL should be null. Best regards, Abid Abid Hussain schrieb: Hi everybody, I have a problem which I really can't figure out. Please look at following code: ... crit = QueryByCriteria.CRITERIA_SELECT_ALL; logger.debug("#2 Criteria is (" + crit + ")."); ... Now look the output of log4j: DEBUG: [modulverwaltung.persistence.ModuleDAO] #2 Criteria is (null). How can this happen? Did I make a mistake or is it a bug? Would be great if somebody could help me about this. Best regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
CRITERIA_SELECT_ALL is null
Hi everybody, I have a problem which I really can't figure out. Please look at following code: ... crit = QueryByCriteria.CRITERIA_SELECT_ALL; logger.debug("#2 Criteria is (" + crit + ")."); ... Now look the output of log4j: DEBUG: [modulverwaltung.persistence.ModuleDAO] #2 Criteria is (null). How can this happen? Did I make a mistake or is it a bug? Would be great if somebody could help me about this. Best regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: retrieving fields and collections by ReportQuery
Hi again, first of all thanks for help. Using distinct would lead to following SQL: SELECT DISTINCT A0.modul_Name,A0.Zuordnung,A0.Haeufigkeit,A1.MODUL_NAME,A1.BEREICH_NAME FROM MODUL A0 INNER JOIN MODUL_BEREICH A1 ON A0.modul_Name=A1.MODUL_NAME ORDER BY 1 I think this wouldn't solve the problem, because the wanted behaviour is the following: Retrieving data same as in QueryByCriteria, including the retrieval of according collections, but retrieving only the fields/columns I actually need. It seems to be like Carlos said, one can't retrieve collections by using the ReportQuery. Isn't it a disadvantage that there is no possibility to restrict QueryByCriteria in the way that only the wanted fields/collections are retrieved? In most cases, I don't need all columns of a table. And it causes a great overhead, when I retrieve 30 columns but need only e.g. 3. Don't get me wrong, I think OJB is a great tool, and it helps me a lot. But wouldn't it be great having a method/class which combines the simplicity of QueryByCriteria and the flexibility of ReportQuery? Best regards, Abid Jakob Braeuchi schrieb: hi abid, what about using distinct ? jakob Abid Hussain schrieb: Hallo again, thanks for the quick answer. When I add disciplines.moduleName and disciplines.disciplineName as attributes for the ReportQuery it somehow works: ReportQueryByCriteria q = QueryFactory.newReportQuery(Module.class, crit); q.addOrderByAscending("name"); q.setAttributes(new String[] { "name", "courseOfStudy", "disciplines.moduleName", "disciplines.disciplineName" }); OJB generates following SQL: SELECT A0.modul_Name,A0.Zuordnung,A0.Haeufigkeit,A1.MODUL_NAME,A1.BEREICH_NAME FROM MODUL A0 INNER JOIN MODUL_BEREICH A1 ON A0.modul_Name=A1.MODUL_NAME ORDER BY 1 But there is one major disadvantage about it: The retrieved Modules occure as often in the resulting collection as they are referenced in the ModuleDiscipline. E.g., when a Module has three according rows in the table ModuleDiscipline, it occurs three times in the result of the query above. Maybe there is another way to fix this problem? Best regards, Abid Hussain Carlos Chávez schrieb: Abid Hussain escribió: Hallo everybody, for the following problem I didn't find a proper solution: I'm using the ReportQuery to retrieve data, because the table has about 25 columns and i only need a few. The problem is, in the ReportQuery I can only specifiy the fields which I want to retrieve, but no collections. I've got the following classes/tables: ... ... To retrieve date from the table MODUL, I could do like this: QueryByCriteria q = new QueryByCriteria(Module.class, QueryByCriteria.CRITERIA_SELECT_ALL); q.addOrderByAscending("name"); c = broker.getCollectionByQuery(q); But then all the fields from the according table would be retrieved, whereas I only need two fields plus the specified collection. On the other hand, when I use a ReportQuery in order to retrieve only the fields I actually need, I can't specify the collection in the ReportQuery. Did you try disciplines.moduleName and disciplines.disciplineName as attributes for the ReportQuery ? Cheers, Carlos Chávez. Anybody got an idea what I can do? Best regards, Abid Hussain - 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] -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: retrieving fields and collections by ReportQuery
Hallo again, thanks for the quick answer. When I add disciplines.moduleName and disciplines.disciplineName as attributes for the ReportQuery it somehow works: ReportQueryByCriteria q = QueryFactory.newReportQuery(Module.class, crit); q.addOrderByAscending("name"); q.setAttributes(new String[] { "name", "courseOfStudy", "disciplines.moduleName", "disciplines.disciplineName" }); OJB generates following SQL: SELECT A0.modul_Name,A0.Zuordnung,A0.Haeufigkeit,A1.MODUL_NAME,A1.BEREICH_NAME FROM MODUL A0 INNER JOIN MODUL_BEREICH A1 ON A0.modul_Name=A1.MODUL_NAME ORDER BY 1 But there is one major disadvantage about it: The retrieved Modules occure as often in the resulting collection as they are referenced in the ModuleDiscipline. E.g., when a Module has three according rows in the table ModuleDiscipline, it occurs three times in the result of the query above. Maybe there is another way to fix this problem? Best regards, Abid Hussain Carlos Chávez schrieb: Abid Hussain escribió: Hallo everybody, for the following problem I didn't find a proper solution: I'm using the ReportQuery to retrieve data, because the table has about 25 columns and i only need a few. The problem is, in the ReportQuery I can only specifiy the fields which I want to retrieve, but no collections. I've got the following classes/tables: ... ... To retrieve date from the table MODUL, I could do like this: QueryByCriteria q = new QueryByCriteria(Module.class, QueryByCriteria.CRITERIA_SELECT_ALL); q.addOrderByAscending("name"); c = broker.getCollectionByQuery(q); But then all the fields from the according table would be retrieved, whereas I only need two fields plus the specified collection. On the other hand, when I use a ReportQuery in order to retrieve only the fields I actually need, I can't specify the collection in the ReportQuery. Did you try disciplines.moduleName and disciplines.disciplineName as attributes for the ReportQuery ? Cheers, Carlos Chávez. Anybody got an idea what I can do? Best regards, Abid Hussain - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
retrieving fields and collections by ReportQuery
Hallo everybody, for the following problem I didn't find a proper solution: I'm using the ReportQuery to retrieve data, because the table has about 25 columns and i only need a few. The problem is, in the ReportQuery I can only specifiy the fields which I want to retrieve, but no collections. I've got the following classes/tables: ... ... To retrieve date from the table MODUL, I could do like this: QueryByCriteria q = new QueryByCriteria(Module.class, QueryByCriteria.CRITERIA_SELECT_ALL); q.addOrderByAscending("name"); c = broker.getCollectionByQuery(q); But then all the fields from the according table would be retrieved, whereas I only need two fields plus the specified collection. On the other hand, when I use a ReportQuery in order to retrieve only the fields I actually need, I can't specify the collection in the ReportQuery. Anybody got an idea what I can do? Best regards, Abid Hussain -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: maybe bug in Criteria.addNotEqualToColumn()
Hi, I think it was my fault. when i replace the Line --> crit.addNotEqualToColumn("name", excludeModules[i]); to --> crit.addNotEqualTo("name", excludeModules[i]); everthing works. Sorry for making trouble. Best regards, Abid Abid Hussain schrieb: Hi everybody, while executing a query there turned up an SQLException. I wonder if this is a bug or if I made a mistake. Here is the concerning section of my repository_user.xml: ... As you see, the column 'name' is of type VARCHAR. The according bean is: public class Module implements Serializable { protected String name; protected String courseOfStudy; ... } Now I want to execute following Code: Criteria crit = new Criteria(); crit.addEqualTo("courseOfStudy", courseOfStudy); if (excludeModules != null) { for (int i = 0; i < excludeModules.length; i++) { crit.addNotEqualToColumn("name", excludeModules[i]); } } ReportQueryByCriteria q = QueryFactory.newReportQuery(Module.class, crit); q.addOrderByAscending("name"); q.setAttributes(new String[] { "name" }); try { iter = broker.getReportQueryIteratorByQuery(q); for (int i = 0; iter.hasNext(); i++) { ... } } ... As you see, I'm adding a notEqualToColumn Criteria with the following parameters: --> name: the concerning column (table column's name is modul_name) --> excludeModules[]: a String[] which says which column values should be excluded The SQL statement which OJB generates is: SELECT A0.modul_Name FROM MODUL A0 WHERE (A0.Zuordnung = 'Bachelor') AND A0.modul_Name <> ALP I: Funktionale Programmierung ORDER BY 1 So, this causes an SQLException, because the name which to be excluded (ALP I: Funktionale Programmierung) is of type VARCHAR but there aren't any enclosing quotation marks. The correct Statement should say: SELECT A0.modul_Name FROM MODUL A0 WHERE (A0.Zuordnung = 'Bachelor') AND A0.modul_Name <> 'ALP I: Funktionale Programmierung' ORDER BY 1 Maybe this is a bug or have i overlooked something? Thanks for help, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
maybe bug in Criteria.addNotEqualToColumn()
Hi everybody, while executing a query there turned up an SQLException. I wonder if this is a bug or if I made a mistake. Here is the concerning section of my repository_user.xml: ... As you see, the column 'name' is of type VARCHAR. The according bean is: public class Module implements Serializable { protected String name; protected String courseOfStudy; ... } Now I want to execute following Code: Criteria crit = new Criteria(); crit.addEqualTo("courseOfStudy", courseOfStudy); if (excludeModules != null) { for (int i = 0; i < excludeModules.length; i++) { crit.addNotEqualToColumn("name", excludeModules[i]); } } ReportQueryByCriteria q = QueryFactory.newReportQuery(Module.class, crit); q.addOrderByAscending("name"); q.setAttributes(new String[] { "name" }); try { iter = broker.getReportQueryIteratorByQuery(q); for (int i = 0; iter.hasNext(); i++) { ... } } ... As you see, I'm adding a notEqualToColumn Criteria with the following parameters: --> name: the concerning column (table column's name is modul_name) --> excludeModules[]: a String[] which says which column values should be excluded The SQL statement which OJB generates is: SELECT A0.modul_Name FROM MODUL A0 WHERE (A0.Zuordnung = 'Bachelor') AND A0.modul_Name <> ALP I: Funktionale Programmierung ORDER BY 1 So, this causes an SQLException, because the name which to be excluded (ALP I: Funktionale Programmierung) is of type VARCHAR but there aren't any enclosing quotation marks. The correct Statement should say: SELECT A0.modul_Name FROM MODUL A0 WHERE (A0.Zuordnung = 'Bachelor') AND A0.modul_Name <> 'ALP I: Funktionale Programmierung' ORDER BY 1 Maybe this is a bug or have i overlooked something? Thanks for help, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: updating the primary key of a table row
Hi Armin, For this special case you have to delete the old value/obj and then insert the new vale/obj. regards, Armin thanks a lot. I thought of this possibility, but wondered if there is another way to perform the update. Regards, Abid -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
updating the primary key of a table row
Hi everybody, i wonder how to perform an update on a table where i changed the primary key. Let's say i've got a table, where the only unique column is the primary key itself - like this: CREATE TABLE foo ( foo_name VARCHAR PRIMARY KEY ); Now I change the column foo_name of a row from 'bla' to 'blub' and perform an update. In SQL, I would do this: UPDATE foo SET foo_name = 'blub' WHERE foo_name = 'bla'; When using OJB I would first retrieve the object I want to update: Foo foo = new Foo(); foo.setFooName("bla"); Query q = new QueryByIdentity(foo); foo = (Foo) broker.getObjectByQuery(q); Then set the attribute fooName: foo.setFooName("blub");) Then perform update: broker.store(foo, ObjectModification.UPDATE); But how should OJB identify the object which is to be updated? I just have changed the primary key and there are not other unique columns! Any ideas? Regards, Abid Hussain -- Abid Hussain Mail: [EMAIL PROTECTED] Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
don't need all columns
Hi everybody, I'm quite a newbie in OJB, so maybe I have overlooked something. In most cases I don't need all colums of a table when I do a query. So, how do I tell OJB not to retrieve all 25 (e.g.) columns of a table but only the ones I need? Best regards, Abid Hussain -- Abid Hussain Mail: [EMAIL PROTECTED] Tel.: 0179 / 9080412 Web: http://www.abid76.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]