Good day. The problem is the following: there are three hibernate entities: customer, order, photo. The customer has orders and there is one photo. The photo consists of long id, byte [] data (mediumblob), Customer customer. Everything is working. It is necessary now to add another score to the order (long id, byte [] data (mediumblob), Ord ord) - i.e. the same as the photo. But, as soon as I add this entity, the order table ceases to be created and "ERROR". What is wrong? Thank. Update: an error occurs only if you add a link between the order and the invoice, therefore I clarify the question. Is there a limit on the number of columns (the order has 8 columns without this entity) or on the number of additional tables?

@Entity @Table(name = "Orders") public class Ord { @Id @Expose @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Expose @ManyToOne(cascade = CascadeType.ALL) @JoinColumn(name = "product") private Product product; @Expose @Column(nullable = false) private String buyer; @Expose private long orderTime; @Expose private long deliveryTime; @Expose @ManyToOne @JoinColumn(name = "customer") private Customer customer; @Expose @JoinColumn(name = "category") @ManyToOne private Category category; @Expose private boolean status; @JoinColumn(name = "check") @OneToOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL) private Check check; @Entity @Table(name = "checks") public class Check { @Id @Expose @GeneratedValue private long id; @Expose(serialize = false) @Column(columnDefinition = "MEDIUMBLOB") private byte[]data; @Expose(serialize = false) @OneToOne(mappedBy = "check") private Ord order; @Entity @Table(name = "photos") public class Photo { @Id @GeneratedValue @Expose private long id; @Expose(serialize = false) @Column(columnDefinition="mediumblob") private byte[]data; @Expose(serialize = false) @OneToOne(mappedBy = "photo") private Customer customer; 
  • order reserved word in the database, try order1 to make and write here - MrFylypenko
  • no, I just wrote it that way ... Actually Ord. Look at the update, please. - Nikolay Egorov
  • Well, then add the code of your entities without a gett / set, well, and the glass error itself - MrFylypenko
  • @MrFylypenko, which is screened without any problems, which hibernate levels cannot do without doing - etki
  • @MrFylypenko added. - Nikolay Egorov

1 answer 1

You use the reserved word check (it does not allow you to create a table with such a column) for the connection for the class Check:

 @Entity @Table(name = "Orders") public class Ord { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @JoinColumn(name = "check_id") //вот тут замена @OneToOne(fetch = FetchType.EAGER,cascade = CascadeType.ALL) private Check check; //Другие поля } 

The reserved word must be changed to another, for example, check_id .