Say we have a Car
class with attributes that represents the fields in the oracle database that only allows unique cars with primary keys year, make, and model:
private int year
private String make
private String model
private String color
Then our example List<Car>
could be:
Car car1 = new Car(2015, "Toyota", "Camry", "Blue")
Car car2 = new Car(2017, "Honda", "Corolla", "White")
Car car3 = new Car(2011, "Honda", "Civic", "Red")
Assuming there are multiple entries in the oracle database,
if I want a select statement that gets the attributes from a List<Car>
to select the same cars with the 3 primary keys in the database, I would want something like:
select * from cars_table where year in (2015,2011,2017) and make in (“Toyota”,”Honda”) and model in (“Camry”,”Corolla”,”Civic”)
I believe that this sql statement works but I have no idea how to build this statement in Java. My algorithm skills aren’t the best and I’ve tried using a for loop for the List but I can’t piece together a second get reference. Thank you so much!