Reputation: 90150
We have two teams who want to access the same database using different technologies. One uses JPA (Hibernate, to be specific). The other uses plain JDBC.
I've been asked to compile a list of concerns assuming that each team uses the default configuration and/or "best practices" of each technology.
This is a new database, so imagine that the schema is being designed solely by the JPA team, or solely by the JDBC team, and then they both go about trying to access it.
Can you please share your experiences?
UPDATE: I'm not asking for opinions here. I don't care whether JPA or JDBC is "better". I am asking for an objective list of interoperability concerns when mixing the two technologies.
Here is an example of what I'm looking for:
Scenario: A user reads a row, modifies it in memory, and saves it back to the database.
version
column to each table.SELECT ... FOR UPDATE
to prevent concurrent updates.Imagine what happens if the JDBC implementation is not aware of the JPA convention and does not update version
on commit:
SELECT
and sees version
equal to 1.SELECT ... FOR UPDATE
.version
.version
is still equal to 1.Lesson learned: The JDBC implementation needs to know to update the version
column.
Upvotes: 2
Views: 1800
Reputation: 90150
Building my own list while waiting for other people to answer:
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
is used, it creates and uses a sequence table (e.g. hibernate_sequence
). JDBC would have to do the same.Upvotes: 2