Acumatica How to get the Cash Account Begin or Ending Balance? - api

When I select a Cash Account in the "Founds Transfers" (CA301000), GL Balance and Avaliable Balance Entries are updated.
Where these amounts come from? I mean, I need to query these field via GI but I cannot figure out the Table's name.
Any Clues?

GL Balance and Available Balance fields are part of the CATransfer DAC.
You won't find them in the CATransfer database table because they are calculated at runtime in CATransfer DAC as unbound fields using the FieldSelecting events of GLBalanceAttribute and CashBalanceAttribute.
You can find out the DAC and Data Field of a UI element by holding Ctl+Alt and clicking on that field.
For reference, here are the GLBalance attributes inCATransfer Dac:
#region InGLBalance
public abstract class inGLBalance : PX.Data.IBqlField
{
}
protected Decimal? _InGLBalance;
[PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXCury(typeof(CATransfer.inCuryID))]
[PXUIField(DisplayName = "GL Balance", Enabled = false)]
[GLBalance(typeof(CATransfer.inAccountID), null, typeof(CATransfer.inDate))]
public virtual Decimal? InGLBalance
{
get
{
return this._InGLBalance;
}
set
{
this._InGLBalance = value;
}
}
#endregion
#region OutGLBalance
public abstract class outGLBalance : PX.Data.IBqlField
{
}
protected Decimal? _OutGLBalance;
[PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXCury(typeof(CATransfer.outCuryID))]
[PXUIField(DisplayName = "GL Balance", Enabled = false)]
[GLBalance(typeof(CATransfer.outAccountID), null, typeof(CATransfer.outDate))]
public virtual Decimal? OutGLBalance
{
get
{
return this._OutGLBalance;
}
set
{
this._OutGLBalance = value;
}
}
#endregion
Here is the GLBalanceAttribute class FieldSelecting event where the value is calculated:
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
GLSetup gLSetup = PXSelect<GLSetup>.Select(sender.Graph);
decimal? result = 0m;
object CashAccountID = sender.GetValue(e.Row, _CashAccount);
object FinPeriodID = null;
if (string.IsNullOrEmpty(_FinPeriodID))
{
object FinDate = sender.GetValue(e.Row, _FinDate);
FinPeriod finPeriod = PXSelect<FinPeriod, Where<FinPeriod.startDate, LessEqual<Required<FinPeriod.startDate>>,
And<FinPeriod.endDate, Greater<Required<FinPeriod.endDate>>>>>.Select(sender.Graph, FinDate, FinDate);
if (finPeriod != null)
{
FinPeriodID = finPeriod.FinPeriodID;
}
}
else
{
FinPeriodID = sender.GetValue(e.Row, _FinPeriodID);
}
if (CashAccountID != null && FinPeriodID != null)
{
// clear glhistory cache for ReleasePayments longrun
sender.Graph.Caches<GLHistory>().ClearQueryCache();
sender.Graph.Caches<GLHistory>().Clear();
GLHistory gLHistory = PXSelectJoin<GLHistory,
InnerJoin<GLHistoryByPeriod,
On<GLHistoryByPeriod.accountID, Equal<GLHistory.accountID>,
And<GLHistoryByPeriod.branchID, Equal<GLHistory.branchID>,
And<GLHistoryByPeriod.ledgerID, Equal<GLHistory.ledgerID>,
And<GLHistoryByPeriod.subID, Equal<GLHistory.subID>,
And<GLHistoryByPeriod.lastActivityPeriod, Equal<GLHistory.finPeriodID>>>>>>,
InnerJoin<Branch,
On<Branch.branchID, Equal<GLHistory.branchID>,
And<Branch.ledgerID, Equal<GLHistory.ledgerID>>>,
InnerJoin<CashAccount,
On<GLHistoryByPeriod.branchID, Equal<CashAccount.branchID>,
And<GLHistoryByPeriod.accountID, Equal<CashAccount.accountID>,
And<GLHistoryByPeriod.subID, Equal<CashAccount.subID>>>>,
InnerJoin<Account,
On<GLHistoryByPeriod.accountID, Equal<Account.accountID>,
And<Match<Account, Current<AccessInfo.userName>>>>,
InnerJoin<Sub,
On<GLHistoryByPeriod.subID, Equal<Sub.subID>, And<Match<Sub, Current<AccessInfo.userName>>>>>>>>>,
Where<CashAccount.cashAccountID, Equal<Required<CashAccount.cashAccountID>>,
And<GLHistoryByPeriod.finPeriodID, Equal<Required<GLHistoryByPeriod.finPeriodID>>>
>>.Select(sender.Graph, CashAccountID, FinPeriodID);
if (gLHistory != null)
{
result = gLHistory.CuryFinYtdBalance;
}
}
e.ReturnValue = result;
e.Cancel = true;
}
}
Here are the CashBalance attributes of CATransfer Dac:
#region CashBalanceIn
public abstract class cashBalanceIn : PX.Data.IBqlField
{
}
protected Decimal? _CashBalanceIn;
[PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXCury(typeof(CATransfer.inCuryID))]
[PXUIField(DisplayName = "Available Balance", Enabled = false)]
[CashBalance(typeof(CATransfer.inAccountID))]
public virtual Decimal? CashBalanceIn
{
get
{
return this._CashBalanceIn;
}
set
{
this._CashBalanceIn = value;
}
}
#endregion
#region CashBalanceOut
public abstract class cashBalanceOut : PX.Data.IBqlField
{
}
protected Decimal? _CashBalanceOut;
[PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXCury(typeof(CATransfer.outCuryID))]
[PXUIField(DisplayName = "Available Balance", Enabled = false)]
[CashBalance(typeof(CATransfer.outAccountID))]
public virtual Decimal? CashBalanceOut
{
get
{
return this._CashBalanceOut;
}
set
{
this._CashBalanceOut = value;
}
}
#endregion
And the CashBalanceAttribute class FieldSelecting event where the value is calculated:
public virtual void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
{
CASetup caSetup = PXSelect<CASetup>.Select(sender.Graph);
decimal? result = 0m;
object CashAccountID = sender.GetValue(e.Row, _CashAccount);
CADailySummary caBalance = PXSelectGroupBy<CADailySummary,
Where<CADailySummary.cashAccountID, Equal<Required<CADailySummary.cashAccountID>>>,
Aggregate<Sum<CADailySummary.amtReleasedClearedCr,
Sum<CADailySummary.amtReleasedClearedDr,
Sum<CADailySummary.amtReleasedUnclearedCr,
Sum<CADailySummary.amtReleasedUnclearedDr,
Sum<CADailySummary.amtUnreleasedClearedCr,
Sum<CADailySummary.amtUnreleasedClearedDr,
Sum<CADailySummary.amtUnreleasedUnclearedCr,
Sum<CADailySummary.amtUnreleasedUnclearedDr>>>>>>>>>>.
Select(sender.Graph, CashAccountID);
if ((caBalance != null) && (caBalance.CashAccountID != null))
{
result = caBalance.AmtReleasedClearedDr - caBalance.AmtReleasedClearedCr;
if ((bool)caSetup.CalcBalDebitClearedUnreleased)
result += caBalance.AmtUnreleasedClearedDr;
if ((bool)caSetup.CalcBalCreditClearedUnreleased)
result -= caBalance.AmtUnreleasedClearedCr;
if ((bool)caSetup.CalcBalDebitUnclearedReleased)
result += caBalance.AmtReleasedUnclearedDr;
if ((bool)caSetup.CalcBalCreditUnclearedReleased)
result -= caBalance.AmtReleasedUnclearedCr;
if ((bool)caSetup.CalcBalDebitUnclearedUnreleased)
result += caBalance.AmtUnreleasedUnclearedDr;
if ((bool)caSetup.CalcBalCreditUnclearedUnreleased)
result -= caBalance.AmtUnreleasedUnclearedCr;
}
e.ReturnValue = result;
e.Cancel = true;
}
}

Related

Undo the total amount round / A/R invoice - document total, field cannot be updated (odbc -1029) SAP B1

I am trying to undo the automatic total amount round in A/R RESERVEI NVOICE b1 on an add on extension.
The error throws after:
txtDocTotalAfterDiscountFreightCharge.Active = true;
txtDocTotalAfterDiscountFreightCharge.String = total.ToString();
with this error: Only if I undo the round on A/R RESERVEI NVOICE.
A/R invoice - document total, field cannot be updated (odbc -1029)
for A/R INVOICE it is working well.
[BasicSapForm(Consts.FORM_RESERVE_INVOICE)]
[BasicSapForm(Consts.FORM_INVOICE)]
class OinvListener : SapDocumentsForm
{
public OinvListener(string uniqueId, object extraInfo)
: base(uniqueId, extraInfo)
{
}
public override void Init()
{
}
[BasicSapEvent(SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE, "", true)]
[BasicSapEvent(SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD, "", true)]
private bool BeforeFormAdd(SAPbouiCOM.BusinessObjectInfo pVal)
{
if (MO_ModuleManager.Common.B1Starter.userModules.ContainsKey(ModuleInfo.Code))
{
if (MO_ModuleManager.Common.B1Starter.userModules.ContainsKey(ModuleInfo.SubCode2))
{
di.BusinessPartners diBp = SapUtils.GetDiObjectByFormTypeAndKey (Consts.FORM_BP, txtCardCode.String) as di.BusinessPartners;
if (diBp.UserFields.Fields.Item("U_RoundAum").Value.ToString() == "N")
{
double total = TypeUtils.ExtractDouble
(txtDocTotalAfterDiscountFreightCharge.String);
ui.EditText txtDisc = mForm.Items.Item("42").Specific as ui.EditText;
if (false == string.IsNullOrEmpty(txtDisc.String))
total += TypeUtils.ExtractDouble(txtDisc.String);
try
{
txtDocTotalAfterDiscountFreightCharge.Active = true;
txtDocTotalAfterDiscountFreightCharge.String = total.ToString();
}
catch { }
}
}
}
return true;
}
}

Java.lang.String errors & not printing to error file

For this project the end result was for there to be 2 error reports sent to an error file at as well as a listing of account summary information printed out. While i can get a majority of the account information printed out such as Balance before transaction and transaction to the account or if there were insufficient funds for the transaction, that's all that will print out as it should be. I'm receiving no errors or exceptions so i'm in all honesty not too sure where the issue at hand may be. I was hoping a second pair of eyes on my code could possibly point out where my issue may be, below is my code of the Account.java, CheckingAccount.java CreditCard.java and lastly D4.java which contains the main method.
Account.java
public class Account {
protected String accountNo, institution, name;
protected double balance;
public Account (String accountNo, String name, String institution, double balance) {
this.name = name;
this.accountNo = accountNo;
this.balance = balance;
this.institution = institution;
}
public String getAccount() {
return accountNo;
}
public boolean debitAccount(double amt) {
return false;
}
public boolean creditAccount(double amt) {
return false;
}
}
CheckingAccount.java
public class CheckingAccount extends Account {
public CheckingAccount(String acctNo, String name, String inst, double balance) {
super(acctNo, name, inst, balance);
this.name = name;
this.accountNo = acctNo;
this.balance = balance;
this.institution = institution;
}
public double getBalance()
{
return balance;
}
public boolean debitAccount(double amt) {
balance += amt;
return false;
}
public boolean creditAccount(double amt) {
balance -= amt;
return false;
}
}
CreditCard.java
public class CreditCard extends Account {
private double creditLimit;
private double availableCredit;
public CreditCard(String acctNo, String name, String inst, double limit, double balance) {
super(acctNo, name, inst, 0);
this.creditLimit = creditLimit;
this.availableCredit = availableCredit;
this.balance = balance;
}
public boolean debitAccount(double amt) {
balance -= amt;
return false;
}
public double getCreditLimit(){
return creditLimit;
}
public double getBalance()
{
return balance;
}
public boolean creditAccount(double amt) {
balance += amt;
return false;
}
}
D4.java
import java.io.*;
import java.util.*;
public class D4 {
public static void main(String[] args) throws FileNotFoundException
{
Boolean valid;
String transactionFile = args[0];
String theaccount, transaction;
File transactions = new File(transactionFile);
Scanner infile = new Scanner(transactions);
File errorFile = new File(args[1]);
PrintWriter error = new PrintWriter(errorFile);
Vector<Account> account = new Vector<Account>();
while(infile.hasNext())
{
transaction = infile.nextLine();
valid = performTrans(account, transaction, error, errorFile);
}
}
private static Account findAccount(Vector<Account> a, String acctNo) {
for(int index = 0; index < a.size(); index ++)
{
if (a.elementAt(index).getAccount().equals(acctNo))
{
return a.elementAt(index);
}
}
return null;
}
private static boolean Checkingacct(Account a)
{
if(a instanceof CheckingAccount)
{
return true;
}
else
{
return false;
}
}
private static boolean Creditcrd(Account a)
{
if(a instanceof CreditCard)
{
return true;
}
else
{
return false;
}
}
private static String errorLog(Vector<Account> a, String transaction)
{
String[] trans = transaction.split(":");
String error;
if(findAccount(a, trans[1])==null)
{
error = ("Invalid account: " + transaction);
System.out.println(error);
return error;
}
else
{
Account acc = findAccount(a, trans[1]);
if( trans[0] == "debit")
{
error = ("Transaction denied: " + transaction);
System.out.println(error);
return error;
}
else
{
return null;
}
}
}
private static boolean performTrans(Vector<Account> account, String transaction, PrintWriter log, File errorFile)
{
String[] pieces = transaction.split(":");
String trans = pieces[0];
System.out.println(pieces);
if(trans.equals("create"))
{
if( pieces[1].equals("checking"))
{
CheckingAccount checking = new CheckingAccount(pieces[2], pieces[3], pieces[4], Double.parseDouble(pieces[5]));
account.add(checking);
return true;
}
else if (pieces[1].equals("credit"))
{
CreditCard creditCard = new CreditCard(pieces[2], pieces[3], pieces[4], 0, Double.parseDouble(pieces[5]));
account.add(creditCard);
return true;
}
else
{
System.out.println("not sure what to put here");
return false;
}
}
else if(trans.equals("debit"))
{
if(findAccount(account, pieces[1]) == null)
{
return false;
}
else
{
Account a = findAccount(account, pieces[1]);
double amount = Double.parseDouble(pieces[2]);
if(Checkingacct(a) == true)
{
CheckingAccount checking = (CheckingAccount) a;
System.out.println("Balance before transaction: " + checking.getBalance());
checking.creditAccount(amount);
System.out.println("Transaction to account: " + amount);
System.out.println("Balance after transaction: " + checking.getBalance() + "\n");
return true;
}
else if(Creditcrd(a) == true)
{
CreditCard creditCard = (CreditCard) a;
System.out.println("Balance before transaction: " + creditCard.getBalance());
System.out.println("Transaction to account: " + amount);
if(amount + creditCard.getBalance() > creditCard.getCreditLimit())
{
System.out.println("Insufficient funds for transaction");
return false;
}
else
{
creditCard.creditAccount(amount);
return true;
}
}
}
}
else if(trans.equals("credit"))
{
if(findAccount(account, pieces[1]) == null)
{
System.out.println("Print Error Message");
return false;
}
else
{
Account a = findAccount(account, pieces[1]);
double amount = Double.parseDouble(pieces[2]);
if(Creditcrd(a) == true)
{
CheckingAccount checking = (CheckingAccount) a;
System.out.println("Balance before transaction: " + checking.getBalance());
checking.debitAccount(amount);
System.out.println("Transaction to account: " + amount);
System.out.println("Balance after transaction: " + checking.getBalance() + "\n");
return true;
}
else if(Creditcrd(a) == true)
{
CreditCard creditCard = (CreditCard) a;
System.out.println(creditCard.getBalance());
return true;
}
}
}
else if(trans.equals("report"))
{
return true;
}
return false;
}
}
The text file im attempting to read from is called D4.txt and the information inside of it is
create:checking:10-3784665:Chase:Joe Holder:2000
create:credit:1234567898765432:First Card:Bob Badger:4000
create:checking:11-3478645:Dime:Melissa Martin:1000
report
debit:10-3784665:523.67
debit:1234567898765432:3500
credit:10-3784665:50
credit:11-3478645:30
debit:10-839723:200
debit:1234567898765432:600
report
The two errors im supposed to be able to print out and see in the errorFile.txt or whatever you choose to call it is and is where the main problem is as this information for some reason is not being processed and printed onto the outputfle.
Invalid account: debit:10839723:200
Transaction denied: debit:1234567898765432:600
The information printed to the console is supposed to look like
Account Summary:
Checking account #103784665
Bank: Chase
Name on account: Joe Holder
Balance: 1526.33
Credit Account #1234567898765432
Bank: First Card
Issued to: Bob Badger
Credit Limit: 4000
Balance: 3500.00
Available credit: 500.00
Checking account #113478645
Bank: Dime
Name on account: Melissa Martin
Balance: 1030.00
End account summary.
But this is also a part of the issue as currently when i run the code whats being printed out to the console is
run D4 d4.txt errorFile.txt
[Ljava.lang.String;#1d540a51
[Ljava.lang.String;#b31c562
[Ljava.lang.String;#3db12bab
[Ljava.lang.String;#4ff0c6b8
[Ljava.lang.String;#4d40d320
Balance before transaction: 2000.0
Transaction to account: 523.67
Balance after transaction: 1476.33
[Ljava.lang.String;#2c9cc42e
Balance before transaction: 4000.0
Transaction to account: 3500.0
Insufficient funds for transaction
[Ljava.lang.String;#2bb07c61
[Ljava.lang.String;#483b594b
[Ljava.lang.String;#31470572
[Ljava.lang.String;#20aedee
Balance before transaction: 4000.0
Transaction to account: 600.0
Insufficient funds for transaction
[Ljava.lang.String;#2ea4aa4d
I know this is a lot of information to sort through and i just want to thank anyone and everyone in advance for your help and hope its something simple that im just overlooking!

C# - NAudio - How to change sample rate on a float[] while reading it?

I'm coding my first audio application, and I'm struggling for hours on trying to change samplerate of a cached sound.
I'm using NAudio and I was able to change the Volume, tweaking the Read() method of my ISampleProvider.
Here is the CachedSound Class :
public class CachedSound
{
public float[] AudioData { get; private set; }
public WaveFormat WaveFormat { get; set; }
public CachedSound(string audioFileName)
{
using (var audioFileReader = new AudioFileReader(audioFileName))
{
WaveFormat = audioFileReader.WaveFormat;
var wholeFile = new List<float>((int)(audioFileReader.Length / 4));
var readBuffer = new float[audioFileReader.WaveFormat.SampleRate * audioFileReader.WaveFormat.Channels];
int samplesRead;
while ((samplesRead = audioFileReader.Read(readBuffer, 0, readBuffer.Length)) > 0)
{
wholeFile.AddRange(readBuffer.Take(samplesRead));
}
AudioData = wholeFile.ToArray();
}
}
}
And here is the CachedSoundSampleProvider class :
using NAudio.Wave;
using System;
public delegate void PlaybackEndedHandler();
public class CachedSoundSampleProvider : ISampleProvider
{
public event PlaybackEndedHandler PlaybackEnded;
private CachedSound cachedSound;
private long _position;
public long Position {
get { return _position; }
set { _position = value; }
}
private float _volume;
public float Volume {
get { return _volume; }
set { _volume = value; }
}
private float _pitchMultiplicator;
public float PitchMultiplicator
{
get { return _pitchMultiplicator; }
set { _pitchMultiplicator = value; }
}
public WaveFormat OriginalWaveFormat { get; set; }
public WaveFormat WaveFormat {
get { return cachedSound.WaveFormat; }
}
//Constructeur
public CachedSoundSampleProvider(CachedSound _cachedSound)
{
cachedSound = _cachedSound;
OriginalWaveFormat = WaveFormat;
}
public int Read(float[] destBuffer, int offset, int numBytes)
{
long availableSamples = cachedSound.AudioData.Length - Position;
long samplesToCopy = Math.Min(availableSamples, numBytes);
//Changing original audio data samplerate
//Double speed to check if working
cachedSound.WaveFormat = new WaveFormat(cachedSound.WaveFormat.SampleRate*2, cachedSound.WaveFormat.Channels);
Array.Copy(cachedSound.AudioData, Position, destBuffer, offset, samplesToCopy);
//Changing Volume
for (int i = 0; i < destBuffer.Length; ++i)
destBuffer[i] *= (Volume > -40) ? (float)Math.Pow(10.0f, Volume * 0.05f) : 0;
Position += samplesToCopy;
if (availableSamples == 0) PlaybackEnded();
return (int)samplesToCopy;
}
}
I don't know how I can achieve this yet.
My goal is simple, I want to be able to tweak sample rate at realtime.
I read it's impossible to change it on the ISampleProvider interface.
That's why I tried to change it on the original audioData.
Thanks in advance for your help ! :)

SMPP error code 61,62

I am using the jsmpp lib for sending sms. The SMSC center returns negative response like 61,62 which are Invalid scheduled delivery time and Invalid Validty Period value. After talking with SMSC support, they require to set a default timeout for the message to be delivered, after some search on jsmpp site, didn't find it. Thanks for any suggestions ?
According to SMPP standard it should be possible to leave both of these null, but if Validity Period is required, this can be either an absolute date or a relative one.
The format should be YYMMDDhhmmsstnnp, where
YY is a two digit year (00-99)
MM is month (01-12)
DD is day (01-31)
hh is hours (00-23)
mm is minutes (00-59)
ss is seconds (00-59)
t is tenths of second (00-59)
nn is the time difference in quarter hours between local time and UTC (00-48)
p can be one of the following :-
'+' local time is ahead of UTC.
'-' local time is behind UTC.
'R' This is a relative time.
So to make the validity period 1 hour using a relative time use the following: "000000010000000R"
In my project I didn't have business requirement to schedule delivery time and set validity Period, so I set them null and it's work fine :-)
I use this class to load smpp config from properties file. Code that will using it will looks more readable and simple :-)
SMPPConfigManager is an interface for this class. It's possible to read this config not only from properties file. For example from Db and you can then implement this interface in new class.
package ru.rodin.denis.smpp;
import java.util.Properties;
import org.jsmpp.bean.*;
/**
*
* #author Denis Rodin
*/
public class SMPPFileConfig implements SMPPConfigManager {
private String host;
private int port;
private String systemId;
private String password;
private String systemType;
private TypeOfNumber sourceAddrTon;
private TypeOfNumber destAddrTon;
private NumberingPlanIndicator sourceAddrNpi;
private NumberingPlanIndicator destAddrNpi;
private String addressRange;
private int connectTimeout;
private long reconnectInterval;
private String sourceAddr;
private String destinationAddr;
private SMSCDeliveryReceipt deliveryReceipt;
private RegisteredDelivery registeredDelivery;
private BindType bindType;
private ESMClass esmClass;
private byte protocolId;
private byte priorityFlag;
private String scheduleDeliveryTime;
private String validityPeriod;
private byte replaceIfPresentFlag;
private GeneralDataCoding generalDataCoding;
private boolean generalDataCoding_compressed = true;
private boolean generalDataCoding_containMessageClass = true;
private MessageClass generalDataCoding_messageClass = MessageClass.CLASS1;
private Alphabet generalDataCoding_alphabet = Alphabet.ALPHA_DEFAULT;
private byte smDefaultMsgId;
private long transactionTimer;
private int enquireLinkTimer;
public SMPPFileConfig(Properties prop) {
this.host = prop.getProperty("smpp.host");
this.port = Integer.parseInt(prop.getProperty("smpp.port"));
this.systemId = prop.getProperty("smpp.systemId");
this.password = prop.getProperty("smpp.password");
this.systemType = prop.getProperty("smpp.systemType");
this.sourceAddrTon = getTypeOfNumber(SMPPConfigManager.AddrTon.SOURCE, prop);
this.destAddrTon = getTypeOfNumber(SMPPConfigManager.AddrTon.DEST, prop);
this.sourceAddrNpi = getNumberingPlanIndicator(SMPPConfigManager.AddrNpi.SOURCE, prop);
this.destAddrNpi = getNumberingPlanIndicator(SMPPConfigManager.AddrNpi.DEST, prop);
this.addressRange = prop.getProperty("smpp.addressRange");
this.connectTimeout = Integer.parseInt(prop.getProperty("smpp.connect.timeout"));
this.reconnectInterval = Long.parseLong(prop.getProperty("smpp.reconnect.interval"));
this.sourceAddr = prop.getProperty("smpp.sourceAddr");
this.destinationAddr = null;
this.deliveryReceipt = getSMSCDeliveryReceipt(prop.getProperty("smpp.SMSC.delivery.receipt"));
this.registeredDelivery = new RegisteredDelivery(deliveryReceipt);
this.bindType = getBindTypeFromProp(prop.getProperty("smpp.bindType"));
this.esmClass = createESMClass(prop.getProperty("smpp.ESMClass.MessageMode"), prop.getProperty("smpp.ESMClass.MessageType"), prop.getProperty("smpp.ESMClass.GSMSpecificFeature"));
this.protocolId = new Byte(prop.getProperty("smpp.protocolId"));
this.priorityFlag = new Byte(prop.getProperty("smpp.priorityFlag"));
this.scheduleDeliveryTime = prop.getProperty("smpp.scheduleDeliveryTime");
this.validityPeriod = prop.getProperty("smpp.validityPeriod");
this.replaceIfPresentFlag = new Byte(prop.getProperty("smpp.replaceIfPresentFlag"));
this.generalDataCoding = new GeneralDataCoding(generalDataCoding_compressed, generalDataCoding_containMessageClass, generalDataCoding_messageClass, generalDataCoding_alphabet);
this.smDefaultMsgId = new Byte(prop.getProperty("smpp.smDefaultMsgId"));
this.transactionTimer = Long.parseLong(prop.getProperty("smpp.transactionTimer"));
this.enquireLinkTimer = Integer.parseInt(prop.getProperty("smpp.enquireLinkTimer"));
}
#Override
public String toString() {
return "SMPPFileConfig{" + "host=" + host + ", port=" + port + ", systemId=" + systemId + ", password=" + password + ", systemType=" + systemType + ", sourceAddrTon=" + sourceAddrTon + ", destAddrTon=" + destAddrTon + ", sourceAddrNpi=" + sourceAddrNpi + ", destAddrNpi=" + destAddrNpi + ", addressRange=" + addressRange + ", connectTimeout=" + connectTimeout + ", reconnectInterval=" + reconnectInterval + ", sourceAddr=" + sourceAddr + ", destinationAddr=" + destinationAddr + ", deliveryReceipt=" + deliveryReceipt + ", registeredDelivery=" + registeredDelivery + ", bindType=" + bindType + ", esmClass=" + esmClass + ", protocolId=" + protocolId + ", priorityFlag=" + priorityFlag + ", scheduleDeliveryTime=" + scheduleDeliveryTime + ", validityPeriod=" + validityPeriod + ", replaceIfPresentFlag=" + replaceIfPresentFlag + ", generalDataCoding=" + generalDataCoding + ", generalDataCoding_compressed=" + generalDataCoding_compressed + ", generalDataCoding_containMessageClass=" + generalDataCoding_containMessageClass + ", generalDataCoding_messageClass=" + generalDataCoding_messageClass + ", generalDataCoding_alphabet=" + generalDataCoding_alphabet + ", smDefaultMsgId=" + smDefaultMsgId + '}';
}
#Override
public String getAddressRange() {
return addressRange;
}
#Override
public int getConnectTimeout() {
return connectTimeout;
}
#Override
public SMSCDeliveryReceipt getDeliveryReceipt() {
return deliveryReceipt;
}
#Override
public RegisteredDelivery getRegisteredDelivery() {
return registeredDelivery;
}
#Override
public NumberingPlanIndicator getDestAddrNpi() {
return destAddrNpi;
}
#Override
public TypeOfNumber getDestAddrTon() {
return destAddrTon;
}
#Override
public void setDestinationAddr(String destinationAddr) {
this.destinationAddr = destinationAddr;
}
#Override
public String getDestinationAddr() {
return destinationAddr;
}
#Override
public String getHost() {
return host;
}
#Override
public String getPassword() {
return password;
}
#Override
public int getPort() {
return port;
}
#Override
public long getReconnectInterval() {
return reconnectInterval;
}
#Override
public String getSourceAddr() {
return sourceAddr;
}
#Override
public NumberingPlanIndicator getSourceAddrNpi() {
return sourceAddrNpi;
}
#Override
public TypeOfNumber getSourceAddrTon() {
return sourceAddrTon;
}
#Override
public String getSystemId() {
return systemId;
}
#Override
public String getSystemType() {
return systemType;
}
#Override
public BindType getBindType() {
return bindType;
}
#Override
public ESMClass getESMClass() {
return esmClass;
}
#Override
public void setESMClass(ESMClass esmClass) {
this.esmClass = esmClass;
}
#Override
public byte getProtocolId() {
return protocolId;
}
#Override
public byte getPriorityFlag() {
return priorityFlag;
}
#Override
public String getScheduleDeliveryTime() {
return scheduleDeliveryTime;
}
#Override
public String getValidityPeriod() {
return validityPeriod;
}
#Override
public byte getReplaceIfPresentFlag() {
return replaceIfPresentFlag;
}
#Override
public GeneralDataCoding getGeneralDataCoding() {
return generalDataCoding;
}
#Override
public byte getsmDefaultMsgId(){
return smDefaultMsgId;
}
#Override
public long getTransactionTimer()
{
return transactionTimer;
}
#Override
public int getEnquireLinkTimer()
{
return enquireLinkTimer;
}
private ESMClass createESMClass(String messageMode, String messageType, String GSMSpecificFeature) {
return new ESMClass(getESMClassMessageMode(messageMode), getESMMessageType(messageType), getESMGSMSpecificFeature(GSMSpecificFeature));
}
private MessageMode getESMClassMessageMode(String type) {
if (type.equals("DEFAULT")) {
return MessageMode.DEFAULT;
} else if (type.equals("DATAGRAM")) {
return MessageMode.DATAGRAM;
} else if (type.equals("STORE_AND_FORWARD")) {
return MessageMode.STORE_AND_FORWARD;
} else if (type.equals("TRANSACTION")) {
return MessageMode.TRANSACTION;
} else {
return null;
}
}
private MessageType getESMMessageType(String type) {
if (type.equals("DEFAULT")) {
return MessageType.DEFAULT;
} else if (type.equals("CONV_ABORT")) {
return MessageType.CONV_ABORT;
} else if (type.equals("ESME_DEL_ACK")) {
return MessageType.ESME_DEL_ACK;
} else if (type.equals("ESME_MAN_ACK")) {
return MessageType.ESME_MAN_ACK;
} else if (type.equals("INTER_DEL_NOTIF")) {
return MessageType.INTER_DEL_NOTIF;
} else if (type.equals("SME_DEL_ACK")) {
return MessageType.SME_DEL_ACK;
} else if (type.equals("SME_MAN_ACK")) {
return MessageType.SME_MAN_ACK;
} else if (type.equals("SMSC_DEL_RECEIPT")) {
return MessageType.SMSC_DEL_RECEIPT;
} else {
return null;
}
}
private GSMSpecificFeature getESMGSMSpecificFeature(String type) {
if (type.equals("DEFAULT")) {
return GSMSpecificFeature.DEFAULT;
} else if (type.equals("REPLYPATH")) {
return GSMSpecificFeature.REPLYPATH;
} else if (type.equals("UDHI")) {
return GSMSpecificFeature.UDHI;
} else if (type.equals("UDHI_REPLYPATH")) {
return GSMSpecificFeature.UDHI_REPLYPATH;
} else {
return null;
}
}
private BindType getBindTypeFromProp(String type) {
//String type = prop.getProperty("smpp.bindType");
if (type.equals("BIND_RX")) {
return BindType.BIND_RX;
} else if (type.equals("BIND_TX")) {
return BindType.BIND_TX;
} else if (type.equals("BIND_TRX")) {
return BindType.BIND_TRX;
} else {
return null;
}
}
private TypeOfNumber getTypeOfNumber(SMPPConfigManager.AddrTon ton, Properties prop) {
String type;
if (ton == SMPPConfigManager.AddrTon.SOURCE) {
type = prop.getProperty("smpp.sourceAddrTon");
} else {
type = prop.getProperty("smpp.destAddrTon");
}
if (type.equals("ABBREVIATED")) {
return TypeOfNumber.ABBREVIATED;
} else if (type.equals("ALPHANUMERIC")) {
return TypeOfNumber.ALPHANUMERIC;
} else if (type.equals("INTERNATIONAL")) {
return TypeOfNumber.INTERNATIONAL;
} else if (type.equals("NATIONAL")) {
return TypeOfNumber.NATIONAL;
} else if (type.equals("NETWORK_SPECIFIC")) {
return TypeOfNumber.NETWORK_SPECIFIC;
} else if (type.equals("SUBSCRIBER_NUMBER")) {
return TypeOfNumber.SUBSCRIBER_NUMBER;
} else if (type.equals("UNKNOWN")) {
return TypeOfNumber.UNKNOWN;
} else {
return null;
}
}
private SMSCDeliveryReceipt getSMSCDeliveryReceipt(String type) {
//String type = prop.getProperty("smpp.SMSC.delivery.receipt");
if (type.equals("DEFAULT")) {
return SMSCDeliveryReceipt.DEFAULT;
} else if (type.equals("SUCCESS")) {
return SMSCDeliveryReceipt.SUCCESS;
} else if (type.equals("SUCCESS_FAILURE")) {
return SMSCDeliveryReceipt.SUCCESS_FAILURE;
} else {
return null;
}
}
private NumberingPlanIndicator getNumberingPlanIndicator(SMPPConfigManager.AddrNpi npi, Properties prop) {
String type;
if (npi == SMPPConfigManager.AddrNpi.SOURCE) {
type = prop.getProperty("smpp.sourceAddrNpi");
} else {
type = prop.getProperty("smpp.destAddrNpi");
}
if (type.equals("DATA")) {
return NumberingPlanIndicator.DATA;
} else if (type.equals("ERMES")) {
return NumberingPlanIndicator.ERMES;
} else if (type.equals("INTERNET")) {
return NumberingPlanIndicator.INTERNET;
} else if (type.equals("ISDN")) {
return NumberingPlanIndicator.ISDN;
} else if (type.equals("LAND_MOBILE")) {
return NumberingPlanIndicator.LAND_MOBILE;
} else if (type.equals("NATIONAL")) {
return NumberingPlanIndicator.NATIONAL;
} else if (type.equals("PRIVATE")) {
return NumberingPlanIndicator.PRIVATE;
} else if (type.equals("TELEX")) {
return NumberingPlanIndicator.TELEX;
} else if (type.equals("WAP")) {
return NumberingPlanIndicator.WAP;
} else if (type.equals("UNKNOWN")) {
return NumberingPlanIndicator.UNKNOWN;
} else {
return null;
}
}
}
when you submit current time as scheduled delivery time this error may occur.because it takes some time to send request. so the time you mentioned might be in past .so set the scheduled delivery time to (current time + 10 seconds )
long TEN_SECONDS=10000;//millisecs
Calendar date = Calendar.getInstance();
long t= date.getTimeInMillis();
Date scheduleDeliveryTime=new Date(t + ( TEN_SECONDS));

Receiving Index Out of Range with NHibernate

I'm hoping that someone can help me with this issue. I've been racking
my brain and my project is due very soon. Thank You in advance.
I'm receiving an index out of range exception when inserting a new
record. After searching endlessly for information, it was suggested
that the number of column values in my mapping do not match that in my
persistent class. However, I counted and re-counted, and they seem to
match. As you can see by my code below, I'm using
NHibernate.Mapping.Attributes to do my mapping. Maybe I'm doing
something wrong there.
I finally downloaded the NHibernate source and debugged through my
problem. Below is the insert statement that NHibernate is attempting
to build:
{INSERT INTO WTSLIB33T.PRODDATA (PSTAT, PCONO, PDVNO, PWKTY, PCRTY,
PTSID, PCNNO, PDTTK, PJBNO, PSJNO, PTKNO, PCWNO, PWKAR, PWKDC, PWKCD,
PCNWO, PWDNO, PDESC, PDCCD, PHRS, PUNIT, PSEQ, PCUST) VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}
As you can see, the number of parameters matches the number of fields
in the list. I've also matched up this generated insert with my class
and what I found is that the PSEQ and PCUST columns are out of order
with my persistent class. Then, while debugging through the Dehydrate
function I found two possible issues. The first is that I noticed that
the call to the NullSafeSet function sets parameter 0 to what my PSEQ
field should be set to but parameter 0 in the insert statement is
PSTAT.
The second issue I noticed is that the very last call "index +=
ArrayHelper.CountTrue(includeColumns[i]);" in the Dehydrate function
leaves the index variable at 23 which is correct; however, the next
call "IdentifierType.NullSafeSet(statement, id, index,
session);" ,where it checks for a row id, passes in index 23 which
would be out of range. This value should be 22 for the zero based
array.
protected int Dehydrate(object id, object[] fields, object rowId, bool[] includeProperty, bool[][] includeColumns, int table, IDbCommand statement, ISessionImplementor session, int index)
{
if (log.IsDebugEnabled)
{
log.Debug("Dehydrating entity: " + MessageHelper.InfoString(this, id, Factory));
}
// there's a pretty strong coupling between the order of the SQL parameter
// construction and the actual order of the parameter collection.
for (int i = 0; i < entityMetamodel.PropertySpan; i++)
{
if (includeProperty[i] && IsPropertyOfTable(i, table))
{
PropertyTypes[i].NullSafeSet(statement, fields[i], index, includeColumns[i], session);
index += ArrayHelper.CountTrue(includeColumns[i]);
}
if (rowId != null)
{
// TODO H3.2 : support to set the rowId
// TransactionManager.manager.SetObject(ps, index, rowId);
// index += 1;
throw new NotImplementedException("support to set the rowId");
}
else if (id != null)
{
IdentifierType.NullSafeSet(statement, id, index, session);
index += IdentifierColumnSpan;
}
return index;
}
MY PERSISTENT CLASS:
[NHibernate.Mapping.Attributes.Class(0, Schema = WTSLIB33T, Table =
"PRODDATA", NameType = typeof(ProddataDAO),
Lazy = true)]
public class ProddataDAO : Object // : INotifyPropertyChanged
{
public ProddataDAO()
{
}
public ProddataDAO(string PSTAT, decimal PCONO, decimal PDVNO, decimal PSEQ, string PWKTY, string PCRTY,
decimal PTSID, decimal PCUST, decimal PCNNO, decimal PDTTK, string PJBNO, string PSJNO, decimal PTKNO,
string PCWNO, string PWKAR, string PWKDC, string PWKCD, string PCNWO, decimal PWDNO, string PDESC,
decimal PDCCD, decimal PHRS, decimal PUNIT)
{
_PSTAT = PSTAT;
_PCONO = PCONO;
_PDVNO = PDVNO;
_PSEQ = PSEQ;
_PWKTY = PWKTY;
_PCRTY = PCRTY;
_PTSID = PTSID;
_PCUST = PCUST;
_PCNNO = PCNNO;
_PDTTK = PDTTK;
_PJBNO = PJBNO;
_PSJNO = PSJNO;
_PTKNO = PTKNO;
_PCWNO = PCWNO;
_PWKAR = PWKAR;
_PWKDC = PWKDC;
_PWKCD = PWKCD;
_PCNWO = PCNWO;
_PWDNO = PWDNO;
_PDESC = PDESC;
_PDCCD = PDCCD;
_PHRS = PHRS;
_PUNIT = PUNIT;
}
//public event PropertyChangedEventHandler PropertyChanged;
private decimal _PSEQ;
//[NHibernate.Mapping.Attributes.Id(0, Name="PSEQ", Column="PSEQ", Type="Decimal")]
[NHibernate.Mapping.Attributes.CompositeId(1, UnsavedValue=NHibernate.Mapping.Attributes.UnsavedValueType.Undefined)]
[NHibernate.Mapping.Attributes.KeyProperty(2, Name = "PSEQ", Column = "PSEQ", Type="Decimal")]
[NHibernate.Mapping.Attributes.KeyProperty(2, Name = "PCUST", Column = "PCUST")]
//[NHibernate.Mapping.Attributes.Generator(3, Class="none")]
[NHibernate.Mapping.Attributes.Property(4, Name="PSEQ", Column="PSEQ")]
public virtual decimal PSEQ
{
get
{
return _PSEQ;
}
set
{
if (value != this._PSEQ)
{
_PSEQ = value;
//OnPropertyChanged("PSEQ");
}
}
}
private decimal _PCUST;
//[NHibernate.Mapping.Attributes.Id(0, Column = "PCUST", Type = "Decimal")]
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PCUST
{
get
{
return _PCUST;
}
set
{
if (value != this._PCUST)
{
_PCUST = value;
//OnPropertyChanged("PCUST");
}
}
}
private string _PSTAT;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PSTAT
{
get
{
return _PSTAT;
}
set
{
if (value != this._PSTAT)
{
this._PSTAT = value;
//OnPropertyChanged("PSTAT");
}
}
}
private decimal _PCONO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PCONO
{
get
{
return _PCONO;
}
set
{
if (value != this._PCONO)
{
_PCONO = value;
//OnPropertyChanged("PCONO");
}
}
}
private decimal _PDVNO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PDVNO
{
get
{
return _PDVNO;
}
set
{
if (value != this._PDVNO)
{
_PDVNO = value;
//OnPropertyChanged("PDVNO");
}
}
}
private string _PWKTY;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PWKTY
{
get
{
return _PWKTY;
}
set
{
if (value != this._PWKTY)
{
_PWKTY = value;
//OnPropertyChanged("PWKTY");
}
}
}
private string _PCRTY;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PCRTY
{
get
{
return _PCRTY;
}
set
{
if (value != this._PCRTY)
{
_PCRTY = value;
//OnPropertyChanged("PCRTY");
}
}
}
private decimal _PTSID;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PTSID
{
get
{
return _PTSID;
}
set
{
if (value != this._PTSID)
{
_PTSID = value;
//OnPropertyChanged("PTSID");
}
}
}
private decimal _PCNNO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PCNNO
{
get
{
return _PCNNO;
}
set
{
if (value != this._PCNNO)
{
_PCNNO = value;
//OnPropertyChanged("PCNNO");
}
}
}
private decimal _PDTTK;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PDTTK
{
get
{
return _PDTTK;
}
set
{
if (value != this._PDTTK)
{
_PDTTK = value;
//OnPropertyChanged("PDTTK");
}
}
}
private string _PJBNO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PJBNO
{
get
{
return _PJBNO;
}
set
{
if (value != this._PJBNO)
{
_PJBNO = value;
//OnPropertyChanged("PJBNO");
}
}
}
private string _PSJNO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PSJNO
{
get
{
return _PSJNO;
}
set
{
if (value != this._PSJNO)
{
_PSJNO = value;
//OnPropertyChanged("PSJNO");
}
}
}
private decimal _PTKNO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PTKNO
{
get
{
return _PTKNO;
}
set
{
if (value != this._PTKNO)
{
_PTKNO = value;
//OnPropertyChanged("PTKNO");
}
}
}
private string _PCWNO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PCWNO
{
get
{
return _PCWNO;
}
set
{
if (value != this._PCWNO)
{
_PCWNO = value;
//OnPropertyChanged("PCWNO");
}
}
}
private string _PWKAR;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PWKAR
{
get
{
return _PWKAR;
}
set
{
if (value != this._PWKAR)
{
_PWKAR = value;
//OnPropertyChanged("PWKAR");
}
}
}
private string _PWKDC;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PWKDC
{
get
{
return _PWKDC;
}
set
{
if (value != this._PWKDC)
{
_PWKDC = value;
//OnPropertyChanged("PWKDC");
}
}
}
private string _PWKCD;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PWKCD
{
get
{
return _PWKCD;
}
set
{
if (value != this._PWKCD)
{
_PWKCD = value;
//OnPropertyChanged("PWKCD");
}
}
}
private string _PCNWO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PCNWO
{
get
{
return _PCNWO;
}
set
{
if (value != this._PCNWO)
{
_PCNWO = value;
//OnPropertyChanged("PCNWO");
}
}
}
private decimal _PWDNO;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PWDNO
{
get
{
return _PWDNO;
}
set
{
if (value != this._PWDNO)
{
_PWDNO = value;
//OnPropertyChanged("PWDNO");
}
}
}
private string _PDESC;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual string PDESC
{
get
{
return _PDESC;
}
set
{
if (value != this._PDESC)
{
_PDESC = value;
//OnPropertyChanged("PDESC");
}
}
}
private decimal _PDCCD;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PDCCD
{
get
{
return _PDCCD;
}
set
{
if (value != this._PDCCD)
{
_PDCCD = value;
//OnPropertyChanged("PDCCD");
}
}
}
private decimal _PHRS;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PHRS
{
get
{
return _PHRS;
}
set
{
if (value != this._PHRS)
{
_PHRS = value;
//OnPropertyChanged("PHRS");
}
}
}
private decimal _PUNIT;
[NHibernate.Mapping.Attributes.Property(4)]
public virtual decimal PUNIT
{
get
{
return _PUNIT;
}
set
{
if (value != this._PUNIT)
{
_PUNIT = value;
//OnPropertyChanged("PUNIT");
}
}
}
public override bool Equals(object obj)
{
if (obj == null)
return false;
ProddataDAO p = obj as ProddataDAO;
if (this.PCONO == p.PCONO && this.PDVNO == p.PDVNO && this.PCUST == p.PCUST && this.PSEQ == p.PSEQ)
return true;
else
return false;
}
public override int GetHashCode()
{
int hash = 1122;
hash += (null == this.PCONO ? 0 : this.PCONO.GetHashCode());
hash += (null == this.PDVNO ? 0 : this.PDVNO.GetHashCode());
hash += (null == this.PCUST ? 0 : this.PCUST.GetHashCode());
hash += (null == this.PSEQ ? 0 : this.PSEQ.GetHashCode());
return hash;
}
One possible cause for this problem is that you have mapped two properties to the same column. For example you have mapped a foreign key relation as a relation and as a property field, or you have a descriminator that you also have mapped as a field.
Looking at the primary key mapping I see that it is mapped twice:
[NHibernate.Mapping.Attributes.CompositeId(1, UnsavedValue=NHibernate.Mapping.Attributes.UnsavedValueType.Undefined)]
[NHibernate.Mapping.Attributes.KeyProperty(2, Name = "PSEQ", Column = "PSEQ", Type="Decimal")]
[NHibernate.Mapping.Attributes.KeyProperty(2, Name = "PCUST", Column = "PCUST")]
//[NHibernate.Mapping.Attributes.Generator(3, Class="none")]
[NHibernate.Mapping.Attributes.Property(4, Name="PSEQ", Column="PSEQ")]
Are you sure this is the way to map a composite key with NHiberante attributes? I haven't used it myself. But my guess is that it is this that is causing NHibernate to think that you have mapped the column PSEQ twice.
I think you should only use the KeyProperty and skip the Property attribute for the properties that belong to the primary key.
Try adding this in the top section of the class (do not adorn the property declarations)
[CompositeId(1,UnsavedValue=UnsavedValueType.Undefined)]
[KeyProperty(2, Name="PSEQ", Column="PSEQ")]
[KeyProperty(4, Name="PCUST", Column="PCUST")]
Found this leated forum thread: https://forum.hibernate.org/viewtopic.php?f=25&t=964631&start=0
i had a similar situation when using XML mapping, we had originally included the "parent id" column in the .hbm.xml, then when we went to add the back-reference via a many-to-one tag i received the index out of range exception. removing the original declaration was the key.
<class name="IncomeDetail" table="INCOMEDETAILS" mutable="true" lazy="false">
<id name="IncomeDetailID" column="INCOME_DETAIL_ID">
<generator class="native" />
</id>
<property name='ParticipantID' column='PARTICIPANT_ID' type='Int32'/>
<property name='IncomeGroupCD' column='INCOME_GROUP_CD' type='String'/>
<property name='IncomeTypeID' column='INCOME_TYPE_ID' type='Int32'/>
<!--<property name='EmploymentID' column='EMPLOYMENT_ID' type='Int32'/>-->
<property name='IncomeFrequencyCD' column='INCOME_FREQUENCY_CD' type='String'/>
<property name='CapturedDetGrossIncomeAmt' column='CAPTURED_DET_GROSS_INCOME_AMT' type='Decimal'/>
<property name='CapturedDetNetIncomeAmt' column='CAPTURED_DET_NET_INCOME_AMT' type='Decimal'/>
<property name='VerifiedDetGrossIncomeAmt' column='VERIFIED_DET_GROSS_INCOME_AMT' type='Decimal'/>
<property name='VerifiedDetNetIncomeAmt' column='VERIFIED_DET_NET_INCOME_AMT' type='Decimal'/>
<property name='IncomeDesc' column='INCOME_DESC' type='String'/>
<property name='CapturedDT' column='CAPTURED_DT' type='DateTime' not-null='true'/>
<property name='CapturedBy' column='CAPTURED_BY' type='String' not-null='true'/>
<property name='VerificationDT' column='VERIFICATION_DT' type='DateTime' />
<property name='VerifiedBy' column='VERIFIED_BY' type='String' />
<property name='VefificationSourceCD' column='VEFIFICATION_SOURCE_CD' type='String'/>
<many-to-one name="EmploymentIncome" column="EMPLOYMENT_ID" />
</class>