I have a StateMachine table having all the states in a key, value pair model, like:
stateId StateName
1 INITIATED
2 STARTED
class DeviceStates {
private int deviceStateId;
private String deviceStateName;
}
I have referred this StateMachine table in Device table
class Device {
private Integer deviceId;
private String serialNum;
private Date lastModifiedDate;
private DeviceStates deviceStatesByDeviceStateId;
}
I have to filter out few DeviceStates from Device table for search.
Please help me how to write the Criteria with which I
should be able to get a filter out a few DeviceStates from Device
.
Any help would be appreciated…
Your code would be much more readable if the class was named
DeviceState(since each instance of the class is one and only one state), and if the field was namedstateinstead ofdeviceStatesByDeviceStateId.