Stefan Strooves
Stefan Strooves

Reputation: 634

Eclipse link how to query

I started to work with eclipse link and from what I read in the net the eclipse link is some kind of JPA implementation and you are not working directly with DB code when you are using eclipse link you are working with objects.

My question is what is this if not DB command?

Query q = em
        .createQuery("SELECT p FROM Person p WHERE p.firstName = :firstName AND p.lastName = :lastName"); 

Upvotes: 0

Views: 5819

Answers (2)

vels4j
vels4j

Reputation: 11298

Its JPA query equivalent to SELECT * FROM PERSON WHERE FIRSTNAME='Stefan' and LASTNAME='Strooves'; further you need to set value for parameters.

Query q = em
    .createQuery("SELECT p FROM Person p WHERE p.firstName = :firstName AND 
                                               p.lastName = :lastName");
q.setParameter("firstName", "Stefan");
q.setParameter("lastName", "Strooves");
List<Person> resultList = q.getResultList();

Result list contains all the Person entities matched with query.

Upvotes: 0

Tasos P.
Tasos P.

Reputation: 4114

It's JPQL. You can find more here

Upvotes: 2

Related Questions