Is there a way to convert table entries from an old table to a new one using the same entity class?
To be specfic, here are my entity class’ annotations for the new table:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "benutzer_id")
private Integer benutzerId;
@Basic(optional = false)
@Column(name = "benutzer_name")
private String benutzerName;
@Column(name = "benutzer_vorname")
private String benutzerVorname;
@Column(name = "benutzer_nachname")
private String benutzerNachname;
@JoinColumn(name = "gruppe_id", referencedColumnName = "gruppe_id")
@ManyToOne(optional = false)
private Gruppe gruppe;
@OneToMany(mappedBy = "benutzer")
private Collection<Bestellung> bestellungen;
The columns “benutzer_vorname” and “benutzer_nachname” are missing in the old table, so Hibernate crashes, if it tries to map the table entries.
Do I have to create a new entity class or is it possible to convert the data using the existing one?
You can’t map an entity on two tables (I’m not talking about the JOIN inheritance strategy here) so you’ll have to create a new entity.