Hi All,
Right now I'm using the GenericQueryManager and a class extending
MetaData to validate new beans for insertion into a database. What I
would like to do is have this validation work on multiple columns and
from what I can tell right now, it is not. Let's talk about an
example first then I will post code.
Lets say I have a row in the database like this:
NAME ACTIVE
--------- ------------
Testing Y
If I created a bean with a NAME="Testing" and an ACTIVE="Y", I would
expect the GQM to say the bean is invalid for insertion into the
database. This works right now. Now, if I had a row like this:
NAME ACTIVE
--------- ------------
Testing N
and I created a bean with NAME="Testing" and an ACTIVE="Y", I want the
GQM to say that the bean is valid for insertion to the database. Now
that we know what I want, let me show you some related code:
MetaData
-------------
addConstraint(new ConstrainedProperty("id")
.identifier(true)
.editable(false)
.unique(true)
);
addConstraint(new ConstrainedProperty("active")
.notEmpty(true)
.notNull(true)
.maxLength(1)
.regexp("(Y|N){1}")
.unique(true)
);
addConstraint(new ConstrainedProperty("name")
.notEmpty(true)
.notNull(true)
.maxLength(64)
.regexp("([\\s\\-A-Za-z0-9]*)")
.unique(true)
);
Here is the code I'm using for the validation, although it shouldn't matter:
SomeElement
-------------------
((Validated)bean).validate(MyAppUtils.getGenericQueryManager(MyClass.class))
What do I need to do to my MetaData class to allow for multiple-column
unicity checks, if it is even available? If it is not available, how
would you suggest working around this? Basically, I've got a table
that holds objects in it that can be active or inactive. If an object
is active, you shouldn't be able to create a new object in that table
with the same name. If an object is inactive, you should be able to
create a new object with the same name as the inactive object.
Thanks in advance,
Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rife-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---