Hi, I've the current problem.
This is the entity I'm working on.
[code]
public class InventoryOrder extends BasicEntity {
private Date date;
private DepartmentGroup departmentGroup;
[b]
@InventoryOrderDepartment
private Department department;
[/b]
private Boolean partialInventory;
private Boolean detailedInventory;
private Kind kind;
private Group group;
private Set<Center> centers;
private Date preliminarBalanceDeadLine;
private Date finalBalanceDeadLine;
private Integer daysBeforeStartWarning = 1;
private String mailWarningStartLegend;
private String mailPreliminarBreachLegend;
private String mailFinalBreachLegend;
private Set<InventoryOrderCenter> centersOrders;
}
[/code]
This is the validator I've made.
[code]
@Documented
@ValidatorClass(InventoryOrderDepartmentValidator.class)
@Target({METHOD, FIELD})
@Retention(RUNTIME)
public @interface InventoryOrderDepartment {
String message() default "{InventoryOrder.Validator.Department}";
}
public class InventoryOrderDepartmentValidator implements Validator<InventoryOrderDepartment>, Serializable {
private static final long serialVersionUID = 1L;
public void initialize(InventoryOrderDepartment parameters) {
}
public boolean isValid(Object value){
...
}
}
[/code]
The problem:
During the [code]isValid[/code] method execution I need data from [code]InventoryOrder[/code] besides the [code]department[/code] attribute.
To be more specific, I need to validate if the [code]department[/code] that is to be set is not already persisted in the DB with the same [code]date[/code].
Is there anyway to specified the value of the entity that is gonna be validate, without, this, being necesary the attribute itself?
If not... how could I make this validation posible?
Thanx in advance
|