Here are the patches, attached.

the msssql.properties goes to /trunk/metadata/database

-----Original Message-----
From: George Daswani [mailto:[EMAIL PROTECTED]
Sent: Friday, February 10, 2006 11:18 PM
To: [email protected]
Subject: RE: Submitting patches, Microsoft SQL Server


Thanks for the reply.

I submitted it to the JIRA - as ROL-1044 

Attached an svn diff file, along with the new properties file (datatype) for 
Microsoft SQL Server 2000 (should also work with 2005).

I've tested it both on the JTDS 1.2 Type4 JDBC Driver, along with Microsoft's 
MSSQL-2005 Type JDBC driver.

George Daswani

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 07, 2006 6:10 AM
To: [email protected]
Subject: Re: Submitting patches, Microsoft SQL Server



You should be able to use the "svn diff" command or your favorite IDE  
file to create a patch containing your changes and new files. Once  
you have that, send it to the Roller dev mailing list or create an  
issue in JIRA and attach it to that issue. Once you've done that, one  
of us will look at it and if it looks good we'll commit it.

- Dave



On Feb 6, 2006, at 4:16 PM, George Daswani wrote:
> Hello Roller Developers,
>
>       We looked at the Roller package and we are planning on using it as  
> our main blog software.  I've modified the sources and builds to  
> support Microsoft SQL server - how do we go about submitting the  
> patches? (format, and etc).
>
> The process/procedure doesn't seem to be listed in the Roller Wiki.
>
> Thanks,
> George Daswani
> ESRI / InfoServices-Systems Development
>
>
>
>



Index: metadata/database/derby.properties
===================================================================
--- metadata/database/derby.properties  (revision 376935)
+++ metadata/database/derby.properties  (working copy)
@@ -9,4 +9,5 @@
 INDEXSIZE_LARGE=
 ADDL_FK_PARAMS=
 TIMESTAMP_SQL_TYPE_NULL=timestamp
+TIMESTAMP_SQL_TYPE=timestamp
 
Index: metadata/database/mysql.properties
===================================================================
--- metadata/database/mysql.properties  (revision 376935)
+++ metadata/database/mysql.properties  (working copy)
@@ -9,3 +9,4 @@
 INDEXSIZE_LARGE=(100)
 ADDL_FK_PARAMS=    
 TIMESTAMP_SQL_TYPE_NULL=datetime NULL
+TIMESTAMP_SQL_TYPE=datetime
\ No newline at end of file
Index: metadata/database/oracle.properties
===================================================================
--- metadata/database/oracle.properties (revision 376935)
+++ metadata/database/oracle.properties (working copy)
@@ -9,3 +9,4 @@
 INDEXSIZE_LARGE=
 ADDL_FK_PARAMS=
 TIMESTAMP_SQL_TYPE_NULL=timestamp null
+TIMESTAMP_SQL_TYPE=timestamp
Index: metadata/database/hibernate/hibernate.cfg.xml
===================================================================
--- metadata/database/hibernate/hibernate.cfg.xml       (revision 376935)
+++ metadata/database/hibernate/hibernate.cfg.xml       (working copy)
@@ -11,12 +11,14 @@
         <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
         
         <!--
-        If you want to use HSQLDB, PostgreSQL, DB2 or Derby, Oracle then use 
the right dialect   
+        If you want to use HSQLDB, PostgreSQL, DB2 or Derby, Oracle, SQLServer 
then use the right dialect   
         <property name="dialect">org.hibernate.dialect.HQLDBDialect</property> 
         <property 
name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
         <property name="dialect">org.hibernate.dialect.DB2Dialect</property>
         <property name="dialect">org.hibernate.dialect.DerbyDialect</property>
         <property 
name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
+        <property 
name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
+        <property 
name="dialect">org.hibernate.dialect.SQLServerDialect</property>
         -->
 
         <!--
Index: metadata/database/db2.properties
===================================================================
--- metadata/database/db2.properties    (revision 376935)
+++ metadata/database/db2.properties    (working copy)
@@ -9,3 +9,4 @@
 INDEXSIZE_LARGE=
 ADDL_FK_PARAMS=on delete no action on update no action enforced enable query 
optimization
 TIMESTAMP_SQL_TYPE_NULL=timestamp null
+TIMESTAMP_SQL_TYPE=timestamp
Index: metadata/database/hsqldb.properties
===================================================================
--- metadata/database/hsqldb.properties (revision 376935)
+++ metadata/database/hsqldb.properties (working copy)
@@ -9,3 +9,4 @@
 INDEXSIZE_LARGE=
 ADDL_FK_PARAMS=
 TIMESTAMP_SQL_TYPE_NULL=timestamp null
+TIMESTAMP_SQL_TYPE=timestamp
Index: metadata/database/createdb.vm
===================================================================
--- metadata/database/createdb.vm       (revision 376935)
+++ metadata/database/createdb.vm       (working copy)
@@ -15,7 +15,7 @@
     passphrase      varchar(255) not null,
     fullname        varchar(255) not null,
     emailaddress    varchar(255) not null,
-    datecreated     timestamp not null,
+    datecreated     $TIMESTAMP_SQL_TYPE not null,
     locale          varchar(20),  
     timezone        varchar(50),    
     isenabled       $BOOLEAN_SQL_TYPE_TRUE not null
@@ -54,14 +54,14 @@
     object_id       varchar(48),           
     object_class    varchar(255),          
     comment_text    varchar(255) not null, 
-    change_time     timestamp              
+    change_time     $TIMESTAMP_SQL_TYPE              
 );
 
 create table usercookie (
     id              varchar(48) not null primary key,
     username        varchar(255) not null,
     cookieid        varchar(100) not null,
-    datecreated     timestamp not null
+    datecreated     $TIMESTAMP_SQL_TYPE not null
 );
 create index uc_username_idx on usercookie( username$!INDEXSIZE );
 create index uc_cookieid_idx on usercookie( cookieid$!INDEXSIZE );
@@ -73,7 +73,7 @@
     link            varchar(255),
     websiteid       varchar(48)  not null,
     template        $TEXT_SQL_TYPE not null,
-    updatetime      timestamp     not null
+    updatetime      $TIMESTAMP_SQL_TYPE     not null
 );
 create index wp_name_idx on webpage( name$!INDEXSIZE );
 create index wp_link_idx on webpage( link$!INDEXSIZE );
@@ -102,7 +102,7 @@
     defaultplugins    varchar(255),
     isenabled         $BOOLEAN_SQL_TYPE_TRUE not null,
     isactive          $BOOLEAN_SQL_TYPE_TRUE not null,
-    datecreated      timestamp not null,
+    datecreated      $TIMESTAMP_SQL_TYPE not null,
     blacklist            $TEXT_SQL_TYPE,
     defaultallowcomments $BOOLEAN_SQL_TYPE_TRUE not null,
     defaultcommentdays   integer default 7 not null,
@@ -175,7 +175,7 @@
     title           varchar(255)  not null,
     text            $TEXT_SQL_TYPE not null,
     pubtime         $TIMESTAMP_SQL_TYPE_NULL,
-    updatetime      timestamp     not null,
+    updatetime      $TIMESTAMP_SQL_TYPE     not null,
     websiteid       varchar(48)  not null,
     categoryid      varchar(48)  not null,
     publishentry    $BOOLEAN_SQL_TYPE_TRUE not null,
@@ -213,7 +213,7 @@
     email   varchar(255),
     url     varchar(255),
     content $TEXT_SQL_TYPE,
-    posttime timestamp   not null,
+    posttime $TIMESTAMP_SQL_TYPE   not null,
     spam    $BOOLEAN_SQL_TYPE_FALSE not null,
     notify  $BOOLEAN_SQL_TYPE_FALSE not null,
     remotehost varchar(128),
@@ -236,7 +236,7 @@
     pingurl      varchar(255) not null,
     websiteid    varchar(48),
     conditioncode    integer default 0 not null,
-    lastsuccess  timestamp
+    lastsuccess  $TIMESTAMP_SQL_TYPE
 );
 create index pt_websiteid_idx on pingtarget( websiteid );
 
@@ -267,7 +267,7 @@
 -- attempts:  number of ping attempts that have been made for this entry
 create table pingqueueentry (
     id             varchar(48) not null primary key,
-    entrytime      timestamp not null, 
+    entrytime      $TIMESTAMP_SQL_TYPE not null, 
     pingtargetid   varchar(48) not null,  
     websiteid      varchar(48) not null,  
     attempts       integer not null
@@ -285,7 +285,7 @@
     datestr   varchar(10),
     refurl    varchar(255) not null,
     refpermalink varchar(255),
-    reftime   timestamp,
+    reftime   $TIMESTAMP_SQL_TYPE,
     requrl    varchar(255),
     title     varchar(255),
     excerpt   $TEXT_SQL_TYPE,
@@ -394,7 +394,7 @@
     feed_url         varchar(255) not null,
     site_url         varchar(255),
     author           varchar(255),
-    last_updated     timestamp,
+    last_updated     $TIMESTAMP_SQL_TYPE,
     inbound_links    integer default -1,
     inbound_blogs    integer default -1
 );
@@ -410,8 +410,8 @@
     author           varchar(255),
     content          $TEXT_SQL_TYPE,
     categories       $TEXT_SQL_TYPE,
-    published        timestamp not null,
-    updated          timestamp    
+    published        $TIMESTAMP_SQL_TYPE not null,
+    updated          $TIMESTAMP_SQL_TYPE    
 );
 create index rage_sid_idx on rag_entry(subscription_id$!INDEXSIZE); 
 
Index: metadata/database/postgresql.properties
===================================================================
--- metadata/database/postgresql.properties     (revision 376935)
+++ metadata/database/postgresql.properties     (working copy)
@@ -9,3 +9,4 @@
 INDEXSIZE_LARGE=
 ADDL_FK_PARAMS=
 TIMESTAMP_SQL_TYPE_NULL=timestamp null
+TIMESTAMP_SQL_TYPE=timestamp
Index: src/org/roller/business/hibernate/HibernateRefererManagerImpl.java
===================================================================
--- src/org/roller/business/hibernate/HibernateRefererManagerImpl.java  
(revision 376935)
+++ src/org/roller/business/hibernate/HibernateRefererManagerImpl.java  
(working copy)
@@ -31,6 +31,13 @@
 import org.roller.pojos.WeblogEntryData;
 import org.roller.pojos.WebsiteData;
 import org.roller.pojos.WebsiteDisplayData;
+import org.hibernate.dialect.DB2Dialect;
+import org.hibernate.dialect.DerbyDialect;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.dialect.OracleDialect;
+import org.hibernate.dialect.SQLServerDialect;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.dialect.Dialect;
 
 
 /**
@@ -178,7 +185,10 @@
             con = ses.connection();
             
             final PreparedStatement stmt;
-            if (con.getMetaData().getDriverName().startsWith("HSQL")) {
+
+                       Dialect currentDialect = 
((SessionFactoryImplementor)ses.getSessionFactory()).getDialect();
+            
+            if (currentDialect instanceof HSQLDialect) {
                 // special handling for HSQLDB
                 stmt = con.prepareStatement(
                         "select top ? w.id,w.name,w.handle,sum(r.dayhits) as s 
"+
@@ -188,7 +198,7 @@
                 stmt.setInt(1, max);
                 stmt.setBoolean(2, true);
                 stmt.setBoolean(3, true);
-            } else if(con.getMetaData().getDriverName().startsWith("Apache 
Derby")) {
+            } else if(currentDialect instanceof DerbyDialect) {
                   // special handling for Derby
                                stmt = con.prepareStatement(
                                    "select w.name, w.handle, w.id, 
sum(r.dayhits) as s "+
@@ -198,7 +208,7 @@
                                stmt.setBoolean(1, true);                       
        
                 stmt.setBoolean(2, true);
                 stmt.setMaxRows(max);
-            } else if(con.getMetaData().getDriverName().startsWith("IBM DB2")) 
{
+            } else if(currentDialect instanceof DB2Dialect) {
                 // special handling for IBM DB2
                 stmt = con.prepareStatement(
                         "select u.username,w.name,w.name,sum(r.dayhits) as s "+
@@ -208,7 +218,7 @@
                         Integer.toString(max) + " rows only");
                 stmt.setBoolean(1, true);
                 stmt.setBoolean(2, true);
-            } else if (con.getMetaData().getDriverName().startsWith("Oracle")) 
{
+            } else if (currentDialect instanceof OracleDialect) {
                                String sql = "select 
u.username,w.name,w.handle,sum(r.dayhits) as s "+
                 "from rolleruser u, website w, referer r "+
                 "where r.websiteid=w.id and w.userid=u.id and w.isenabled=? 
and w.isactive=? and rownum <= ? " +
@@ -216,7 +226,14 @@
                                stmt = con.prepareStatement(sql);
                                stmt.setBoolean(1, true);
                                stmt.setBoolean(2, true);
-                               stmt.setInt(3, max );                           
+                               stmt.setInt(3, max );
+            } else if (currentDialect instanceof SQLServerDialect) {
+               String sql = "select top " + max + " 
w.id,w.name,w.handle,sum(r.dayhits) as s " +
+                               "from website as w, referer as r where 
r.websiteid=w.id and w.isenabled= ? " +
+                               "group by w.name,w.handle,w.id order by s desc";
+                               // special handling for Microsoft SQLServer
+                               stmt = con.prepareStatement(sql);
+                               stmt.setBoolean(1, true);
             } else {
                 stmt = con.prepareStatement(
                         "select w.id,w.name,w.handle,sum(r.dayhits) as s "+
@@ -486,7 +503,14 @@
             Session session = ((HibernateStrategy)mStrategy).getSession();
             String reset = "update RefererData set dayHits=0";
             session.createQuery(reset).executeUpdate();
-            String delete = "delete RefererData where excerpt is null or 
excerpt=''";
+            Dialect currentDialect = 
((SessionFactoryImplementor)session.getSessionFactory()).getDialect();
+            String delete = null;
+            if ( currentDialect instanceof SQLServerDialect ){
+               // cannot use = on text,image (blob) fields on sql server, only 
like
+               delete = "delete RefererData where excerpt is null or excerpt 
like ''";
+            } else {
+               delete = "delete RefererData where excerpt is null or 
excerpt=''";
+            }
             session.createQuery(delete).executeUpdate();
         } catch (Exception e) {
             mLogger.error("EXCEPTION resetting referers",e);
@@ -506,7 +530,14 @@
             String reset = "update RefererData set dayHits=0 where 
website=:site";
             session.createQuery(reset)
                 .setParameter("site",website).executeUpdate();
-            String delete = "delete RefererData where website=:site and 
(excerpt is null or excerpt='')";
+            Dialect currentDialect = 
((SessionFactoryImplementor)session.getSessionFactory()).getDialect();
+            String delete = null;
+            if ( currentDialect instanceof SQLServerDialect){
+               // cannot use = on text,image (blob) fields on sql server, only 
like
+               delete = "delete RefererData where website=:site and (excerpt 
is null or excerpt like '')";
+            } else {
+               delete = "delete RefererData where website=:site and (excerpt 
is null or excerpt='')";
+            }
             session.createQuery(delete)
                 .setParameter("site",website).executeUpdate();
         } catch (Exception e) {
Index: build.xml
===================================================================
--- build.xml   (revision 376935)
+++ build.xml   (working copy)
@@ -522,6 +522,12 @@
          templatePath="${basedir}/metadata/database/" 
          outputDirectory="build/roller/WEB-INF/dbscripts/oracle/" 
          outputFile="README.txt" />
+     <texen 
+         controlTemplate="control.vm" 
+         contextProperties="${basedir}/metadata/database/mssql.properties"
+         templatePath="${basedir}/metadata/database/" 
+         outputDirectory="build/roller/WEB-INF/dbscripts/mssql/" 
+         outputFile="README.txt" />
 </target>
 
 <!-- ********************************************************************* -->

Reply via email to