I'm new to JPA and I'm learning a lot about it. I recently deployed an application with EclipseLink as my JPA provider and it is running well.
Now there is a need to add an extra column to one of the mapped tables. This extra field is for reporting purposes and does not affect my application, so I really don't want to touch something that is working well. I will of course update my application in due time to include this field in my mappings but I don't want to do it just now.
This column addition will be done externally by the DBA directly to the tables. Will this addition break my application?
I believe that this should not happens since there is no change in the mapped fields and as far as JPA is concerned nothing has changed. JPA will not be aware of what was added so everything should work without breaking.
Please correct me if I'm wrong. Thanks.
We can use the JPA @Lob annotation to map large fields to large database object types.
Let's start with the @Column annotation. It is an optional annotation that enables you to customize the mapping between the entity attribute and the database column.
Of-course if you use it only for querying purpose then it should be fine.
If no @Table is defined the default values are used: the unqualified class name of the entity. For example if you have: @Entity public class MyTest{ ... Your table will have the name my_test in your database.
You can do it there's no reason it could break, JPA does not force you to map every column to a field in your entity. Except if the new column is mandatory (NOT NULL
) and does not have a default value (on insert for example).
Will this addition break my application?
No, it will not.
JPA allows you to map only the tables and fields you actually need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With