Hibernate chokes on missing rows when dealing with a legacy database

后端 未结 4 1955
一个人的身影
一个人的身影 2021-02-19 09:19

I am trying to implement hibernate on a legacy database (that still has a legacy PHP client), and am running into some problems because the people who wrote the original app had

4条回答
  •  抹茶落季
    2021-02-19 09:52

    I recently programmed a webapp against a legacy database with similar issues. You can still use hibernate, if you don't want to use multiple data access frameworks. What I did is write out native SQL queries for the tricky parts using 'createSqlQuery'. In some cases I had to map complete subqueries or computed values to an entity property, but it works. For parts of the database that were more regular I could still use regular Hibernate mappings and criteria/HQL queries.

    Another thing: maybe you should refrain from using terms like 'no idea what they were doing' or 'muck' a bit. I know it is tempting to view any code left to you by predecessors as inferior, but realize that these people probably did the best they could at the time. Also, your own code is not flawless either, so some humility is in place. Why? For one, people around you might get along with you a bit better if you are not foaming around the mouth all the time about the previous developer(s) who they thought were very knowledgeable. Just a tip.

提交回复
热议问题