[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - JPA defaulting column type to varchar(2) and I want char(2)

krenfro do-not-reply at jboss.com
Thu Mar 27 17:24:29 EDT 2008


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.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139485#4139485

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139485



More information about the jboss-user mailing list