My application consults a third-party database with read-only access. I need the cars to be built after a certain date and have a history of exchange and shipping to a dealer. The relationship is that a car has one or more elements of the story. An article of the story belongs to a car. Here is my SQL query to get this information:
select c. * from the car c join car_history hist1 in hist1.car_id = c.id where c.built_date> & # 39; 2018-11-01 & # 39; - in JPA will use a past date and hist1.action_type = & # 39; TRADED & # 39; and hist1.car_id in select hist2.order_id from car_history hist2 where hist2.action_type = & # 39; STD & # 39; )
My application does not need data from car_history other than to use it to filter the cars you need as shown in the previous query. Should I create an auto history entity even though the auto history data will not be used beyond this query?