0 Replies Latest reply on Mar 27, 2008 5:24 PM by krenfro

    JPA defaulting column type to varchar(2) and I want char(2)

    krenfro

      Is there any way to get JPA to map a String member variable as a 'char' sql data type instead of the default 'varchar'?

      In an EJB3 Entity Bean I have the following member variable defined:

      ...
      @Column( name="STATE", nullable=false, length=2 )
      private String state;
      ...

      When using JPA to read/persist this entity, using Hibernate as the provider, I get an exception complaining that varchar(2) was the expected type for the column. I don't want to have to modify the database schema to varchar(2) even though that is trivial. My only guess is that I need to use the "columnDefinition" attribute of the @Column annotation.

      Thanks in advance.