Querying a MySQL DataBase from JPA

I am working on a Java project. I want a query for mysql related to admission date having mapping between two modules student and attendance. Here's my code so far:

public List<Student> findStudentByDate(String admissionDate) {

   System.out.println("call findStudentMethd******************with this pattern"
        + admissionDate
        + "*********************************************");
   return em.createQuery("select student from Student student where student.admissionDate>='' AND < '' like '" + admissionDate + "'")
            .getResultList();
}

Answers


I believe your query's fracture resides in the fact that you missed the condition.

You have to mention the column and the value in the WHERE clause.

In other words, student.admissionDate >= admissionDate and student.admissionDate >= admissionDate.

Here is how the query should look like (emphasize on the WHERE clause!):

  " SELECT student " +
  " FROM Student student " +
  " WHERE student.admissionDate >= '" + admissionDate + "'" +
  " AND   student.admissionDate <  '" + admissionDate + "'"

Need Your Help

How to grep Git commit diffs or contents for a certain word?

git search grep

In a Git code repository I want to list all commits that contain a certain word. I tried this

Import CSV files from BLOB to Database Table

sql csv blob

I have a table in MS SQL Express that is storing csv files as blobs. I want to import those csv files into a table. The columns in the csv match the columns in the database table. Is this possible?...