Hello,
I have had some problems embedding components for my project, using Java Persistence Annotations and MySQL.
More specifically, Hibernate does not throw any exception while building the tables, however, Hibernate does not create the corresponding table, thus eventually throwing "table does not exist" exceptions.
This behaviour happens with the following code:
Code:
@Entity
public class TestEmb {
private Long id;
private ImageReference image;
private String name;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
@SuppressWarnings("unused")
private void setId(Long id) {
this.id = id;
}
@Embedded
public ImageReference getImage() {
return image;
}
public void setImage(ImageReference image) {
this.image = image;
}
}
@Embeddable
public class ImageReference {
private String title;
private String url;
private String link;
private String description;
@Column(name = "image-title", length = 255)
public String getTitle() { /* Standard getter/setter code omitted */ }
@Column(name = "image-url", length = 255)
public String getUrl() { /* Standard getter/setter code omitted */ }
@Column(name = "image-link", length = 255)
public String getLink() { /* Standard getter/setter code omitted */ }
@Column(name = "image-description", length = 255)
public String getDescription() { /* Standard getter/setter code omitted */ }
}
I have only been able to verify that as soon as I comment the references to the "image" field (field, getter and setter + annotations), the table for "TestEmb" would appear in the database.
I have been unable to understand what was going wrong, and I would like to have your help:
-Do you have an idea of what could be wrong with the code/project setup/whatever else ?
-How can I make Hibernate throw an exception, or at least a message, detailing why it could not create a table rather than let it fail silently? (I am using slf4j and log4j)
Thank you in advance.