大家好日子,我的架构问题与我设计域类的方式有关。
我有一个名为 TxnBatch 的父域类,它与Transactions类有一对多关系,还有另外两个子类 ProcessorTxnBatch 和 TamsTerminalTxnBatch 扩展 TxnBatch 类
逻辑是,当执行事务时,我首先将其添加到 processorTxnBatch.addToTransactions(事务),处理完事务后,我将其添加到终端批处理 tamsTerminalTxnBatch.addToTransactions(transaction)这是另一个子类
现在的问题是,当我将同一个交易添加到另一个批次的交易时,它会从之前的批次中删除交易我将其添加到。
父类
package com.itex.cipg
class TxnBatch implements Serializable{
static final String OPEN = "OPEN"
static final String CLOSED = "CLOSED"
/**
*The Batch number of this Transaction
**Set when the Batch is created
**/
String batchNo = "0"
/**
*The Batch Status of the transaction
**/
String batchStatus = OPEN
/**
*The Time this batch was started
**/
Date startTime
/**
*The Time this batch was Closed
**/
Date lastUpdated
/**
*The Time this batch was Closed
**/
Date closeTime
/**
*The NextSequence Number of this Batch
**/
Integer seqNo = 1
//Attributes Updated During a payService.updateBatch() Function call in payService
/**
* The Total Amount of All Transactions
*/
double allTransactionsSum = 0
/**
* The Total Amount Charged for the Approved Transactions
*/
double approvedTransactionsCharge = 0
/**
* The Total Amount of Approved Transactions
*/
double approvedTransactionsSum = 0
/**
* The Total Amount of Declined Transactions
*/
double declinedTransactionsSum = 0
/**
* The Total Amount of CANCELED Transactions
*/
double canceledTransactionsSum = 0
/**
* The Total Amount of CANCELED Transactions
*/
double errorTransactionsSum = 0
/**
* The Total number of ALL Transactions
*/
int allTransactionsCount = 0
/**
* The Total number of Approved Transactions
*/
int approvedTransactionsCount= 0
/**
* The Total number of declined Transactions
*/
int declinedTransactionsCount = 0
/**
* The Total number of canceled Transactions
*/
int canceledTransactionsCount = 0
/**
*The Total Sum of Unprocessed Transactions
*/
int unProcessedTransactionsSum = 0
/**
*The Total number of Unprocessed Transactions
**/
int unProcessedTransactionsCount = 0
/**
* The Total number of canceled Transactions
*/
int errorTransactionsCount = 0
/**
*The manimun batch Number to reach before closing this Batch
**/
int maxBatchNoLimit = 100
static hasMany = [transactions: Transaction]
/**
*The result of this batch
*as gotten from TAMS when
*the batch is closed
**/
String result
//Implements the Constraints of this Object
static constraints = {
batchStatus()
batchNo(blank:false)
seqNo()
allTransactionsCount()
unProcessedTransactionsSum()
unProcessedTransactionsCount()
allTransactionsSum(display:true)
approvedTransactionsCount()
approvedTransactionsSum()
canceledTransactionsCount(display:true)
canceledTransactionsSum()
errorTransactionsCount(display:true)
errorTransactionsSum(display:true)
declinedTransactionsCount(display:true)
declinedTransactionsSum(display:true)
closeTime(nullable:true)
result(nullable:true)
}
String toString()
{
return batchStatus + "-" + batchNo + ":" + seqNo
}
}
第一个儿童班
package com.itex.cipg
class ProcessorTxnBatch extends TxnBatch implements Serializable{
/**
*The Server Processor of the Transaction Batch
*
**/
Server server
}
第二个孩子班
package com.itex.cipg
class TamsTerminalTxnBatch extends TxnBatch implements Serializable{
/**
*The TAMS Terminal this batch belongs TO
**/
TamsTerminal terminal
}
我想要将事务添加到 TamsTerminalTxnBatch 以及 ProcessorTxnBatch 请注意static hasMany = [transactions:transaction]
我做完之后
def transaction = new Transaction //arbitrarily creating a Transaction
processorTxnBatch.addToTransactions(transaction)
assert processorTxnBatch.transactions.size() = 1 //true
tamsTerminalTxnBatch.addToTransactions(transaction)
assert tamsTerminalTxnBatch.transactions.size() = 1 //true
assert processorTxnBatch.transactions.size() = 0 //true
我不知道为什么..........请帮助我
虽然它们存放在同一张桌子上..........谢谢