Search code examples
javajpavarcharlongtext

generating tables from jpa with limited character length


I want to create a text field in a database with varchar(700) (I want 700 characters max). I tried to define it like this:

@Entity
@Table(name = "t_foo)
public class Foo {

@Column(unique = true, nullable = false)
@Id
private String idNational;

@Column(length=700)
private String comment;

...

The table generate has the following properties:

idNational varchar(255) NOT NULL

comment longtext NULL

I would really like the comment to be varchar(700). Is there a reason it makes it a longtext? Is there a way I can make it varchar? Maybe this is an easy question, but I haven't found the solution! Do I have to create the tables with DDL instead?

Thank you!


Solution

  • It's problem with JPA provider configuration. Better solution is cretion of tables with DDL.