What is the correct way to defend against trying to store more text than can be accommodated in a VARCHAR2 database field?
Say the PARTNER_ROLE field of the REGISTRATIONS table is declared as VARCHAR2(80).
This field is mapped in the Registration class in Java as
public class Registration {
@Column(name=”PARTNER_ROLE” length=”80”)
private String partnerRole;
}
However, the setPartnerRole() method allows the user to stuff a string of any length. The problem is encountered only when one subsequently tries to insert or update the REGISTRATIONS record. Oracle complains.
What is the correct way to handle this situation?