Yeah, this is kind of clunky. I just realized testing some business logic that the integer inside the domain object MUST be initialized to zero.
The following does not work once the integer value is 0.
Code:
A a = new A();
List<A> as = aDao.findAllByCriteria( a, "name", 0, 10 );
assertEquals( 9, as.size() );
It must be changed to this:
Code:
A a = A.criteria();
List<A> as = aDao.findAllByCriteria( a, "name", 0, 10 );
assertEquals( 9, as.size() );
And criteria() is something like this within the A class:
Code:
...
Integer integerValue = 0;
...
public static A criteria() {
A a = new A();
a.setIntegerValue( null );
return a;
}
Isn't this kind of bloated? Like to make this much code to make it work? :( I guess it's not too bad, but this is a definitely a "hidden" disadvantage, unless I'm missing something.
To make testing a bit simpler, I've had to create a mismatched pair, which is kind of annoying as well:
Code:
public int getIntegerValue() {
return integerValue;
}
public void setIntegerValue( Integer integerValue ) {
this. integerValue = integerValue;
}
Am I doing something wrong?