Re: Struts DB Access :: Best Practices
On 10 Mar 2005, at 13:48, NetSQL wrote: Ex#2: you can create a cursor to give everyone in NYC a raise, and go by row by row. Or you can do a set operation in one command. I allways avoid row by row, and allways try to go for set, as per direction by Celko and others. Your millage may vary. Okay, now I see what you are saying. Yes, a bulk UPDATE is certainly faster (and easier) than fetching a ResultSet and firing UPDATEs on each row. That's just a matter of using SQL properly. But this isn't the situation I was talking about. There are times it is legitimately necessary to get a large ResultSet in one gulp and pass it on to the client. This is what I was talking about; I don't want to keep the whole thing in memory. -- Scott Lamb <http://www.slamb.org/> PGP.sig Description: This is a digitally signed message part
Re: Struts DB Access :: Best Practices
On 10 Mar 2005, at 11:55, Scott Lamb wrote: - consistent dynamic sql (from what I see, there are different ways for altering the order and the where clauses..are there others?) There's also the , which is similar to your iterator. Ahh, lost a later draft with more here. There's no general-purpose lexical bind (like Oracle Forms & Reports' &foo). I also don't have a way of quoting SQL identifiers, as I haven't found the need. I sometimes execute queries like this: declare cursor grants is selectgrantee, granted_role from dba_role_privs where granted_role in ('FOO', 'BAR'); begin for grant in grants loop execute immediate 'revoke ' || quote_identifier(grant.granted_role) || ' from ' || quote_identifier(grantee); end loop; end; / show errors but those are infrequent admin tasks, and I'm happy just typing that block into SQL*Plus. I don't know why you'd do that from a web app. This is another case where I try to avoid implementing the feature before I see what needs it. I waited on lexical binds and added instead bind lists, conditionals, and dynamic order by clauses when each presented its need. They've all been much better for the task than lexical binds would be, and there might be some more left of that nature. -- Scott Lamb <http://www.slamb.org/> PGP.sig Description: This is a digitally signed message part
Re: Struts DB Access :: Best Practices
NetSQL wrote: Even silly JSF uses RowSet as DTO. (RowSet is realy a ArrayList of HashMaps. Rows of Columns) What does a ArrayList of HashMaps get you over a java.sql.ResultSet? I'll tell you a big disadvantage: it keeps everything in memory. What if the result set is large? I look at it like this: -SQL is a Set oriented lang.(row by row processing is exponentialy slower) This is totally wrong: - SQL is a multi-set-oriented language, much to the disgust of many relational database users. - "Exponentially" doesn't mean "a lot". It describes a function that asymptotically approaches e^n. - Putting all the data into another container _is_ row-by-row processing. You're always doing row-by-row processing, even just to fetch it from the database server. And once you've put it in whatever form you want, you still have to do row-by-row processing, or you've wasted your time fetching a lot of useless rows. Regards, Scott - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Struts DB Access :: Best Practices
On 10 Mar 2005, at 07:59, Larry Meadors wrote: Disclosure: I am an iBATIS developer, so I'd like to offer another opinion on the comparison. Cool! I might add an appendix to my documentation with this comparison. When I do, I'll give you another opportunity to complain. :) - iBATIS does database pooling for you; Axamol does not. I prefer to use the servlet container's built-in pooling. What about testing your DAOs? The dependency on the servlet container can become problematic. The client code is expected to pass in a java.sql.Connection or javax.sql.DataSource, so there's no direct dependency. - iBATIS does caching; Axamol does not. I haven't encountered the situation in which I'd want quite the caching they have. I work with iBATIS on a project where I regularly do queries over multi-gigabyte tables. Caching is darn handy in those situations. :-) I'm sure it is there. But I don't need it yet, and no one's complained to me that they do, either. I deliberately avoid writing features before they're needed. - iBATIS has a lot of options to use JavaBeans, which I don't find useful. I just take parameters in a java.util.Map and return a java.sql.ResultSet directly. (I'm a DynaActionForm kind of guy, so using a form bean form this would be a little out of place.) OK, now I have to just plain disagree with you. ;-) Using Maps and ResultSet in your application as the domain model is just plain bad design. It is difficult to test and too loosely coupled. I used to be of this school of thought also. But, well, then I encountered Python. ;) I'd like to do things statically, but not at the expense of writing lots of code. I particularly hate code initially generated by tools that I have to manually maintain afterward. And besides, everything else in a servlet container takes this approach - context, session, request, and page scope variables are all essentially map entries. - Axamol includes XSLT and standardized elements for embedding documentation in your libraries and producing HTML for them. Cool! I have wondered if including that in iBATIS would be used. Do your users use that much? What users? ;) Axamol SQL Library doesn't have the community iBATIS does. I use it, a friend uses it, and I've gotten a fair number of downloads. But my projects can be weird that way...even with NetGrowler, which _must_ be popular (lots of downloads, I see occasional mentions of it on forums), I only hear from users when they've got a problem or feature request. So I don't know how many users I have, much less exactly what parts of it they use. But my friend and I find it useful. A few other things I did not see in Axamol: - row handlers I'm not sure what you mean by this: - The things for grabbing a a single int value and such when you do count(*), rather than dealing with the whole ResultSet? I've thought about adding those, but for now Axamol SQL Library is dirt-simple: it just always gives you the ResultSet. - The things for linking to other queries on a per-row basis? I try to avoid those; I like my pages to make a constant number of queries. - consistent dynamic sql (from what I see, there are different ways for altering the order and the where clauses..are there others?) There's also the , which is similar to your iterator. The binding looks more awkward to me: iBATIS - select * from someTable where key = #id# axamol - select * from someTable where key = It is. I did it this way initially to avoid having to do any parsing; just for ease of implementation. I might end up introducing a syntax like that. I like how you handle multiple databases. Simple. Good job on that. Thanks. Cool project Scott, I hope you are not offended if we take some of your ideas for iBATIS. ;-) I'd be flattered. Larry Regards, Scott -- Scott Lamb <http://www.slamb.org/> PGP.sig Description: This is a digitally signed message part
Re: Struts DB Access :: Best Practices
karthikeyan balasubramanian wrote: I looked at iBATIS, it seems to be simple and easy to use. I will also check out others and let you know my thoughts. I'll add one to your list: Axamol SQL Library <http://www.slamb.org/projects/axamol/sql-library/> It's a project of mine, so I'd love to hear if it works out for you. (Or if it doesn't do what you need, but could if I added feature X.) It is similar to iBATIS SQL Maps but lighter / narrower in scope. I looked over their user manual recently, and the differences I spotted were: - iBATIS does database pooling for you; Axamol does not. I prefer to use the servlet container's built-in pooling. - iBATIS does caching; Axamol does not. I haven't encountered the situation in which I'd want quite the caching they have. - iBATIS has a lot of options to use JavaBeans, which I don't find useful. I just take parameters in a java.util.Map and return a java.sql.ResultSet directly. (I'm a DynaActionForm kind of guy, so using a form bean form this would be a little out of place.) - iBATIS has a lot of support for translating "magic" values (of the 9/9/99 variety) into nulls, which is a fundamentally bad idea. Axamol doesn't do this and never will. - iBATIS's conditional SQL elements have this prepend="..." attribute that I find confusing. I accomplish the same thing just by using boolean identities: "true and boolvar" = "false or boolvar" = "boolvar". Compare the example on iBATIS SQL Map's developer guide page 35 to my example two at <http://www.slamb.org/projects/axamol/sql-library/manual/pr01s02.html> and you'll see what I'm getting at. - Axamol includes XSLT and standardized elements for embedding documentation in your libraries and producing HTML for them. - Axamol captures timing statistics which are useful for determining where you need to optimize your SQL. Good luck, whatever you end up using. Regards, Scott -- Scott Lamb <http://www.slamb.org/> - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Licensing for org.apache.struts.taglib.html derivative
I'm developing a new JSP-like presentation layer.[*] As part of it, I am writing a Struts HTML tag library. If it looks suspiciously similar to org.apache.struts.taglib.html...well, it is. I'm intending for the usage to be identical. I've also been looking at the struts code while implementing it. There are certainly chunks that have ended up the same. The rest of my project is MIT-licensed with myself as the copyright holder. I'd be happy to do differently for this part of it. Should I just copy the headers of the struts html files, placing it under the Apache license and assigning copyright to the ASF? Or what would you like me to do? I'd certainly like to give people the proper credit for their work. Thanks, Scott [*] - Somewhat out-of-date webpage at <http://www.slamb.org/projects/axamol/sax-pipeline/>. It's essentially JSP for SAX instead of raw text streams. Like Apache Cocoon, but much smaller in scope and with JSP-style tag libraries instead of horrible XSLT+Java logicsheets. -- Scott Lamb <http://www.slamb.org/> PGP.sig Description: This is a digitally signed message part