Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Capital letters for class attribute?

  • Hi,

    I was trying to create an attribute named DNI for one of my classes. Everything seemed to go smoothly, even records were created. Nevertheless, DNI values did not appear on the columns being showed on the browser.. It said it could not convert from Int to String when reading records from the database...

    Why?, Is there any limitation on the name for the class attributes under OpenXava/Hibernate?

    Thanks in advance,


    Last edit: Jose Roman Bilbao 2013-09-16
  • Javier Paniza
    Javier Paniza

    Hi José,

    you have to write your DNI property in this way:

    private String dni;
    public String getDni() {
        return dni;
    public void setDni(String dni) {
        this.dni = dni;

    That is, follow the JavaBeans rules for properties. Not only OpenXava, but also Hibernate and even Java (with its JavaBeans and instrospection APIs) expect you follow the Java conventions for naming.

    All caps in Java is reserved for final static variables (that is for constants). Following the Java naming rules is also useful when other Java developers read a snippet of your code, they can understand many things without reading the definitions. If a Java programmer see DNI he'll thinks that is a final variable.

    Help others in this forum as I help you.
    Need more help? Get OpenXava professional support.

    • Thanks a lot for your response, now everything is going fine.