Question

I have the following problem. I can set the transaction state to be either "start, end or ongoing". I set this, then serialise my Transaction object over to the server, who retrieves it. Works like a charm the first time (when the transaction is in start mode), but then when I resend the object, this time in "ongoing" mode, the server continues to see it in "start" mode. I've tested the code at the line before the serialization, and the line after the deserialization, and this is definitely where the problem is. Any help would be very much appreciated. The relevant code snippets are as follows:

serialization

        if ((query instanceof Transaction) && !(trx.getTransactionState()==Consts.trx_start)) System.out.println("Not start");
        oos.writeObject(query);
        oos.flush();

deserialization

    while (true) {
                Object statement = null;

                try {

                    statement = ois.readObject();
                    if ((statement instanceof Transaction) && !(((Transaction) statement).getTransactionState()==Consts.trx_start)) System.out.println("Not start 2");
                    handle_statement(statement, socket);
                } catch (IOException e) {

and the Transaction class:

    public class Transaction extends Statement{

/**
 * 
 */
private static final long serialVersionUID = -2284996855537430822L;
Statement statement_list;
int trx_state; 


/**
 * 
 */
public Transaction() {
    trx_state = Consts.trx_start;; 
}

/**
 * @param statement
 */
public void setStatement(Statement statement ) { 
    statement_list = statement; 
} 


public void setTransactionState(int state) {
        trx_state = state; 
}

public int getTransactionState() {
    return trx_state; 
}
/**
 * @return
 */
public Statement getStatement() {
    return statement_list;
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top