Amir Asyraf
Amir Asyraf

Reputation: 65

How to manipulate data object and save into Spring JPA in effective way?

  1. How can i save the manipulated object and other object after the "Transaction.builder" at below code in effective way ?

  2. Is there any other way for me to set all the object in the builder rather than only the object that i want to ?

(FYI: I have entity class with hundred of object)

 ProcessingError error = new ProcessingError("Tag Serial Num and Vehicle Plate Num are empty",
                        ResponseStatus.TAG_SERIAL_NUM_VEHICLE_PLATE_NUM_NOT_EXISTS,
                        TransactionRule.VALIDATE_TAG_SERIAL_NUM_VEHICLE_PLATE_NUM);

log.info("Transaction before builder :{}",transaction.getTcTransactionId());

   transaction = Transaction.builder()
        .responseStatus(error.getResponseStatus())
        .failedErrorRule(error.getTransactionRule())
        .build();

 log.info("Transaction after builder :{}",transaction.getTcTransactionId());

Ref full code at top:

log shown in the code before using builder:

Transaction before builder :"test01"

After Log shown in the code after using builder

Transaction after builder :null

Upvotes: 0

Views: 206

Answers (1)

Amir Asyraf
Amir Asyraf

Reputation: 65

Remove the builder and just straight set the variable such as in below code:

transaction.setResponseStatus(error.getResponseStatus());
transaction.setFailedErrorRule(error.getTransactionRule());

Upvotes: 1

Related Questions