Grey Line

Upcoming release of the ClearDataBuilder supports AUTOINCREMENTed property in the DataCollection items populated from databases based on autogenerated values like MSSqlServer/ Sybase identity, or Oracle’s sequence, and so forth. All you need to do is add identity parameter to the CDB annotation

    /**
    * @daoflex:sql
    *  sql=select * from employee
    *  transferType=EmployeeDTO[]
    *  keyColumns=id
    *  identity=id
    *  updateTable=employee
    */
 
    public abstract List getEmployees();

and allow server changes to reflect back on the DataCollection:

dataCollection.roundTripSync = true;



Sample Use Case

Imagine a MSSqlServer table “employee”, with IDENTITY column named “id”. Here is the abstract Java class you would need to write:

package com.farata.test;
import java.util.List;
/**
 * @daoflex:webservice
 *   pool=jdbc/test
 */
public abstract class Employee
{
		/**
		* @daoflex:sql
		*  sql=select * from employee
		*  transferType=EmployeeDTO[]
		*  keyColumns=id
		*  identity=id
		*  updateTable=employee
		*/
 
		public abstract List getEmployees();
}

A Clean CDB build, as usual, will generate concrete implementation of the Assembler, already registered for Flex remoting, ActionScript DTO classes matching the Java counterparties and so forth.

Importantly, the specifics of the identity annotation will force CDB to enquire the value of the autogenerated id column along with the execution of the executeUpdate() and send the modified record back to the Flex client.


Two-Way Syncronization: DataCollection – BlazeDS Assembler

You have to allow the echo of the server-side changes back to the client. You have two options.

  • dataCollection.roundTripSync=true; – to allow Flex process the immediate result of “your own” dataCollection.sync() call
  • dataCollection.autoSyncEnabled=true; – to allow Flex consume server-born asyncronous messages with changes inflicted by other clients. This option requires design-time autoSyncEnabled=true CDB annotation as well.

    Here is the explanation. During the sync() operation changes originated in the DataCollection are remoted to method(s) of a server Assembler as Array of com.farata.remoting.ChangeObject elements. All of these methods are also returning the Array of changes, including, if any, changes originated by the server. The value of the roundTripSync determines whether these changes effect DataCollection when the synchronization is complete. Default value is false


    Pluggable Identity Factory

    No two databases are born equal. The default setting of the CDB is to handle identity compliant with MSSqlServer, i.e. to use SELECT SCOPE_IDENTITY() as the cleanest possible computation of the identity. If you are running Sybase, you would have to modify the default daoflex.identity.factory in the daoflex-build/daoflex-build-custom.properties:

    daoflex.identity.factory=com.farata.daoflex.SybaseIdentityFactory

    It gets worse if you are an Oracle sequence guy. Plugging a foo.bar.OracleIdentityFactory class that has to implement com.farata.daoflex.IIdentityFactory interface is not any different from the Sybase, but CDB does not know upfront which sequence to use. So roll up your sleeves and create something like following:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    
    package foo.bar;
     
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.Map;
     
    import com.farata.daoflex.DAOException;
    import com.farata.daoflex.IIdentityFactory;
     
    public class OracleIdentityFactory implements IIdentityFactory {
    	public long getIdentity(Map<String, Object> properties) {
    		long identity = 0;
    		PreparedStatement stmt = null;
    		ResultSet rs = null;
    		try {
     
    			Connection conn = (Connection) properties.get(CONNECTION);
    			String table = (String) properties.get(TABLE);
    			String sequenceName="UNKNOWN_SEQUENCE";  
    			// Your custom logic to determine the sequence give the table goes here		
    			if (table==table) 
    			     sequenceName = "MY_SEQUENCE";			
    			stmt = conn.prepareStatement("SELECT " + sequenceName + ".NEXTVAL AS identity FROM DUAL");
    			rs = stmt.executeQuery();
    			while( rs.next() ) {
    				identity = rs.getLong("identity");
    			}
    			return identity;
    		} catch (Throwable te) {
    			te.printStackTrace();
    			throw new DAOException("Failed creating identity", te);
    		}
    		finally {
    			try {rs.close(); rs = null;} catch (Exception e){}
    			try {stmt.close(); stmt = null;} catch (Exception e){}
    		}
    	}
    }

    Victor Rasputnis

  • Comments are closed.

    canada online pharmacy propecia
    free cialis
    buy cialis without rx
    cheap cialis
    viagra quick delivery
    levitra overnight shipping
    best price cialis without perscription
    hydrochlorothiazide cialis
    50mg viagra
    cialis discount prices
    best price cialis
    canada levitra
    online viagra levitra cialis
    cialis pills for sale
    indian cialis
    cialis free samples
    when will viagra be generic?
    buy cheap viagra online uk
    order generic viagra canada
    where can i get cialis
    generic viagra online pharmacy
    cheap online propecia
    propecia from canada
    best price for generic viagra
    where buy viagra
    cialis 5 mg
    viagra off internet
    alaska viagra doctors
    buy viagra online without a prescription
    viagra onlines
    propecia sales canadian
    cialis ottawa pharmacy
    cheapest viagra online
    online ordering propecia
    buy cheap uk viagra
    overnight viagra
    viagra online buy
    buy propecia 5mg
    online order viagra overnight delivery
    how to buy viagra in canada
    propecia discount
    cialis daily canada
    canada propecia prescription
    vardenafil:
    cialis next day delivery
    order viagra in canada
    cialis free delivery
    uk cialis sales
    buying generic propecia
    canada viagra
    levitra without prescription
    generic viagra australia
    cheap cialis from india
    buy generic cialis online
    online presription for viagra
    best viagra and popular in uk

    real viagra without prescription
    levitra online without prescription
    liquid cialis for sale
    buy generic cialis online from canada
    viagra express delivery
    soft gel viagra
    buy cialis pill
    canadian generic cialis
    tablet viagra
    100 mg cialis
    buy cheapest cialis
    propecia for sale online
    overnight propecia
    viagra price
    get cialis online
    buy cheap generic cialis
    viagra replacement
    viagra online in canada
    order cialis from canada
    prescription needed for cialis
    menu:
    50mg viagra
    viagra for sale online in the uk
    cialis canada on line
    viagra mail order usa
    cialis viagra
    viagra 100 mg
    cialis for less 20 mg
    levitra viagra online
    find cheap viagra online
    online viagra au
    online generic cialis 100 mg
    online pharmacy propecia
    pfizer viagra no prescription
    buy propecia online cheap pharmacy
    to buy viagra online
    propecia
    viagra doses
    i want free viagra
    buy real viagra online no prescription
    viagra for woman
    brand viagra professional
    sildenafil viagra
    cialis now
    viagra for less
    lowest price for viagra from canada
    where to buy cialis cheap
    viagra online in canada
    canadian healthcare cialis
    cialis kanada
    cheapest levitra uk
    cheapest viagra in uk
    no prescription viagra canada
    canadian pharmacy cialis no rx
    cheapest prices on propecia
    viagra samples
    cheap discount cialis
    viagra tablet weight
    low price viagra
    viagra canadian pharmacy support
    cialis us drug stores
    generic cialis next day delivery
    viagra canada cheapest
    buy propecia online
    generic propecia canada
    find cialis no prescription required
    propecia cialis viagra
    cialis strenght mg
    lowest-price propecia costs us
    discount cialis levitra viagra
    buy viagra for women
    real cialis online
    drugstore best buy generic cialisbuy generic cialis
    generic viagra canadian pharmacy
    cialis testimonial
    propecia generic
    viagra how much
    buy propecia no prescription
    find viagra without prescription
    buy generic cialis online
    no rx viagra
    cialis free delivery
    viagra from uk
    cheap canadian viagra
    buy generic cialis
    cheap cialis pills
    levitra 10 mg without prescriptions
    viagra pfizer canada
    cheap viagra for sale
    cheap cialis online canada
    viagra echeck
    cheap cialis online no prescription
    propecia orders
    cialis without prescription in canada
    low cost canadian viagra
    viagra/cialis sales
    buy cialis without prescription
    generic propecia for sale
    cheap viagra canada
    can i buy viagra in canada
    nizagara viagra online
    viagra mail order
    www.cialis.com
    viagra sales online
    viagra in china
    canadian pharmacy viagra cheap
    ordering viagra online
    cialis canadian cost
    buy viagra online without prescription
    viagra with no prescription in britain
    find viagra no prescription required
    cialis daily canada
    cheap brand name cialis
    vardenafil generic
    buy propecia without a prescription
    the best price of viagra
    try cialis for free
    order cialis in canada
    usa cialis women
    generic cialis sales
    viagra sale
    sale of viagra tablets
    womens viagra no prescription
    di scount 50 mg viagra
    buy cialis online australia
    cialis online australia
    real viagra without a prescription
    buy cheapest viagra online
    cialis canadian online pharmacy
    sale viagra
    alternative for viagra
    prescription for propecia
    buying cheap cialis
    viagra order
    viagra com
    purchase cialis next day delivery
    online viagra levitra cialis
    professional cialis online
    combine cialis and levitra
    prices for propecia
    real viagra to buy
    sildenafil
    levitra for sale
    cheap order prescription propecia