Reputation: 41
I have spring.jpa.hibernate.ddl-auto=create
set, and most of my tables are being generated. One is not! I know this must be something stupid, and I'm hoping it's common enough that someone will recognize the problem.
Here is the entity whose table is not being created (without the imports).
@Entity
@Data
@NoArgsConstructor
public class ImageSize {
@Id
@SequenceGenerator(name = "imagesizeseq", sequenceName = "IMAGE_SIZE_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "imagesizeseq")
private Integer imageSizeId;
private String Size;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "imageSize")
private List<ImageData> imageDatas;
}
Here is the entity with a relationship to the missing table
@Entity
@Data
@NoArgsConstructor
public class ImageData {
@Id
@SequenceGenerator(name = "imagedataseq", sequenceName = "IMAGE_DATA_SEQ", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "imagedataseq")
private Integer imageDataId;
@Lob
private byte[] imageData; //TODO: make this java.sql.Blob rather than byte[]; see p 101 in hibernate bk
@ManyToOne
@JoinColumn(name = "IMAGE_SIZE_ID")
private ImageSize imageSize;
@ManyToOne
@JoinColumn(name = "IMAGE_ID")
private Image image;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MIME_TYPE_ID")
private MimeType mimeType;
}
Upvotes: 0
Views: 59
Reputation: 41
The problem was a reserved word. The console error just said 'invalid identifier' right after trying to create the image_size table (the missing one). I changed a field in the image_size table from 'size' to 'imageSize' and that fixed the problem.
Upvotes: 1