Hello,
Please help!
I am new to ORM, I am designing access to existing data.
Example Problem: I want to get a particular customer by Id(007). I have two ways of doing it.
Assumption: I have a @Entity class Customer mapped to Database table.
1. (OO Way)
Customer cust = entityManager.find(Customer.class, Id);
String fName = cust.first_name
String lName = cust.last_name
2. (QL Way)
String querySt = "SELECT c FROM Customer c WHERE c.Id = '007'";
Query query = entityManager.createQuery(querySt);
Collection <Customers> cust = query.getResutList();
String fName = cust.first_name
String lName = cust.last_name
Q1. Am I using the correct steps in using both of them,
Q2. If I prefer to use the first one are there any disadvantages to it.
Many Thanks
Alain