Issue
I am looking for an answer if it is possible or not in hibernate.
What I am trying to achieve is that if a particular table exists in the DB then the application should do all the regular operations with it (which exists in the code - find,save.. etc.).
Else just ignore the table (@Repository) and the fields in the @Entity class, and will skip all the related code.
I have the same question regarding ignoring particular non-existing field of an existing table and the field is annotated with @Column, is it possible to ignore the field if it does not exist in table?
I want to use save method of JPA but which can ignore that field if needed.
Solution
That's impossible because with Hibernate you map a Class to table and the table and all the mapped columns MUST exist.
What you are trying to do is dynamic SQL and there you would need to read the database dictonary to check what exsits and generate the code during runtime.
Answered By - Simon Martinelli