tomtomssi
tomtomssi

Reputation: 1035

How to map unknown columns using Hibernate?

I have a database that from time to time gets or has columns removed. Is it possible to map these columns using Hibernate if the column names and data types are not known beforehand? Something like:

@Entity
@Table(name = "some_table")
public class SomeTable {
    @Id
    @GeneratedValue(strategy = GenerationType.Entity)
    private String id;

    // private List<Object> fields;
}

Upvotes: 0

Views: 109

Answers (1)

Christian Beikov
Christian Beikov

Reputation: 16400

It's not possible through entities because Hibernate selects exactly the columns you mapped instead of doing a select *. You can run a native query and run select * though.

Upvotes: 1

Related Questions