Index: /trunk/fmgVen/etc/test-db/test-db-changelog.xml
===================================================================
--- /trunk/fmgVen/etc/test-db/test-db-changelog.xml	(revision 25)
+++ /trunk/fmgVen/etc/test-db/test-db-changelog.xml	(revision 26)
@@ -4,475 +4,33 @@
     </changeSet>
     <changeSet author="fmguler" id="0">
-        <tagDatabase tag="0"/>
+        <tagDatabase tag="tag-init"/>
     </changeSet>
     <!-- TEST SCHEMA >> -->
     <changeSet author="fmguler" id="1">
-        <createTable schemaName="public" tableName="aa_authorization_parameter">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="aa_authorization_parameter_pkey"/>
+        <createTable schemaName="public" tableName="some_domain_object">
+            <column autoIncrement="true" name="id" type="serial">
+                <constraints nullable="false" primaryKey="true" primaryKeyName="some_domain_object_pkey"/>
             </column>
-            <column name="param_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="attribute" type="VARCHAR(100)"/>
-            <column name="operator" type="VARCHAR(100)"/>
-            <column name="value" type="TEXT(2147483647)"/>
-            <column name="connective" type="VARCHAR(10)"/>
-            <column name="order" type="int4">
-                <constraints nullable="false"/>
-            </column>
+            <column name="name" type="VARCHAR(100)"/>
+            <column name="description" type="TEXT(2147483647)"/>
+            <column name="date" type="TIMESTAMP WITHOUT TIME ZONE"/>
         </createTable>
     </changeSet>
     <changeSet author="fmguler" id="2">
-        <createTable schemaName="public" tableName="aa_group">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="aa_group_pkey"/>
-            </column>
-            <column name="name" type="VARCHAR(100)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="description" type="VARCHAR(1000)"/>
-        </createTable>
+        <tagDatabase tag="tag-single-table"/>
     </changeSet>
     <changeSet author="fmguler" id="3">
-        <createTable schemaName="public" tableName="aa_group_authorization">
-            <column name="auth_name" type="VARCHAR(100)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="group_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="param_no" type="int4"/>
-            <column name="rule" type="int4"/>
-        </createTable>
+        <insert schemaName="public" tableName="some_domain_object">
+            <column name="name" value="name1"/>
+            <column name="description" value="desc1"/>
+            <column name="date" value="2010-10-13"/>
+        </insert>
+        <rollback>
+            delete from some_domain_object;
+        </rollback>
     </changeSet>
     <changeSet author="fmguler" id="4">
-        <createTable schemaName="public" tableName="aa_user_group">
-            <column name="username" type="VARCHAR(100)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="group_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="order" type="int4">
-                <constraints nullable="false"/>
-            </column>
-        </createTable>
+        <tagDatabase tag="tag-single-table-data"/>
     </changeSet>
-    <changeSet author="fmguler" id="5">
-        <createTable schemaName="public" tableName="user_attribute">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="user_attribute_pkey"/>
-            </column>
-            <column autoIncrement="true" name="user_no" type="serial">
-                <constraints nullable="false"/>
-            </column>
-            <column name="attribute" type="VARCHAR(100)"/>
-            <column name="value" type="TEXT(2147483647)"/>
-            <column name="type" type="VARCHAR(100)"/>
-            <column defaultValueNumeric="0" name="priority" type="int4"/>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="6">
-        <createTable schemaName="public" tableName="user_authentication">
-            <column name="username" type="VARCHAR(150)">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="user_authentication_pkey"/>
-            </column>
-            <column name="password" type="VARCHAR(150)">
-                <constraints nullable="false"/>
-            </column>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="7">
-        <createTable schemaName="public" tableName="user_operation">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="user_operation_pkey"/>
-            </column>
-            <column name="username" type="VARCHAR(100)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="module" type="VARCHAR(100)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="operation" type="VARCHAR(100)">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueDate="now()" name="date" type="TIMESTAMP WITHOUT TIME ZONE">
-                <constraints nullable="false"/>
-            </column>
-            <column name="parameter" type="TEXT(2147483647)"/>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="8">
-        <addPrimaryKey columnNames="auth_name, group_no" constraintName="aa_group_authorization_pkey" schemaName="public" tableName="aa_group_authorization"/>
-    </changeSet>
-    <changeSet author="fmguler" id="9">
-        <addPrimaryKey columnNames="username, group_no" constraintName="aa_user_group_pkey" schemaName="public" tableName="aa_user_group"/>
-    </changeSet>
-    <changeSet author="fmguler" id="10">
-        <addUniqueConstraint columnNames="user_no, attribute" constraintName="user_attribute_user_no_key" schemaName="public" tableName="user_attribute"/>
-    </changeSet>
-    <changeSet author="fmguler" id="11">
-        <createIndex indexName="aa_param_index" schemaName="public" tableName="aa_authorization_parameter" unique="false">
-            <column name="param_no"/>
-        </createIndex>
-    </changeSet>
-    <changeSet author="fmguler" id="12">
-        <createIndex indexName="aa_param_index2" schemaName="public" tableName="aa_group_authorization" unique="false">
-            <column name="param_no"/>
-        </createIndex>
-    </changeSet>
-    <changeSet author="fmguler" id="13">
-        <createIndex indexName="aa_auth_name_index" schemaName="public" tableName="aa_group_authorization" unique="false">
-            <column name="auth_name"/>
-        </createIndex>
-    </changeSet>
-    <changeSet author="fmguler" id="14">
-        <createIndex indexName="aa_user_group_index" schemaName="public" tableName="aa_user_group" unique="false">
-            <column name="username"/>
-            <column name="group_no"/>
-        </createIndex>
-    </changeSet>
-    <changeSet author="fmguler" id="15">
-        <createIndex indexName="user_operation_index" schemaName="public" tableName="user_operation" unique="false">
-            <column name="username"/>
-            <column name="module"/>
-            <column name="operation"/>
-            <column name="date"/>
-        </createIndex>
-    </changeSet>
-    <changeSet author="fmguler" id="16">
-        <addForeignKeyConstraint baseColumnNames="group_no" baseTableName="aa_group_authorization" baseTableSchemaName="public" constraintName="aa_group_authorization_group_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="RESTRICT" referencedColumnNames="no" referencedTableName="aa_group" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="17">
-        <createView schemaName="public" viewName="user_view">
-            <![CDATA[SELECT ua.user_no, u1.value AS username, u2.value AS full_name, u3.value AS receipt_signing_type, u4.value AS mobile_signature_phone_number, u5.value AS mobile_signature_credit FROM ((((((SELECT DISTINCT user_attribute.user_no FROM user_attribute ORDER BY user_attribute.user_no) ua LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'username'::text)) u1 ON ((ua.user_no = u1.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'fullName'::text)) u2 ON ((ua.user_no = u2.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'receiptSigningType'::text)) u3 ON ((ua.user_no = u3.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'mobileSignaturePhoneNumber'::text)) u4 ON ((ua.user_no = u4.user_no))) LEFT JOIN (SELECT user_attribute.user_no, user_attribute.value FROM user_attribute WHERE ((user_attribute.attribute)::text = 'mobileSignatureCredit'::text)) u5 ON ((ua.user_no = u5.user_no))) ORDER BY ua.user_no;]]>
-        </createView>
-    </changeSet>
-    <changeSet author="fmguler" id="18">
-        <comment>SERIAL'ler serilerin sonuna _seq ekliyor, ama kodda oldugu gibi cagirabiliyoruz</comment>
-        <sql>
-          ALTER TABLE aa_authorization_parameter_no_seq RENAME TO aa_authorization_parameter_no;
-          ALTER TABLE aa_group_no_seq RENAME TO aa_group_no;
-          ALTER TABLE user_attribute_no_seq RENAME TO user_attribute_no;
-          ALTER TABLE user_attribute_user_no_seq RENAME TO user_no;
-          ALTER TABLE user_operation_no_seq RENAME TO user_operation_no;
-        </sql>
-        <rollback/>
-    </changeSet>
-    <changeSet author="fmguler" id="19">
-        <comment>Default Data</comment>
-        <sql>
-          INSERT INTO aa_group ("no", name, description) VALUES (1, 'Signomat Base Users', 'Signomat Base Users, have basic usage rights');
-          INSERT INTO aa_group ("no", name, description) VALUES (2, 'SignArt Client Users', 'SignArt Client Users, have access to CSP mobile signing facilities');
-          INSERT INTO aa_group ("no", name, description) VALUES (3, 'Workspace Users', 'Workspace Users, have access to /workspace web pages');
-          INSERT INTO aa_group ("no", name, description) VALUES (4, 'Dox Users', 'Dox Users, have access to /dox web pages');
-          INSERT INTO aa_group ("no", name, description) VALUES (5, 'Admin Users', 'Admin Users have access to /admin web pages');
-          INSERT INTO aa_group ("no", name, description) VALUES (6, 'Demo Users', 'Demo Users have limited access, no access to DoX, and no timestamp facilities in signing portal');
-
-
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 1, NULL, 1);
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 2, NULL, 2);
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 3, NULL, 3);
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 4, NULL, 4);
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 5, NULL, 5);
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('PageAccessAuth', 6, NULL, 3);
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('SignAuth', 3, NULL, 1);
-          INSERT INTO aa_group_authorization (auth_name, group_no, param_no, "rule") VALUES ('SignAuth', 6, NULL, 2);
-
-
-          INSERT INTO user_attribute (attribute, value, "type", priority) VALUES ('username', 'admin', '00_id', 0);
-          INSERT INTO user_attribute (user_no, attribute, value, "type", priority) VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 'citizenshipNumber', '12345', '00_id', 0);
-          INSERT INTO user_authentication (username, "password") VALUES ('12345', '21232f297a57a5a743894a0e4a801fc3');
-
-
-          INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 1, 1);
-          INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 3, 2);
-          INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 4, 3);
-          INSERT INTO aa_user_group (username, group_no, "order") VALUES ((select user_no from user_attribute where attribute = 'username' and value='admin'), 5, 4);
-        </sql>
-        <rollback/>
-    </changeSet>
-    <changeSet author="fmguler" id="20" runOnChange="true">
-        <comment>Function to delete all data from all tables. Can be updated later (runAlways is set)</comment>
-        <createProcedure><![CDATA[
-          --DROP FUNCTION db_delete_all_data();
-          CREATE OR REPLACE FUNCTION db_delete_all_data() RETURNS character varying
-              LANGUAGE plpgsql
-              AS 'DECLARE
-              table_list VARCHAR(100000);
-              mtable RECORD;
-          BEGIN
-
-             table_list := '''';
-              -- public semasinda bulunan tum tablolar, bizim tablolarimiz  
-              
-              FOR mtable IN select * from pg_tables where schemaname = ''public'' LOOP                
-                  IF position(''databasechangelog'' in mtable.tablename)>0 THEN CONTINUE; END IF;
-                  table_list := table_list || quote_ident(mtable.tablename) || '', '';
-              END LOOP;
-
-              table_list := substring(table_list from 0 for length(table_list)-1);
-
-              EXECUTE ''TRUNCATE TABLE '' || table_list;        
-                  
-              RETURN table_list;
-          END;';
-          ]]>
-        </createProcedure>
-        <rollback/>
-    </changeSet>
-    <!-- << INFRASTRUCTURE SCHEMA -->
-    <!-- WORKSPACE SCHEMA >> -->
-    <changeSet author="fmguler" id="21">
-        <createTable schemaName="public" tableName="workspace_file">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="workspace_file_pkey"/>
-            </column>
-            <column name="user_no" type="int4"/>
-            <column name="file_path" type="VARCHAR(10000)"/>
-            <column name="file_summary" type="TEXT(2147483647)"/>
-            <column name="status" type="int4"/>
-            <column name="creation_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
-            <column name="file_extension" type="VARCHAR(1024)"/>
-            <column defaultValueBoolean="false" name="temporary" type="bool">
-                <constraints nullable="false"/>
-            </column>
-        </createTable>
-    </changeSet>
-    <!-- << WORKSPACE SCHEMA -->
-    <changeSet author="fmguler" id="22">
-        <tagDatabase tag="21"/>
-    </changeSet>
-    <!-- DOX SCHEMA >> -->
-    <changeSet author="fmguler" id="23">
-        <createTable schemaName="public" tableName="dox_message">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="dox_message_pkey"/>
-            </column>
-            <column name="type" type="int4"/>
-            <column name="subject" type="VARCHAR(10000)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="content" type="TEXT(2147483647)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="sender" type="VARCHAR(1024)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="date" type="TIMESTAMP WITHOUT TIME ZONE"/>
-            <column defaultValueNumeric="0" name="options" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="status" type="int4">
-                <constraints nullable="false"/>
-            </column>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="24">
-        <createTable schemaName="public" tableName="dox_message_attribute">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="dox_message_attribute_pkey"/>
-            </column>
-            <column name="message_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="type" type="VARCHAR(1024)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="attribute" type="VARCHAR(1024)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="value" type="TEXT(2147483647)">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="order" type="int4">
-                <constraints nullable="false"/>
-            </column>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="25">
-        <createTable schemaName="public" tableName="dox_message_attachment">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="dox_message_attachment_pkey"/>
-            </column>
-            <column name="message_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="content_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="content_type" type="VARCHAR(1000)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="name" type="VARCHAR(10000)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="reference" type="VARCHAR(1000)">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="flags" type="int4">
-                <constraints nullable="false"/>
-            </column>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="26">
-        <createTable schemaName="public" tableName="dox_content">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="dox_attachment_content_pkey"/>
-            </column>
-            <column name="path" type="VARCHAR(10000)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="hash" type="VARCHAR(1024)"/>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="27">
-        <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_message_attribute" baseTableSchemaName="public" constraintName="dox_message_attribute_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="28">
-        <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_message_attachment" baseTableSchemaName="public" constraintName="dox_message_attachment_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="29">
-        <addForeignKeyConstraint baseColumnNames="content_no" baseTableName="dox_message_attachment" baseTableSchemaName="public" constraintName="dox_message_attachment_content_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_content" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="30">
-        <tagDatabase tag="29"/>
-    </changeSet>
-    <!-- DOX SCHEMA (TRANSACTION) >> -->
-    <changeSet author="fmguler" id="31">
-        <createTable schemaName="public" tableName="dox_domain">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="dox_domain_pkey"/>
-            </column>
-            <column name="domain" type="VARCHAR(1024)"/>
-            <column name="address" type="VARCHAR(2048)"/>
-            <column name="client_certificate" type="TEXT(2147483647)"/>
-            <column name="server_certificate" type="TEXT(2147483647)"/>
-            <column defaultValueBoolean="false" name="can_relay" type="bool">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="protocol" type="int4">
-                <constraints nullable="false"/>
-            </column>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="32">
-        <createTable schemaName="public" tableName="dox_transaction_log">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="dox_transaction_log_pkey"/>
-            </column>
-            <column name="message_no" type="int4"/>
-            <column name="sender" type="VARCHAR(1024)">
-                <constraints nullable="false"/>
-            </column>
-            <column name="recipient" type="VARCHAR(1024)">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="sender_domain_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="recipient_domain_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueBoolean="false" name="relay" type="bool">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueDate="now()" name="date" type="TIMESTAMP WITHOUT TIME ZONE">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="protocol" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="status" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="details" type="TEXT(2147483647)"/>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="33">
-        <createTable schemaName="public" tableName="dox_user_message">
-            <column autoIncrement="true" name="no" type="serial">
-                <constraints nullable="false" primaryKey="true" primaryKeyName="dox_user_message_pkey"/>
-            </column>
-            <column name="user_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="message_no" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column defaultValueNumeric="0" name="folder" type="int4">
-                <constraints nullable="false"/>
-            </column>
-            <column name="transaction_log_no" type="int4"/>
-        </createTable>
-    </changeSet>
-    <changeSet author="fmguler" id="34">
-        <addForeignKeyConstraint baseColumnNames="sender_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_sender_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="35">
-        <addForeignKeyConstraint baseColumnNames="recipient_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_recipient_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="36">
-        <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="37">
-        <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="38">
-        <addForeignKeyConstraint baseColumnNames="transaction_log_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_transaction_log_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="SET NULL" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_transaction_log" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="39">
-        <tagDatabase tag="38"/>
-    </changeSet>
-    <!-- DOX SCHEMA (UPDATE 1) -->
-    <changeSet author="fmguler" id="40">
-        <addColumn tableName="dox_message_attachment" schemaName="public">
-            <column name="content_length" type="int4" defaultValueNumeric="0"/>
-        </addColumn>
-        <comment>to keep track of attachment size, and tell to the browser while downloading</comment>
-    </changeSet>
-    <changeSet author="fmguler" id="41">
-        <comment>
-            change on delete cascade to on delete restrict of some foreign key constraints, since referencing tables does not belong to referenced tables
-            e.g. Msg. attachment does not belong to content, if a msg attch. exists, referenced content cannot be deleted.
-        </comment>
-        <dropForeignKeyConstraint baseTableName="dox_message_attachment" baseTableSchemaName="public" constraintName="dox_message_attachment_content_no_fkey"/>
-        <rollback changeSetId="29" changeSetAuthor="fmguler" />
-    </changeSet>
-    <changeSet author="fmguler" id="42">
-        <addForeignKeyConstraint baseTableName="dox_message_attachment" baseTableSchemaName="public" baseColumnNames="content_no"  constraintName="dox_message_attachment_content_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_content" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="43">
-        <dropForeignKeyConstraint baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_recipient_domain_no_fkey"/>
-        <rollback changeSetId="35" changeSetAuthor="fmguler" />
-    </changeSet>
-    <changeSet author="fmguler" id="44">
-        <addForeignKeyConstraint baseColumnNames="recipient_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_recipient_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="45">
-        <dropForeignKeyConstraint baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_sender_domain_no_fkey"/>
-        <rollback changeSetId="34" changeSetAuthor="fmguler" />
-    </changeSet>
-    <changeSet author="fmguler" id="46">
-        <addForeignKeyConstraint baseColumnNames="sender_domain_no" baseTableName="dox_transaction_log" baseTableSchemaName="public" constraintName="dox_transaction_log_sender_domain_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_domain" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="47">
-        <dropForeignKeyConstraint baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_transaction_log_no_fkey"/>
-        <rollback changeSetId="38" changeSetAuthor="fmguler" />
-    </changeSet>
-    <changeSet author="fmguler" id="48">
-        <addForeignKeyConstraint baseColumnNames="transaction_log_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_transaction_log_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_transaction_log" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="49">
-        <dropForeignKeyConstraint baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_message_no_fkey"/>
-        <rollback changeSetId="37" changeSetAuthor="fmguler" />
-    </changeSet>
-    <changeSet author="fmguler" id="50">
-        <addForeignKeyConstraint baseColumnNames="message_no" baseTableName="dox_user_message" baseTableSchemaName="public" constraintName="dox_user_message_message_no_fkey" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="CASCADE" referencedColumnNames="no" referencedTableName="dox_message" referencedTableSchemaName="public"/>
-    </changeSet>
-    <changeSet author="fmguler" id="51">
-        <tagDatabase tag="50"/>
-    </changeSet>
-    <!-- << DOX SCHEMA -->
+    <!-- << TEST SCHEMA -->
 </databaseChangeLog>
Index: /trunk/fmgVen/nbproject/build-impl.xml
===================================================================
--- /trunk/fmgVen/nbproject/build-impl.xml	(revision 25)
+++ /trunk/fmgVen/nbproject/build-impl.xml	(revision 26)
@@ -80,4 +80,41 @@
     </target>
     <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+        <j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/>
+        <j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>
+        <j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/>
+        <j2seproject1:property name="platform.javac.tmp" value="platforms.${platform.active}.javac"/>
+        <condition property="platform.javac" value="${platform.home}/bin/javac">
+            <equals arg1="${platform.javac.tmp}" arg2="$${platforms.${platform.active}.javac}"/>
+        </condition>
+        <property name="platform.javac" value="${platform.javac.tmp}"/>
+        <j2seproject1:property name="platform.java.tmp" value="platforms.${platform.active}.java"/>
+        <condition property="platform.java" value="${platform.home}/bin/java">
+            <equals arg1="${platform.java.tmp}" arg2="$${platforms.${platform.active}.java}"/>
+        </condition>
+        <property name="platform.java" value="${platform.java.tmp}"/>
+        <j2seproject1:property name="platform.javadoc.tmp" value="platforms.${platform.active}.javadoc"/>
+        <condition property="platform.javadoc" value="${platform.home}/bin/javadoc">
+            <equals arg1="${platform.javadoc.tmp}" arg2="$${platforms.${platform.active}.javadoc}"/>
+        </condition>
+        <property name="platform.javadoc" value="${platform.javadoc.tmp}"/>
+        <condition property="platform.invalid" value="true">
+            <or>
+                <contains string="${platform.javac}" substring="$${platforms."/>
+                <contains string="${platform.java}" substring="$${platforms."/>
+                <contains string="${platform.javadoc}" substring="$${platforms."/>
+            </or>
+        </condition>
+        <fail unless="platform.home">Must set platform.home</fail>
+        <fail unless="platform.bootcp">Must set platform.bootcp</fail>
+        <fail unless="platform.java">Must set platform.java</fail>
+        <fail unless="platform.javac">Must set platform.javac</fail>
+        <fail if="platform.invalid">
+ The J2SE Platform is not correctly set up.
+ Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. 
+ Either open the project in the IDE and setup the Platform with the same name or add it manually.
+ For example like this:
+     ant -Duser.properties.file=&lt;path_to_property_file&gt; jar (where you put the property "platforms.${platform.active}.home" in a .properties file)
+  or ant -Dplatforms.${platform.active}.home=&lt;path_to_JDK_home&gt; jar (where no properties file is used) 
+  </fail>
         <available file="${manifest.file}" property="manifest.available"/>
         <available file="${application.splash}" property="splashscreen.available"/>
@@ -199,5 +236,4 @@
             <length length="0" string="${endorsed.classpath}" when="greater"/>
         </condition>
-        <property name="javac.fork" value="false"/>
         <property name="jar.index" value="false"/>
         <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
@@ -245,5 +281,5 @@
                 <mkdir dir="${empty.dir}"/>
                 <mkdir dir="@{apgeneratedsrcdir}"/>
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
                     <src>
                         <dirset dir="@{gensrcdir}" erroronmissingdir="false">
@@ -284,5 +320,5 @@
                 <property location="${build.dir}/empty" name="empty.dir"/>
                 <mkdir dir="${empty.dir}"/>
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
                     <src>
                         <dirset dir="@{gensrcdir}" erroronmissingdir="false">
@@ -335,5 +371,5 @@
             <attribute default="**" name="testincludes"/>
             <sequential>
-                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">
                     <batchtest todir="${build.test.results.dir}">
                         <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
@@ -366,4 +402,7 @@
                         <path path="@{classpath}"/>
                     </classpath>
+                    <bootclasspath>
+                        <path path="${platform.bootcp}"/>
+                    </bootclasspath>
                 </nbjpdastart>
             </sequential>
@@ -381,5 +420,7 @@
     </target>
     <target name="-init-debug-args">
-        <property name="version-output" value="java version &quot;${ant.java.version}"/>
+        <exec executable="${platform.java}" outputproperty="version-output">
+            <arg value="-version"/>
+        </exec>
         <condition property="have-jdk-older-than-1.4">
             <or>
@@ -406,5 +447,5 @@
             <element name="customize" optional="true"/>
             <sequential>
-                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">
                     <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                     <jvmarg line="${debug-args-line}"/>
@@ -431,5 +472,5 @@
             <element name="customize" optional="true"/>
             <sequential>
-                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">
                     <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                     <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
@@ -613,5 +654,5 @@
             <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
         </pathconvert>
-        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+        <echo>${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
     </target>
     <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available+splashscreen.available" name="-do-jar-with-libraries-and-splashscreen">
@@ -627,5 +668,5 @@
         <echo>To run this application from the command line without Ant, try:</echo>
         <property location="${dist.jar}" name="dist.jar.resolved"/>
-        <echo>java -jar "${dist.jar.resolved}"</echo>
+        <echo>${platform.java} -jar "${dist.jar.resolved}"</echo>
     </target>
     <target depends="init,compile,-pre-pre-jar,-pre-jar,-init-macrodef-copylibs" if="do.archive+manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries" unless="splashscreen.available">
@@ -637,5 +678,5 @@
         <echo>To run this application from the command line without Ant, try:</echo>
         <property location="${dist.jar}" name="dist.jar.resolved"/>
-        <echo>java -jar "${dist.jar.resolved}"</echo>
+        <echo>${platform.java} -jar "${dist.jar.resolved}"</echo>
     </target>
     <target name="-post-jar">
@@ -715,5 +756,5 @@
     <target depends="init" if="have.sources" name="-javadoc-build">
         <mkdir dir="${dist.javadoc.dir}"/>
-        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" executable="${platform.javadoc}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
             <classpath>
                 <path path="${javac.classpath}"/>
Index: /trunk/fmgVen/nbproject/genfiles.properties
===================================================================
--- /trunk/fmgVen/nbproject/genfiles.properties	(revision 25)
+++ /trunk/fmgVen/nbproject/genfiles.properties	(revision 26)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=6b84a8b1
+build.xml.data.CRC32=31e5c25b
 build.xml.script.CRC32=a9b2e5a3
 build.xml.stylesheet.CRC32=28e38971@1.38.1.45
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=6b84a8b1
-nbproject/build-impl.xml.script.CRC32=494c2ca4
+nbproject/build-impl.xml.data.CRC32=31e5c25b
+nbproject/build-impl.xml.script.CRC32=68c11675
 nbproject/build-impl.xml.stylesheet.CRC32=78c6a6ee@1.38.1.45
Index: /trunk/fmgVen/nbproject/project.properties
===================================================================
--- /trunk/fmgVen/nbproject/project.properties	(revision 25)
+++ /trunk/fmgVen/nbproject/project.properties	(revision 26)
@@ -30,5 +30,5 @@
     ${libs.Ven.classpath}
 # Space-separated list of extra javac options
-javac.compilerargs=-Xlint:deprecation
+javac.compilerargs=
 javac.deprecation=false
 javac.processorpath=\
@@ -53,5 +53,5 @@
 javadoc.windowtitle=
 meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
+platform.active=JDK_1.4
 run.classpath=\
     ${javac.classpath}:\
Index: /trunk/fmgVen/nbproject/project.xml
===================================================================
--- /trunk/fmgVen/nbproject/project.xml	(revision 25)
+++ /trunk/fmgVen/nbproject/project.xml	(revision 26)
@@ -6,4 +6,5 @@
             <name>fmgVen</name>
             <minimum-ant-version>1.6.5</minimum-ant-version>
+            <explicit-platform explicit-source-supported="true"/>
             <source-roots>
                 <root id="src.dir"/>
Index: /trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java
===================================================================
--- /trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java	(revision 25)
+++ /trunk/fmgVen/src/com/fmguler/ven/QueryGenerator.java	(revision 26)
@@ -18,6 +18,11 @@
 package com.fmguler.ven;
 
+import com.fmguler.ven.util.Convert;
+import java.beans.PropertyDescriptor;
+import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
 
 /**
@@ -27,7 +32,15 @@
 public class QueryGenerator {
     private Set domainPackages;
+    private Set dbClasses;
 
     public QueryGenerator() {
         domainPackages = new HashSet();
+        dbClasses = new HashSet();
+        //the predefined database classes;
+        this.dbClasses.add(Integer.class);
+        this.dbClasses.add(String.class);
+        this.dbClasses.add(Date.class);
+        this.dbClasses.add(Double.class);
+        this.dbClasses.add(Boolean.class);
     }
 
@@ -40,9 +53,77 @@
     }
 
-    public String generateUpdateQuery() {
-        return null;
+    public String generateInsertQuery(Object object) throws VenException {
+        BeanWrapper wr = new BeanWrapperImpl(object);
+        String objectName = Convert.toSimpleName(object.getClass().getName());
+        String tableName = Convert.toDB(objectName);
+        PropertyDescriptor[] pdArr = wr.getPropertyDescriptors();
+
+        //generate insert query
+        StringBuffer query = new StringBuffer("insert into " + tableName + "(");
+        StringBuffer values = new StringBuffer(" values(");
+        for (int i = 0; i < pdArr.length; i++) {
+            Class fieldClass = pdArr[i].getPropertyType(); //field class
+            String columnName = Convert.toDB(pdArr[i].getName()); //column name
+            String fieldName = pdArr[i].getName(); //field name
+            //if (fieldName.equals("id")) continue; //remove if it does not break the sequence
+            if (dbClasses.contains(fieldClass)) { //direct database field (Integer,String,Date, etc)
+                query.append(columnName);
+                query.append(",");
+                values.append(":").append(fieldName);
+                values.append(",");
+            }
+            if (fieldClass.getPackage() != null && domainPackages.contains(fieldClass.getPackage().getName())) { //object
+                query.append(Convert.toDB(fieldName)).append("_id");
+                query.append(",");
+                values.append(":").append(fieldName).append(".id");
+                values.append(",");
+            }
+        }
+        query.deleteCharAt(query.length() - 1);
+        query.append(")");
+        values.deleteCharAt(values.length() - 1);
+        values.append(");");
+        query.append(values);
+
+        return query.toString();
     }
 
-    //SETTERS-------------------------------------------------------------------
+    /**
+     * Generates insert/update query
+     * @return the insert update SQL query
+     */
+    public String generateUpdateQuery(Object object) throws VenException {
+        BeanWrapper wr = new BeanWrapperImpl(object);
+        String objectName = Convert.toSimpleName(object.getClass().getName());
+        String tableName = Convert.toDB(objectName);
+        PropertyDescriptor[] pdArr = wr.getPropertyDescriptors();
+
+        StringBuffer query = new StringBuffer("update " + tableName + " set ");
+        for (int i = 0; i < pdArr.length; i++) {
+            Class fieldClass = pdArr[i].getPropertyType(); //field class
+            String columnName = Convert.toDB(pdArr[i].getName()); //column name
+            String fieldName = pdArr[i].getName(); //field name
+            if (dbClasses.contains(fieldClass)) { //direct database field (Integer,String,Date, etc)
+                query.append(columnName).append("=:").append(fieldName);
+                query.append(",");
+            }
+            if (fieldClass.getPackage() != null && domainPackages.contains(fieldClass.getPackage().getName())) { //object
+                query.append(columnName).append("_id=:").append(fieldName).append(".id");
+                query.append(",");
+            }
+        }
+        query.deleteCharAt(query.length() - 1);
+        query.append(" where id = :id ;"); //TODO: remove the last comma
+        return query.toString();
+    }
+
+    public String generateSequenceQuery(Object object) throws VenException {
+        String objectName = Convert.toSimpleName(object.getClass().getName());
+        String tableName = Convert.toDB(objectName);
+        return "select nextval('" + tableName + "_id_seq');";
+    }
+
+    //--------------------------------------------------------------------------
+    //SETTERS
     public void addDomainPackage(String domainPackage) {
         domainPackages.add(domainPackage);
Index: /trunk/fmgVen/src/com/fmguler/ven/Ven.java
===================================================================
--- /trunk/fmgVen/src/com/fmguler/ven/Ven.java	(revision 25)
+++ /trunk/fmgVen/src/com/fmguler/ven/Ven.java	(revision 26)
@@ -18,7 +18,12 @@
 package com.fmguler.ven;
 
+import java.util.HashMap;
 import java.util.List;
 import javax.sql.DataSource;
+import org.springframework.beans.BeanWrapper;
+import org.springframework.beans.BeanWrapperImpl;
+import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.springframework.jdbc.core.namedparam.SqlParameterSource;
 
 /**
@@ -44,15 +49,56 @@
     }
 
-    public Object get(int no, Class objectClass) {
+    public Object get(int id, Class objectClass) {
         return null;
     }
 
+    /**
+     * Save the object. If it has a "id" property it will be updated.
+     * It will be inserted otherwise.
+     * <p>
+     * The object will be saved to a table with the same name as the object,
+     * The fields of object will be mapped to the table fields.
+     * 
+     * @param object the object to be saved
+     */
     public void save(Object object) {
+        String query = null;
+
+        if (isObjectNew(object)) {
+            //if this is a new object assign a new id first
+            generateId(object);
+            query = generator.generateInsertQuery(object);
+        } else {
+            query = generator.generateUpdateQuery(object);
+        }
+
+        //execute the insert/update query
+        SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(object);
+        template.update(query, parameterSource);
     }
 
-    public void delete(int no, Class objectClass) {
+    public void delete(int id, Class objectClass) {
     }
 
-    //SETTERS-------------------------------------------------------------------
+    //--------------------------------------------------------------------------
+    //PRIVATE METHODS
+    //return true if the object id is zero or null false otherwise
+    private boolean isObjectNew(Object object) throws VenException {
+        BeanWrapper beanWrapper = new BeanWrapperImpl(object);
+        Object objectId = beanWrapper.getPropertyValue("id"); 
+        if (objectId == null) return true;
+        if (!(objectId instanceof Integer)) throw new VenException(VenException.EC_GENERATOR_OBJECT_ID_TYPE_INVALID);
+        return ((Integer)objectId).intValue() == 0;
+    }
+
+    //set new object id
+    private void generateId(Object object) {
+        Integer newObjectId = new Integer(template.queryForInt(generator.generateSequenceQuery(object), new HashMap()));
+        BeanWrapper beanWrapper = new BeanWrapperImpl(object);
+        beanWrapper.setPropertyValue("id", newObjectId);
+    }
+
+    //--------------------------------------------------------------------------
+    //SETTERS
     public void setDataSource(DataSource dataSource) {
         if (dataSource == null) throw new RuntimeException("fmgVen - DataSource cannot be null");
Index: /trunk/fmgVen/src/com/fmguler/ven/VenException.java
===================================================================
--- /trunk/fmgVen/src/com/fmguler/ven/VenException.java	(revision 26)
+++ /trunk/fmgVen/src/com/fmguler/ven/VenException.java	(revision 26)
@@ -0,0 +1,74 @@
+/*
+ *  fmgVen - A Convention over Configuration Java ORM Tool
+ *  Copyright 2010 Fatih Mehmet Güler
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+package com.fmguler.ven;
+
+/**
+ * All kinds of exceptions in Ven operations.
+ * @author Fatih Mehmet Güler
+ */
+public class VenException extends RuntimeException {
+    private String errorCode;
+    private String errorParam;
+    //Error codes
+    //"Invalid object, \"id\" property must be of integer type"
+    public static final String EC_GENERATOR_OBJECT_ID_TYPE_INVALID = "ec-generator-object-id-type-invalid";
+
+    /**
+     * Init VenException with an error code
+     * @param errorCode the error code
+     */
+    public VenException(String errorCode) {
+        this.errorCode = errorCode;
+    }
+
+    /**
+     * Init VenException with an error code and an error parameter
+     * @param errorCode the error code
+     * @param errorParam the error param
+     */
+    public VenException(String errorCode, String errorParam) {
+        this.errorCode = errorCode;
+        this.errorParam = errorParam;
+    }
+
+    /**
+     * Init VenException with an error code, error parameter and the cause of the exception
+     * @param errorCode the error code
+     * @param errorParam the error parameter
+     * @param cause the cause of the exception
+     */
+    public VenException(String errorCode, String errorParam, Throwable cause) {
+        super(cause);
+        this.errorCode = errorCode;
+        this.errorParam = errorParam;
+    }
+
+    /**
+     * @return the error code of the exception
+     */
+    public String getErrorCode() {
+        return errorCode;
+    }
+
+    /**
+     * @return the error parameter of the exception, which can contain details about the error
+     */
+    public String getErrorParam() {
+        return errorParam;
+    }
+}
Index: /trunk/fmgVen/src/com/fmguler/ven/util/Convert.java
===================================================================
--- /trunk/fmgVen/src/com/fmguler/ven/util/Convert.java	(revision 26)
+++ /trunk/fmgVen/src/com/fmguler/ven/util/Convert.java	(revision 26)
@@ -0,0 +1,61 @@
+/*
+ *  fmgVen - A Convention over Configuration Java ORM Tool
+ *  Copyright 2010 Fatih Mehmet Güler
+ * 
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ * 
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *  under the License.
+ */
+package com.fmguler.ven.util;
+
+import java.util.Locale;
+
+/**
+ * Utility class for conversions from database naming convention to java, and vice versa
+ * @author Fatih Mehmet Güler
+ */
+public class Convert {
+    /**
+     * Convert from java camelCase case to database naming convention
+     * <p>
+     * For example, if the name of the given name is SomeDomainObject
+     * it will be converted to some_domain_object
+     *
+     * @param camelCase the camelCase case name
+     * @return database style name
+     */
+    public static String toDB(String camelCase) {
+        if (camelCase.equals("")) return "";
+        StringBuffer result = new StringBuffer();
+        result.append(camelCase.substring(0, 1).toLowerCase(Locale.ENGLISH));
+        for (int i = 1; i < camelCase.length(); i++) {
+            String sCamel = camelCase.substring(i, i + 1);
+            String sLower = sCamel.toLowerCase(Locale.ENGLISH);
+            if (!sCamel.equals(sLower)) {
+                result.append("_").append(sLower);
+            } else result.append(sCamel);
+        }
+        return result.toString();
+    }
+
+    /**
+     * Convert the full package name to simple name.
+     * For Java 1.4 compatibility of Class.getSimpleName()
+     * @param fullName Class.getName()
+     * @return the part after the last .
+     */
+    public static String toSimpleName(String fullName) {
+        int i = fullName.lastIndexOf(".");
+        if (i < 0) return fullName;
+        return fullName.substring(i + 1);
+    }
+}
Index: /trunk/fmgVen/src/net/fmg/ven/Olcut.java
===================================================================
--- /trunk/fmgVen/src/net/fmg/ven/Olcut.java	(revision 25)
+++ /trunk/fmgVen/src/net/fmg/ven/Olcut.java	(revision 26)
@@ -7,5 +7,4 @@
  * Ven - Ayar Yerine Gelenek veritabanı erişim nesnesi
  */
-
 package net.fmg.ven;
 
@@ -25,5 +24,5 @@
     private Map parametreler;
     private Set baglaclar;
-    
+
     /** 
      * Yeni ölçüt
@@ -32,81 +31,80 @@
         this.metin = "";
         this.parametreler = new HashMap();
-        this.baglaclar =  new HashSet();
+        this.baglaclar = new HashSet();
         //{"and", "or", "=", "<>", "<", ">"}
     }
-    
+
     /**
      * YAPILMADI
      */
-    public Olcut ekle(Olcut olcut){        
+    public Olcut ekle(Olcut olcut) {
         return null;
     }
-    
+
     /**
      * YAPILMADI
      */
-    public Olcut ekle(List olcutler){        
+    public Olcut ekle(List olcutler) {
         return null;
     }
-    
+
     /**
      * YAPILMADI
      */
-    public Olcut ve(){
+    public Olcut ve() {
         return null;
     }
-    
+
     /**
      * koşul ekle
      */
-    public Olcut ekle(String kosul){
-        this.metin +=" "+kosul;
+    public Olcut ekle(String kosul) {
+        this.metin += " " + kosul;
         return this;
     }
-    
+
     /**
      * koşullarda kullanılan parametreleri ekle
      */
-    public Olcut ekle(String parametre, Object nesne){
-        this.parametreler.put(parametre,nesne);
+    public Olcut ekle(String parametre, Object nesne) {
+        this.parametreler.put(parametre, nesne);
         return this;
     }
-    
+
     /**
      * koşullarda kullanılan parametreleri tümden ekle
      */
-    public Olcut ekle(Map parametreler){
+    public Olcut ekle(Map parametreler) {
         this.parametreler.putAll(parametreler);
         return this;
     }
-    
-    public String olcutleriAl(){
+
+    public String olcutleriAl() {
         //((1=1) and ((1=1) and (musteri_numuneler_numune_sahibi.rapor_tarihi is null) and (musteri.no = 4)))
         //Musteri.numuneler.deneyler.deneyTip.ad like :p1
         String sonuc = "";
-        metin = metin.replace("(","( ");
-        metin = metin.replace(")"," )");
+        metin = metin.replaceAll("\\(", "\\( ");
+        metin = metin.replaceAll("\\)", " \\)");
         String[] parcalar = metin.split(" ");
         for (int i = 0; i < parcalar.length; i++) {
-            if (!parcalar[i].startsWith(":") && parcalar[i].contains(".")){
-                int sonNokta = parcalar[i].lastIndexOf('.');                
+            if (!parcalar[i].startsWith(":") && parcalar[i].indexOf(".") >= 0) {
+                int sonNokta = parcalar[i].lastIndexOf('.');
                 sonuc += " ";
-                int u = parcalar[i].length();                
-                sonuc +=Cevir.vt(parcalar[i].substring(0,sonNokta).replace('.','_'));
-                sonuc +=Cevir.vt(parcalar[i].substring(sonNokta,u));
-            }else{
-                sonuc += " "+parcalar[i];
+                int u = parcalar[i].length();
+                sonuc += Cevir.vt(parcalar[i].substring(0, sonNokta).replace('.', '_'));
+                sonuc += Cevir.vt(parcalar[i].substring(sonNokta, u));
+            } else {
+                sonuc += " " + parcalar[i];
             }
         }
         return sonuc;
     }
-    
-    public Map parametreler(){
+
+    public Map parametreler() {
         return this.parametreler;
     }
 
     public String toString() {
-        return olcutleriAl()+" "+this.parametreler;
+        return olcutleriAl() + " " + this.parametreler;
     }
-    
 }
Index: /trunk/fmgVen/src/net/fmg/ven/SorguEslestirici.java
===================================================================
--- /trunk/fmgVen/src/net/fmg/ven/SorguEslestirici.java	(revision 25)
+++ /trunk/fmgVen/src/net/fmg/ven/SorguEslestirici.java	(revision 26)
@@ -57,5 +57,5 @@
         long t1 = System.currentTimeMillis();
         final List sonuclar = new LinkedList();
-        final String tabloAdi = Cevir.vt(nesneSinifi.getSimpleName());
+        final String tabloAdi = Cevir.vt(Cevir.isim(nesneSinifi.getName()));
         final Set sutunlar = new HashSet();
         
Index: /trunk/fmgVen/src/net/fmg/ven/SorguUretici.java
===================================================================
--- /trunk/fmgVen/src/net/fmg/ven/SorguUretici.java	(revision 25)
+++ /trunk/fmgVen/src/net/fmg/ven/SorguUretici.java	(revision 26)
@@ -59,5 +59,5 @@
             if (alanSinifi.getPackage()!=null && nesnePaketleri.contains(alanSinifi.getPackage().getName()) && baglarKapsar(baglar,nesneYolu+"."+alanAdi)){ //domain nesnesi 1-1 join
                 String bagTablosuDigerAd = tabloAdi+"_"+sutunAdi; // bağ tablosu için diğer ad, çünkü aynı isimde birden fazla bağ olabilir, karışmasın
-                String bagTablosu = Cevir.vt(alanSinifi.getSimpleName());//gerçek bağ tablosu
+                String bagTablosu = Cevir.vt(Cevir.isim(alanSinifi.getName()));//gerçek bağ tablosu
                 fromCumlesi.append(" left join "+bagTablosu+" "+bagTablosuDigerAd);
                 fromCumlesi.append(" on "+bagTablosuDigerAd+".no = "+tabloAdi+"."+sutunAdi+"_no");
@@ -67,5 +67,5 @@
                 Class cokluAlandakiNesneSinifi = (Class)wr.getPropertyValue(alanAdi+".nesneSinifi");
                 String bagTablosuDigerAd = tabloAdi+"_"+sutunAdi; // bağ tablosu için diğer ad, çünkü aynı isimde birden fazla bağ olabilir, karışmasın
-                String bagTablosu = Cevir.vt(cokluAlandakiNesneSinifi.getSimpleName());//gerçek bağ tablosu
+                String bagTablosu = Cevir.vt(Cevir.isim(cokluAlandakiNesneSinifi.getName()));//gerçek bağ tablosu
                 String bagAlani = Cevir.vt((String)wr.getPropertyValue(alanAdi+".bagAlani")); //YAP: bunu vermeden de varsayılan birşey yapsın
                 fromCumlesi.append(" left join "+bagTablosu+" "+bagTablosuDigerAd);
@@ -93,5 +93,5 @@
     public String secmeSorgusuUret(Set baglar, Class nesneSinifi){
         //long t1 = System.currentTimeMillis();
-        String nesneAdi = nesneSinifi.getSimpleName();
+        String nesneAdi = Cevir.isim(nesneSinifi.getName());
         String tabloAdi = Cevir.vt(nesneAdi);
         StringBuffer selectCumlesi = new StringBuffer("select ");
@@ -108,5 +108,5 @@
     public String saymaSorgusuUret(Set baglar, Class nesneSinifi){
         //long t1 = System.currentTimeMillis();
-        String nesneAdi = nesneSinifi.getSimpleName();
+        String nesneAdi = Cevir.isim(nesneSinifi.getName());
         String tabloAdi = Cevir.vt(nesneAdi);
         StringBuffer selectCumlesi = new StringBuffer();
@@ -123,5 +123,5 @@
     public String guncellemeSorgusuUret(Object nesne){
         BeanWrapper wr = new BeanWrapperImpl(nesne);
-        String nesneAdi = nesne.getClass().getSimpleName();
+        String nesneAdi = Cevir.isim(nesne.getClass().getName());
         String tabloAdi = Cevir.vt(nesneAdi);
         StringBuffer sorgu;
Index: /trunk/fmgVen/src/net/fmg/ven/Ven.java
===================================================================
--- /trunk/fmgVen/src/net/fmg/ven/Ven.java	(revision 25)
+++ /trunk/fmgVen/src/net/fmg/ven/Ven.java	(revision 26)
@@ -48,5 +48,5 @@
         Set baglar = new HashSet();
         kullanimlar.put(kullanimNo,baglar);
-        baglar.add(nesneSinifi.getSimpleName());
+        baglar.add(Cevir.isim(nesneSinifi.getName()));
         
         String sorgu = uretici.secmeSorgusuUret(baglar, nesneSinifi);
@@ -111,5 +111,5 @@
     public Object nesneAl(Class nesneSinifi, Integer no, Set baglar){
         String sorgu = uretici.secmeSorgusuUret(baglar, nesneSinifi);
-        Olcut olcut = new Olcut().ekle("and "+Cevir.vt(nesneSinifi.getSimpleName())+".no = :___no").ekle("___no",no);
+        Olcut olcut = new Olcut().ekle("and "+Cevir.vt(Cevir.isim(nesneSinifi.getName()))+".no = :___no").ekle("___no",no);
         sorgu += " where 1=1"+olcut.olcutleriAl();
         if(hataAyiklama) System.out.println("SQL: "+sorgu);
@@ -127,5 +127,5 @@
     public Object nesneAl(Class nesneSinifi, Integer no, Set baglar, Olcut olcut){
         String sorgu = uretici.secmeSorgusuUret(baglar, nesneSinifi);
-        sorgu += " where 1=1 and "+Cevir.vt(nesneSinifi.getSimpleName())+".no = :___no "+olcut.olcutleriAl(); //No diğer ölçütlerden önce gelmeli order-limit için
+        sorgu += " where 1=1 and "+Cevir.vt(Cevir.isim(nesneSinifi.getName()))+".no = :___no "+olcut.olcutleriAl(); //No diğer ölçütlerden önce gelmeli order-limit için
         olcut.ekle("___no",no);
         if(hataAyiklama) System.out.println("SQL: "+sorgu);
@@ -145,10 +145,10 @@
         BeanWrapper wr = new BeanWrapperImpl(nesne);
         if(wr.getPropertyValue("no")==null){            
-            wr.setPropertyValue("no",new Integer(sablon.queryForInt("select currval('"+Cevir.vt(nesne.getClass().getSimpleName())+"_no')", new HashMap())));
+            wr.setPropertyValue("no",new Integer(sablon.queryForInt("select currval('"+Cevir.vt(Cevir.isim(nesne.getClass().getName()))+"_no')", new HashMap())));
         }
     }
     
     public void nesneSil(Integer no, Class nesneSinifi){
-        String sorgu = "delete from "+Cevir.vt(nesneSinifi.getSimpleName())+" where no = :no ;";
+        String sorgu = "delete from "+Cevir.vt(Cevir.isim(nesneSinifi.getName()))+" where no = :no ;";
         Map parametreler = new HashMap(2);
         parametreler.put("no",no);
Index: /trunk/fmgVen/src/net/fmg/ven/arac/Cevir.java
===================================================================
--- /trunk/fmgVen/src/net/fmg/ven/arac/Cevir.java	(revision 25)
+++ /trunk/fmgVen/src/net/fmg/ven/arac/Cevir.java	(revision 26)
@@ -35,4 +35,10 @@
         return sonuc.toString();
     }
+
+    public static String isim(String isim) {
+        int i = isim.lastIndexOf(".");
+        if (i < 0) return isim;
+        return isim.substring(i + 1);
+    }
     
 }
Index: /trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java
===================================================================
--- /trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java	(revision 25)
+++ /trunk/fmgVen/test/com/fmguler/ven/sample/Sample.java	(revision 26)
@@ -40,6 +40,6 @@
     public static void main(String[] args) {
         buildDatabase();
-        testGet();
-        //rollbackDatabase();
+        testSave();
+        rollbackDatabase();
     }
 
@@ -139,6 +139,5 @@
             Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(getDataSource().getConnection());
             Liquibase liquibase = new Liquibase("etc/test-db/test-db-changelog.xml", new FileSystemFileOpener(), database);
-            //liquibase.rollback(51, "");
-            liquibase.rollback("0", "");
+            liquibase.rollback("tag-single-table", "");
             Locale.setDefault(currLocale);
         } catch (SQLException ex) {
Index: /trunk/fmgVen/test/com/fmguler/ven/sample/domain/SomeDomainObject.java
===================================================================
--- /trunk/fmgVen/test/com/fmguler/ven/sample/domain/SomeDomainObject.java	(revision 25)
+++ /trunk/fmgVen/test/com/fmguler/ven/sample/domain/SomeDomainObject.java	(revision 26)
@@ -25,5 +25,5 @@
  */
 public class SomeDomainObject {
-    private int no;
+    private Integer id;
     private String name;
     private String description;
@@ -31,15 +31,15 @@
 
     /**
-     * @return the no
+     * @return the id
      */
-    public int getNo() {
-        return no;
+    public Integer getId() {
+        return id;
     }
 
     /**
-     * @param no the no to set
+     * @param id the id to set
      */
-    public void setNo(int no) {
-        this.no = no;
+    public void setId(Integer id) {
+        this.id = id;
     }
 
@@ -87,5 +87,5 @@
 
     public String toString() {
-        return no + " " + name + " " + description + " " + date;
+        return id + " " + name + " " + description + " " + date;
     }
 }
