I see always more java web applications using ORM frameworks for mapping entities to the database and apparently making the serialization of objects easier.
This looks good and usually involves a lot of code like:
@Entity
@Table(name="Flight")
public class Flight implements Serializable {
Long id;
@Id
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
}
The above maps the Flight POJO to a database table named Flight, this seems quite reasonable for a new application designed from ground up.
However is it a viable solution to use an ORM solution like JPA when an application has to be developed with legacy tables and logic?
In other words is it possible to use ORM tables and legacy tables together? How can I map legacy tables into POJO?
I have seen similar questions like legacy tables to jpa2 entities and generate object @entities from database however they all talk about tools to "reverse engineer" tables to objects. Shouldn't there be an option to do it by hand and once mapped correctly let the ORM framework manage them? It all seems like a hack doing what I am asking for however transforming legacy databases to ORM managed ones should be the rule in my opinion.
Thank you