I have generated/mapped tables from database using IntelliJ.
Now I want to update the database for one table and I would like to do it via ORM (JPA).
I have created entity class:
@Entity
@Table(name = "protocol", schema = "swprojekt")
public class ProtocolEntity {
private int protocolId;
private String name;
private Date expires;
private String description;
private DocumentEntity document;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "protocol_id", nullable = false)
public int getProtocolId() {
return protocolId;
}
public void setProtocolId(int protocolId) {
this.protocolId = protocolId;
}
@Basic
@Column(name = "name", nullable = false, length = 3000)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Basic
@Column(name = "expires", nullable = false)
public Date getExpires() {
return expires;
}
public void setExpires(Date expires) {
this.expires = expires;
}
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="document")
public DocumentEntity getDocument() {
return document;
}
public void setDocument(DocumentEntity document) {
this.document = document;
}
@Basic
@Column(name = "description", nullable = false, length = 3000)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ProtocolEntity)) return false;
ProtocolEntity that = (ProtocolEntity) o;
if (getProtocolId() != that.getProtocolId()) return false;
if (!getName().equals(that.getName())) return false;
if (!getExpires().equals(that.getExpires())) return false;
if (!getDescription().equals(that.getDescription())) return false;
return getDocument().equals(that.getDocument());
}
@Override
public int hashCode() {
int result = getProtocolId();
result = 31 * result + getName().hashCode();
result = 31 * result + getExpires().hashCode();
result = 31 * result + getDescription().hashCode();
result = 31 * result + getDocument().hashCode();
return result;
}
However, now I am unsure. How can I force ORM to create the table? Running just app does not work. What configuration do I have to make/set?