I’m currently implementing a new functionality to a tool in an e-learning platform. I need to retrieve some columns from 3 different tables in the database. The particular tool is implemented with Hibernate technology where a class is mapped to a database table.
However, I need to use some information from different tables to build a single class.
- Can you Hibernate provide this sort of implementation?
- If not, will it be appropriate for me to use SQL in this situation?
- Is it a good practice to have 2 database technologies in one place?
Hibernate is made to do this, multiple tables either through relationships such as many-to-one, or multiple tables which represent different subtypes, etc. You can use entity-name to map a single class to two different tables for different situations. So the answer is yes.
As to doing Hibernate and hand-coding SQL in the same application, I think it’s a very common practice, sometimes it’s 200% easier to do than figure out the Hibernate mapping for a small detail. I’m referring to something like JDBC, but as nowaq points out, you cna do this in Hibernate as well.