As per my experience with IBatis and as per my understanding of your problem, IBatis calls the setter properties on an object only once when it is populating the object with data. I have debugged the objects passed to IBatis many times and the setter properties are called only once for an object population. The behaviour as per my experience is that when IBatis creates an object via reflection, all the member variables will be initialized to their default values. You can override this by setting the values of the member variables to your business-domain related sentinel values in default constructor. I hope this helps.

 

Can you provide the snippet of your code that is throwing the exception?

PDSR

Jehanzeb Musani
Software Developer

PDSR Technologies FZ-LLC
Al Shatha Tower, 1406
Dubai Internet City
P.O. Box 502416
Dubai, UAE

 

Tel:   +971  4   3692873
Fax:  +971  4   3688220
Mob: +971  50  2465392

[EMAIL PROTECTED]
http://www.pdsr.com

Legal Notice: This message may contain information which is confidential and subject to legal privilege. If you are not the intended recipient, you may not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify the sender immediately by email, facsimile or telephone and return and/or destroy the original message. The views and/or opinions expressed within the contents of his message are not necessarily those of PDSR Technologies FZ-LLC or their affiliates.

 

Sharesense

http://www.sharesense.com

 

 

 


From: Arjen Smits [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 10, 2006 10:48 AM
To: [email protected]
Subject: Confirmation about how ibatis fills the objects it maps to?

 

I have an question concerning how ibatis fills the object it maps its data to.

 

I know it uses the properties of an object to set its data. However in what sequence does it do this? Does it first initialises the field by setting it to null? Or does it do some other form of initialisation first before filling the object with the actual data?

 

The reason I am asking is because currently I implemented an sort of data integrity checking in the data object.

However ibatis triggers the error mechanism when it try’s to set the data in the object.

For example:

 

I got an Class User. This class has the String Username property.

In the set procedure of this property I check if the value being used is not null and the string is longer then 0. If it is I throw an specialised exception.

 

So what happens now is that when I query the database with an select and ibatis tries to fill the user object it throws this specialised exception, indicating that the value being used is either null or an empty string. After some debugging I found out it actually fills it with an empty value first, afore putting in the “real” value.

 

So it seems to initialise the object first with empty values.

 

Can I get confirmation of this behaviour ?

 

Reply via email to