You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Derek Stevenson <de...@retrocode.com> on 2002/08/19 21:31:06 UTC

trying to delete data from db - doSelect shows cached data instead

I've got the following tables defined in my torque xml:

         <table name="MOCHA_USER" idMethod="none">
                 <column name="USER_ID" required="true" primaryKey="true" 
type="INTEGER"/>
         </table>

         <table name="USER_ATTRIBUTE_CODE">
                 <column name="UA_CODE" required="true" primaryKey="true" 
type="VARCHAR" size="8"/>
                 <column name="UA_DESC" type="VARCHAR" size="255"/>
         </table>

         <table name="USER_ATTRIBUTE">
                 <column name="USER_ID" required="true" primaryKey="true" 
type="INTEGER"/>
                 <column name="UA_CODE" required="true" primaryKey="true" 
type="VARCHAR" size="8"/>
                 <column name="VALUE" type="VARCHAR" size="255"/>

                 <foreign-key foreignTable="MOCHA_USER">
                         <reference local="USER_ID" foreign="USER_ID"/>
                 </foreign-key>
                 <foreign-key foreignTable="USER_ATTRIBUTE_CODE">
                         <reference local="UA_CODE" foreign="UA_CODE"/>
                 </foreign-key>
         </table>


I want to add a new user attribute to the USER_ATTRIBUTE table, but before 
doing so, I want to make sure all existing attributes of a particular class 
are deleted first.  For each of those attributes, I do the delete with the 
following method (in my torque-generated MochaUser object):

     public void clearUserFlag(String flagName) throws Exception {
         if (flagName != null || flagName.length() == 0) {
             Criteria crit = new Criteria();
             int userid = this.getUserId().getBigDecimal().intValue();
             crit.add(UserAttributePeer.USER_ID, userid);
             crit.add(UserAttributePeer.UA_CODE, flagName);
             UserAttributePeer.doDelete(crit);
             this.save();
         }
     }

Then, I add the appropriate attribute via the MochaUser.addUserAttribute() 
method, thus:

     public void addUserFlag(String flagName, String flagValue) throws 
Exception {
         // Add user attribute
         UserAttribute ua = new UserAttribute();
         ua.setUaCode(flagName);
         if (flagValue == null || flagValue == "") {
             flagValue = "true";
         }
         ua.setValue(flagValue);
         this.addUserAttribute(ua);
         ua.save();
     }

However, when I iterate through the Vector from 
MochaUser.getUserAttributes(), I get both the deleted user attributes and 
the newly added one!  When I check the database, though, the deleted user 
attribute is in fact gone.  So, here's my questions:

1. The getUserAttributes() method must be accessing some sort of cache of 
the attributes (from the source it looks like there's a Vector that's 
stored in memory to avoid db hits), and is returning the list of attributes 
initially provided by the database, plus whatever's been added via the 
addUserAttribute() method.  Should I be doing the delete a different way, 
that tells the MochaUser object to requery the database?  Or alternatively 
'notifies' MochaUser to delete the UserAttribute from its cached collection?

2. I'm pretty sure the clearUserFlag method above isn't the most elegant 
way to delete a user attribute.  Any recommendations for modifying the code?

TIA,
Derek


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Is there page caching in turbine?

Posted by Kris Woodbeck <kr...@webmotion.com>.
If you have a completely static (non-dependant on any database/etc.) 
page, just put the HTML straight into the .vm file, don't make an 
associated class for it, and it'll serve fast in the first place.  If 
you're thinking of making a page containing a large list of infrequently 
changing data, (such as the listing of ISPs in the article you 
mentioned) I would highly suggest any of a paging/alphabetical 
listing/searchable list approach instead of dumping *all* of the data to 
one big file (most users hate scrolling through hundreds of entries in 
the first place).  That'll decrease bandwidth usage, increase page 
loading time (obviously), most likely eliminate the need for caching, 
and just be nicer to users.  However, if you do insist on some type of 
caching (or your application really requires it), look into JCS ( 
http://jakarta.apache.org/turbine/jcs/ ) which is actually a part of 
turbine (so, yes, someone has implemented a caching system for turbine).

Kris

Yatin Shah wrote:

> Has anyone implemented any caching for static pages in turbine?
> I like to use turbine/velocity to serve static pages and retain 
> optimum throughput.
> What I'm looking for is described here in Jason Hunter's article: 
> http://www.servlets.com/soapbox/freecache.html
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Torque won't connect to multiple databases.

Posted by Skip Walker <sk...@gossamer-group.com>.
Using torque-3.0-b3.

I have one set of peers, the new fulcrum db security peers, that are
supposed to connect to database Data1.

I have another set of peers, Data2Peers, that supposed to connect to
database Data2.

I have the following defined in Torque.properties

torque.database.default=Data1
torque.database.Data1.adapter=mssql
torque.database.Data2.adapter=mssql

## Using torque's old pool
torque.dsfactory.Data1.factory=org.apache.torque.dsfactory.TorqueDataSourceF
actory
torque.dsfactory.Data1.pool.defaultMaxConnections=10
torque.dsfactory.Data1.pool.maxExpiryTime=3600
torque.dsfactory.Data1.pool.connectionWaitTimeout=10
torque.dsfactory.Data1.connection.driver = com.inet.pool.PoolDriver
torque.dsfactory.Data1.connection.url =
jdbc:inetpool:inetdae7:${torque.dbhost}?database=Data1&charset=Cp1252
torque.dsfactory.Data1.connection.user = User
torque.dsfactory.Data1.connection.password = Pass

torque.dsfactory.Data2.factory=org.apache.torque.dsfactory.TorqueDataSourceF
actory
torque.dsfactory.Data2.pool.defaultMaxConnections=10
torque.dsfactory.Data2.pool.maxExpiryTime=3600
torque.dsfactory.Data2.pool.connectionWaitTimeout=10
torque.dsfactory.Data2.connection.driver = com.inet.pool.PoolDriver
torque.dsfactory.Data2.connection.url =
jdbc:inetpool:inetdae7:${torque.dbhost}?database=Data2&charset=Cp1252
torque.dsfactory.Data2.connection.user = User
torque.dsfactory.Data2.connection.password = Pass


The problem I am having is that I can't get the security peers to connect to
database Data1 and Data2Peers to connect to database Data2.  It appears to
be a race condition.  If the security objects are executed first, then they
have no problem connecting to db Data1.  However, if Data2Peers then execute
subsequently, they don't connect to db Data2, and appear to try and connect
to db Data1, hence causing an SQLException regarding objects not found.

The same applies vice versa.

It appears that I can only get a connection to the first db that is
connected to via torque.

Has anyone else encountered this problem?  Any help is appreciated.

Thanks,
Skip




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Is there page caching in turbine?

Posted by Yatin Shah <yg...@kripa.com>.
Has anyone implemented any caching for static pages in turbine?
I like to use turbine/velocity to serve static pages and retain optimum 
throughput.
What I'm looking for is described here in Jason Hunter's article: 
http://www.servlets.com/soapbox/freecache.html

-- 
Yatin Shah, President                       mailto:ygs@kripa.com
Kripa Inc.                                  http://www.kripa.com
Dayton, New Jersey USA                      phone:  732.329.8303
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Developers of real time event driven distributed DB applications




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>