I'm using SpringBoot 1.5.14.RELEASE and com.h2database:h2. I have an entity that looks like this
//.... annotations here
public class SomeEntity {
@Id
private Long id;
@Column(name = "some_columne_name", columnDefinition = "FLOAT(10,7)")
private Double someColumnName;
}
The H2 is started with spring.jpa.generate-ddl=true
and spring.jpa.hibernate.ddl-auto=create
But for some reason, H2 does not create the table because later in the code, when a select query run it throws SQL Error:42102
, Table not found
if I start H2 without the columnDefinition
in the entity then it creates the table successfully
How to create tables in H2 with columnDefinition
in entities ?
According to H2 Data Types documentation the correct format is FLOAT(precisionInt) and not FLOAT(precisionInt, precisionInt). So all you have to do is to change column definition part and it will work.
e.g. @Column(name = "some_columne_name", columnDefinition = "FLOAT(10)")
As for what should be the value of precisionInt:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With