New Posts New Posts RSS Feed: Entity MaxLength Property
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Entity MaxLength Property

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: Entity MaxLength Property
    Posted: 19-Mar-2011 at 10:01am
I have an Entity which has a VarChar field of 350 chars.  On rare occasions, the length will exceed that.  An error is then thrown by the database.
 
If I set the MaxLength of the property on the Entity, I still get an error that says MaxLength has been exceeded.
 
What is the guidance on avoiding this type of error? 
 
There is no GUI involved, it occurs on backend processing, so I don't think it really a validation issue.
 
If it just truncated the field, that would be OK with me as it's usually corruption on a data error when it gets exceeded.
 
But I do want to save the rest of the entity which I can't do if it's throwing an error.
 
Greg
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 21-Mar-2011 at 1:53am

Hi Greg,

 
Not sure I understand the issue...
You want to be able to enter more than 350 characters and not have any error thrown? If this is the size limit you will get the exception regardless. (from DevForce and/or the datasource)
 
If you still want to be able to input more than 350 chars without errors, you should handle the extra characters before you try to commit. For that I suggest using the property interceptor (BeforeSet) to truncate the string to the maximum allowed size.
 
You can find additional info about property interceptors in the DevForce Resource Center.
 
Let me know if I understood your issue and if that's the answer you are looking for.
 
Silvio.
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 22-Mar-2011 at 4:50pm

Hi Silvo,

The issue is that I am doing data processing and have no control over the data that is sometimes input.  Thus it can happen that the field is over 350 chars, so yes, I just want to truncate the field down to the 350 chars so no error is thrown.
 
So yes, you do understand correctly.
 
I will check out the BeforeSet property interceptor, it's sounds like what I am looking for.
 
Greg
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down