RE: Criteria needs write permissions?
The schema databasemap name (e.g. defaultDB) will always be hard coded to the name in the XML file. So, it will never be found in another Database object. Your code snippet doesn't connect the nondefaultDB pool name to anything the criteria/SQLBuilder uses. But your debugging showed it was looking for this name. I suspect this is because your runtime torque.database.default property set to nondefaultDB. This property is the name that Torque uses for the default if none is specified. Try either changing your runtime settings to use defaultDB or specify the defaultDB name on your criteria constructor, e.g. new Criteria(defaultDB). This will make sure that the name used will match the schema name. -Original Message- From: Sheldon Ross [mailto:sr...@simmgene.com] Sent: Monday, November 16, 2009 5:19 PM To: Apache Torque Users List Subject: Re: Criteria needs write permissions? Second, create all criteria element using the *Peer objects. The DatabaseMap is populated when a *Peer class is loaded (static init). So, all tables Maps you will be referencing will exist in a Database object keyed to the DB Schema Name. This seems to be where I'm failing. Yes some queries will work. But I don't think the metadata areas will work. If this is what you meant, then I apologize. For example. Use an OrderBy clause for selecting from a database connection pool that is not from the default schema for that object. Connection srcConn = Torque.getConnection(nondefaultDB); Criteria critera = new Criteria(); criteria.addAscendingOrderByColumn(TableAPeer.COLA); TableAPeer.doSelect(criteria,srcConn); This doesn't work for me because TableA does not exist in the dbMap for nondefaultDB. It does exist in the dbMap for defaultDB because that's what's coded via the schema name. SQLBuilder succeeds at building the query for c.add(TableAPeer.COLA, 4); because it doesn't reference any metadata. It fails on the processOrderBy(db, dbMap, crit, query); because this function assumes the metadata is there. Ross DukeCE Privacy Statement: Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed. If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately. Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Criteria needs write permissions?
Greg Monroe wrote: Connection srcConn = Torque.getConnection(databaseA); Connection destConn = Torque.getConnection(databaseB); Don't want to be picky, but the recommended method is Connection srcConn = Transaction.begin(databaseA); } finally { Torque.closeConnection(srcConn); and Transaction.commit(srcConn), respectively. BTW: The limitations with your described approach look serious to me. You would need a lot of comments to explain what you're about to do, wouldn't you? Bye, Thomas. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: Criteria needs write permissions?
Sorry for the delay, out for a long weekend (gotta stay in bed on Fri 13th!). Simple Torque Objects CAN be used with two different connection pools. I have done this myself. However, there are some special limitations. I spent some time wandering the code and refreshing my memory and here's what I found. First, you need to understand some definitions: Simple Torque Objects - Just the core record information methods. The methods generated by the complexObjectModel build property (e.g. the ones which generate the methods to get the related foreign key and children objects) do not work. The autogenerated code assumes a lot about which connection to use. DBSchema Name - This is a string key defined via the XML schema database name attribute. It is used internally by Torque to tie together all the schema metadata in a DatabaseMap. This is used by Torque to determine things like table names, column attributes, and the like. DatabaseMap - This is the object that contains all the meta data *Map objects related to a specific DBSchema name. DB Connection Pool Name - This is a string key that is defined in the Torque runtime properties, e.g. the torque.dsfactory.DB Connection Name.* properties. This is eventually stored in a Database object in the TorqueInstance. Database Object - This is a container for information relating to a database, e.g. the connection pool info, the dbmap, the idbroker info, and the like. However, you can have a Database Object that does not contain all this info (e.g. a Database object with just connection info). Because of historical design purposes lost in antiquity, the DB Schema name and the DB Connection Name tend to be considered to be the same. Many of the references to DBName are not clearly labeled as to which name is meant. This has lead to some poor internal coding and a lot of confusion. One of the goals of Torque 4.0 is to try to correct this. So, how do you use Simple Torque objects with multiple DBs... First, set up your connection pools in the runtime properties. E.g. torque.dsfactory.databaseA.* and torque.dsfactory.databaseB. Second, create all criteria element using the *Peer objects. The DatabaseMap is populated when a *Peer class is loaded (static init). So, all tables Maps you will be referencing will exist in a Database object keyed to the DB Schema Name. NOTE: The dbName parameter on the Criteria constructor refers to the DB Schema Name and NOT directly to a DB Connection Pool Name. If there is a DB Connection Pool defined with the same name, this will be used. You need to write your code to use the methods that have a connection parameter. E.g., TablePeer.doSelect(Criteria, Connection). You get the connection object to use with this via the Toque.getConnection(String name) static method. The name here is the DB Connection Pool name. To tie this all together with some sample code that will move data from one DB to another one: Criteria c = new Criteria(); c.add(TableAPeer.COLA, 4); Connection srcConn = Torque.getConnection(databaseA); Connection destConn = Torque.getConnection(databaseB); try { List results = TableAPeer.doSelect(c,srcConn); Iterator rIt = results.iterator(); while( rIt.hasNext() ) { TableA rec = (TableA) rIt.next(); rec.save(destConn); } } finally { Torque.closeConnection(srcConn); Torque.closeConnection(destConn); } -Original Message- From: Alvaro Coronel [mailto:alvarocorone...@yahoo.com] Sent: Friday, November 13, 2009 10:50 AM To: Apache Torque Users List Subject: Re: Criteria needs write permissions? Does that mean that a Torque object can be used with two different connections as long as no pool is involved? From: Thomas Vandahl t...@apache.org To: torque-user@db.apache.org Sent: Fri, November 13, 2009 1:27:26 PM Subject: Re: Criteria needs write permissions? On 13.11.09 08:12, Thomas Fischer wrote: I'm not sure whether this is a bug or not, I need to think about it. If i remember correctly, the database name is used for the database connection (including credentials) and the table layout. Probably there are some cases where this wants to be treated differently. As I see it, the limitation is that a Torque object can only be used with one database connection pool. This might or might not be considered a bug, however, the given application type does not look typical to me. Bye, Thomas. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org DukeCE Privacy Statement: Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed. If you
Re: Criteria needs write permissions?
Second, create all criteria element using the *Peer objects. The DatabaseMap is populated when a *Peer class is loaded (static init). So, all tables Maps you will be referencing will exist in a Database object keyed to the DB Schema Name. This seems to be where I'm failing. Yes some queries will work. But I don't think the metadata areas will work. If this is what you meant, then I apologize. For example. Use an OrderBy clause for selecting from a database connection pool that is not from the default schema for that object. Connection srcConn = Torque.getConnection(nondefaultDB); Criteria critera = new Criteria(); criteria.addAscendingOrderByColumn(TableAPeer.COLA); TableAPeer.doSelect(criteria,srcConn); This doesn't work for me because TableA does not exist in the dbMap for nondefaultDB. It does exist in the dbMap for defaultDB because that's what's coded via the schema name. SQLBuilder succeeds at building the query for c.add(TableAPeer.COLA, 4); because it doesn't reference any metadata. It fails on the processOrderBy(db, dbMap, crit, query); because this function assumes the metadata is there. Ross Greg Monroe wrote: Sorry for the delay, out for a long weekend (gotta stay in bed on Fri 13th!). Simple Torque Objects CAN be used with two different connection pools. I have done this myself. However, there are some special limitations. I spent some time wandering the code and refreshing my memory and here's what I found. First, you need to understand some definitions: Simple Torque Objects - Just the core record information methods. The methods generated by the complexObjectModel build property (e.g. the ones which generate the methods to get the related foreign key and children objects) do not work. The autogenerated code assumes a lot about which connection to use. DBSchema Name - This is a string key defined via the XML schema database name attribute. It is used internally by Torque to tie together all the schema metadata in a DatabaseMap. This is used by Torque to determine things like table names, column attributes, and the like. DatabaseMap - This is the object that contains all the meta data *Map objects related to a specific DBSchema name. DB Connection Pool Name - This is a string key that is defined in the Torque runtime properties, e.g. the torque.dsfactory.DB Connection Name.* properties. This is eventually stored in a Database object in the TorqueInstance. Database Object - This is a container for information relating to a database, e.g. the connection pool info, the dbmap, the idbroker info, and the like. However, you can have a Database Object that does not contain all this info (e.g. a Database object with just connection info). Because of historical design purposes lost in antiquity, the DB Schema name and the DB Connection Name tend to be considered to be the same. Many of the references to DBName are not clearly labeled as to which name is meant. This has lead to some poor internal coding and a lot of confusion. One of the goals of Torque 4.0 is to try to correct this. So, how do you use Simple Torque objects with multiple DBs... First, set up your connection pools in the runtime properties. E.g. torque.dsfactory.databaseA.* and torque.dsfactory.databaseB. Second, create all criteria element using the *Peer objects. The DatabaseMap is populated when a *Peer class is loaded (static init). So, all tables Maps you will be referencing will exist in a Database object keyed to the DB Schema Name. NOTE: The dbName parameter on the Criteria constructor refers to the DB Schema Name and NOT directly to a DB Connection Pool Name. If there is a DB Connection Pool defined with the same name, this will be used. You need to write your code to use the methods that have a connection parameter. E.g., TablePeer.doSelect(Criteria, Connection). You get the connection object to use with this via the Toque.getConnection(String name) static method. The name here is the DB Connection Pool name. To tie this all together with some sample code that will move data from one DB to another one: Criteria c = new Criteria(); c.add(TableAPeer.COLA, 4); Connection srcConn = Torque.getConnection(databaseA); Connection destConn = Torque.getConnection(databaseB); try { List results = TableAPeer.doSelect(c,srcConn); Iterator rIt = results.iterator(); while( rIt.hasNext() ) { TableA rec = (TableA) rIt.next(); rec.save(destConn); } } finally { Torque.closeConnection(srcConn); Torque.closeConnection(destConn); } -Original Message- From: Alvaro Coronel [mailto:alvarocorone...@yahoo.com] Sent: Friday, November 13, 2009 10:50 AM To: Apache Torque Users List Subject: Re: Criteria needs write permissions? Does that mean that a Torque object can be used with two different connections as long as no pool is involved? From: Thomas Vandahl t
Re: Criteria needs write permissions?
On 13.11.09 08:12, Thomas Fischer wrote: I'm not sure whether this is a bug or not, I need to think about it. If i remember correctly, the database name is used for the database connection (including credentials) and the table layout. Probably there are some cases where this wants to be treated differently. As I see it, the limitation is that a Torque object can only be used with one database connection pool. This might or might not be considered a bug, however, the given application type does not look typical to me. Bye, Thomas. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Criteria needs write permissions?
Does that mean that a Torque object can be used with two different connections as long as no pool is involved? From: Thomas Vandahl t...@apache.org To: torque-user@db.apache.org Sent: Fri, November 13, 2009 1:27:26 PM Subject: Re: Criteria needs write permissions? On 13.11.09 08:12, Thomas Fischer wrote: I'm not sure whether this is a bug or not, I need to think about it. If i remember correctly, the database name is used for the database connection (including credentials) and the table layout. Probably there are some cases where this wants to be treated differently. As I see it, the limitation is that a Torque object can only be used with one database connection pool. This might or might not be considered a bug, however, the given application type does not look typical to me. Bye, Thomas. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Criteria needs write permissions?
The why is a good question, the table is not found. The tables hashmap in the dbMap appears to be empty. It of course is found when using the other db connection. It looks like I'm gonna have to dig for awhile. Thanks. Thomas Fischer wrote: The null ointer exception seems to come from reading the table or column map. Can you put a breakpoint in SQLBuilder.java:497 and see whether the table or the column cannot be found (and why it is not found)? Thomas Ok so I was trying to make our site a little safer from sql injections, so I made a database connection that connects with a user that only has SELECT permissions. And edited Criteria like such public Criteria() { this(DEFAULT_CAPACITY); this.setDbName(readonlydatabase); } Now it seems to work for must things, but a couple queries fail with throws java.lang.Exception java.lang.NullPointerException at org.apache.torque.util.SQLBuilder.processOrderBy (SQLBuilder.java:497) at org.apache.torque.util.SQLBuilder.buildQueryClause(SQLBuilder.java:302) at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:730) This error disappears as soon as I let the criteria use a database connection with write privileges. I know the user that it connects with has select privileges on every public table in the database. Does criteria need update privileges to work or something? The query the criteria constructs work fine when I connect as the readonly user and run it manually. Any thoughts? Thanks -- Sheldon Ross - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org -- Sheldon Ross Software Development American Simmental Association sr...@simmgene.com (406)587-4531 ext 102 - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Criteria needs write permissions?
That would probably work, but It seems a little overkill. Do you know where the lazy loading happens? When I run with r/w connection, the dbmap tables hash does appear to load that way. However when I run the readonly connection, it just stays empty. Thanks Greg Monroe wrote: FWIW, the dbMap object get populated in a lazy manner by default. However, there is a way to force it to be fully loaded via a code call. You do this by calling: org.apache.torque.linkage.DefaultMapInit.init(); Not that this class actually exists in the generated classes and not in the Torque package. This is because it provided a known class that knows (via extension) the user settable om package. -Original Message- From: Sheldon Ross [mailto:sr...@simmgene.com] Sent: Thursday, November 12, 2009 3:25 PM To: Apache Torque Users List Subject: Re: Criteria needs write permissions? The why is a good question, the table is not found. The tables hashmap in the dbMap appears to be empty. It of course is found when using the other db connection. It looks like I'm gonna have to dig for awhile. Thanks. Thomas Fischer wrote: The null ointer exception seems to come from reading the table or column map. Can you put a breakpoint in SQLBuilder.java:497 and see whether the table or the column cannot be found (and why it is not found)? Thomas Ok so I was trying to make our site a little safer from sql injections, so I made a database connection that connects with a user that only has SELECT permissions. And edited Criteria like such public Criteria() { this(DEFAULT_CAPACITY); this.setDbName(readonlydatabase); } Now it seems to work for must things, but a couple queries fail with throws java.lang.Exception java.lang.NullPointerException at org.apache.torque.util.SQLBuilder.processOrderBy (SQLBuilder.java:497) at org.apache.torque.util.SQLBuilder.buildQueryClause(SQLBuilder.java:302) at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:730) This error disappears as soon as I let the criteria use a database connection with write privileges. I know the user that it connects with has select privileges on every public table in the database. Does criteria need update privileges to work or something? The query the criteria constructs work fine when I connect as the readonly user and run it manually. Any thoughts? Thanks -- Sheldon Ross - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org -- Sheldon Ross Software Development American Simmental Association sr...@simmgene.com (406)587-4531 ext 102 - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org DukeCE Privacy Statement: Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed. If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately. Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org -- Sheldon Ross Software Development American Simmental Association sr...@simmgene.com (406)587-4531 ext 102 - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Criteria needs write permissions?
Ok, I apologize for the traffic. Here goes, when you build the database objects, it hardcodes in the database name that exists in your schema.xml. The code is in the doBuild() method of the ${Table}MapBuild.java public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap(defaultdb); Therefore when you query against a different database, the table names never get added to the tables hash for that database. I would consider this a bug as I don't think this would affect only me. Should I report it to the dev mailing list or something. Not sure of the etiquette there. Anyway thanks all. Sheldon Ross wrote: Ok, I think this maybe a bug. After watching the addTable method in DatabaseMap, It appears to add the table to the default database dbMap even if the criteria is querying against a different database. Sheldon Ross wrote: That would probably work, but It seems a little overkill. Do you know where the lazy loading happens? When I run with r/w connection, the dbmap tables hash does appear to load that way. However when I run the readonly connection, it just stays empty. Thanks Greg Monroe wrote: FWIW, the dbMap object get populated in a lazy manner by default. However, there is a way to force it to be fully loaded via a code call. You do this by calling: org.apache.torque.linkage.DefaultMapInit.init(); Not that this class actually exists in the generated classes and not in the Torque package. This is because it provided a known class that knows (via extension) the user settable om package. -Original Message- From: Sheldon Ross [mailto:sr...@simmgene.com] Sent: Thursday, November 12, 2009 3:25 PM To: Apache Torque Users List Subject: Re: Criteria needs write permissions? The why is a good question, the table is not found. The tables hashmap in the dbMap appears to be empty. It of course is found when using the other db connection. It looks like I'm gonna have to dig for awhile. Thanks. Thomas Fischer wrote: The null ointer exception seems to come from reading the table or column map. Can you put a breakpoint in SQLBuilder.java:497 and see whether the table or the column cannot be found (and why it is not found)? Thomas Ok so I was trying to make our site a little safer from sql injections, so I made a database connection that connects with a user that only has SELECT permissions. And edited Criteria like such public Criteria() { this(DEFAULT_CAPACITY); this.setDbName(readonlydatabase); } Now it seems to work for must things, but a couple queries fail with throws java.lang.Exception java.lang.NullPointerException at org.apache.torque.util.SQLBuilder.processOrderBy (SQLBuilder.java:497) at org.apache.torque.util.SQLBuilder.buildQueryClause(SQLBuilder.java:302) at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:730) This error disappears as soon as I let the criteria use a database connection with write privileges. I know the user that it connects with has select privileges on every public table in the database. Does criteria need update privileges to work or something? The query the criteria constructs work fine when I connect as the readonly user and run it manually. Any thoughts? Thanks -- Sheldon Ross - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org -- Sheldon Ross Software Development American Simmental Association sr...@simmgene.com (406)587-4531 ext 102 - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org DukeCE Privacy Statement: Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed. If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately. Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org -- Sheldon Ross Software
RE: Criteria needs write permissions?
OK, I think I understand what's going on here. It's really a semi-bug part but part a definitional issue. This is because the term database name/dbname actually has two meaning in Torque. The first is the schema database name, i.e. the name in your schema XML. This is used to group all the database schema's Metadata in the Database structure. The second meaning for this is the database connection pool name. This is the name used in the runtime config to define the DB connection info. Unfortunately, for historical reasons, these two names are tied together. Mostly for convenience reasons... but there are a few cases in the utility classes where a subquery or something needs to be done and the default DB name is used. So, people get confused when it seems like you can't use the DB objects with more than one database connection. But that's not true. To use more than one connection pool, you need to use the methods that take a connection object. To get an alternate connection, you define this in your runtime with a different name. E.g. set up a different set of torque.dsfactory. properties. Then use the Torque.getConnection(String) to get a connection from this pool. FWIW, I put forth a plan for Torque 4 to separate the connection pool name from the schema name. This would require objects and criteria to track which pool they came from. -Original Message- From: Sheldon Ross [mailto:sr...@simmgene.com] Sent: Thursday, November 12, 2009 4:28 PM To: Apache Torque Users List Subject: Re: Criteria needs write permissions? Ok, I think this maybe a bug. After watching the addTable method in DatabaseMap, It appears to add the table to the default database dbMap even if the criteria is querying against a different database. Sheldon Ross wrote: That would probably work, but It seems a little overkill. Do you know where the lazy loading happens? When I run with r/w connection, the dbmap tables hash does appear to load that way. However when I run the readonly connection, it just stays empty. Thanks Greg Monroe wrote: FWIW, the dbMap object get populated in a lazy manner by default. However, there is a way to force it to be fully loaded via a code call. You do this by calling: org.apache.torque.linkage.DefaultMapInit.init(); Not that this class actually exists in the generated classes and not in the Torque package. This is because it provided a known class that knows (via extension) the user settable om package. -Original Message- From: Sheldon Ross [mailto:sr...@simmgene.com] Sent: Thursday, November 12, 2009 3:25 PM To: Apache Torque Users List Subject: Re: Criteria needs write permissions? The why is a good question, the table is not found. The tables hashmap in the dbMap appears to be empty. It of course is found when using the other db connection. It looks like I'm gonna have to dig for awhile. Thanks. Thomas Fischer wrote: The null ointer exception seems to come from reading the table or column map. Can you put a breakpoint in SQLBuilder.java:497 and see whether the table or the column cannot be found (and why it is not found)? Thomas Ok so I was trying to make our site a little safer from sql injections, so I made a database connection that connects with a user that only has SELECT permissions. And edited Criteria like such public Criteria() { this(DEFAULT_CAPACITY); this.setDbName(readonlydatabase); } Now it seems to work for must things, but a couple queries fail with throws java.lang.Exception java.lang.NullPointerException at org.apache.torque.util.SQLBuilder.processOrderBy (SQLBuilder.java:497) at org.apache.torque.util.SQLBuilder.buildQueryClause(SQLBuilder.java:302) at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:730) This error disappears as soon as I let the criteria use a database connection with write privileges. I know the user that it connects with has select privileges on every public table in the database. Does criteria need update privileges to work or something? The query the criteria constructs work fine when I connect as the readonly user and run it manually. Any thoughts? Thanks -- Sheldon Ross --- -- To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org -- Sheldon Ross Software Development American Simmental Association sr...@simmgene.com (406)587-4531 ext 102
Re: Criteria needs write permissions?
Ok, I apologize for the traffic. No reason to apologize for anything. This is a perfectly valid question. Here goes, when you build the database objects, it hardcodes in the database name that exists in your schema.xml. The code is in the doBuild() method of the ${Table}MapBuild.java public void doBuild() throws TorqueException { dbMap = Torque.getDatabaseMap(defaultdb); Therefore when you query against a different database, the table names never get added to the tables hash for that database. I would consider this a bug as I don't think this would affect only me. Should I report it to the dev mailing list or something. Not sure of the etiquette there. I'm not sure whether this is a bug or not, I need to think about it. If i remember correctly, the database name is used for the database connection (including credentials) and the table layout. Probably there are some cases where this wants to be treated differently. But please open a jira issue on this ( https://issues.apache.org/jira/secure/Dashboard.jspa), so it will not be forgotten. Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Criteria needs write permissions?
The null ointer exception seems to come from reading the table or column map. Can you put a breakpoint in SQLBuilder.java:497 and see whether the table or the column cannot be found (and why it is not found)? Thomas Ok so I was trying to make our site a little safer from sql injections, so I made a database connection that connects with a user that only has SELECT permissions. And edited Criteria like such public Criteria() { this(DEFAULT_CAPACITY); this.setDbName(readonlydatabase); } Now it seems to work for must things, but a couple queries fail with throws java.lang.Exception java.lang.NullPointerException at org.apache.torque.util.SQLBuilder.processOrderBy (SQLBuilder.java:497) at org.apache.torque.util.SQLBuilder.buildQueryClause(SQLBuilder.java:302) at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:730) This error disappears as soon as I let the criteria use a database connection with write privileges. I know the user that it connects with has select privileges on every public table in the database. Does criteria need update privileges to work or something? The query the criteria constructs work fine when I connect as the readonly user and run it manually. Any thoughts? Thanks -- Sheldon Ross - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org