Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

ORA-00932: データ型が一致しません: NUMBERが予想されましたがBINARYです。 でハマっているJavaerの皆様へ

More than 3 years have passed since last update.
SELECT
  *
FROM
  HOGE
WHERE
(:startDate IS NULL OR START_DATE >= :startDate) AND
(:endDate IS NULL OR START_DATE >= :endDate)

みたいなSQLをEntityManagerから作ったQueryに食わせて

EntityManager em = YourEntityManagerFactory.create();
Query query = em.createNamedQuery("yourQuery.Name");
query.setParameter("startDate", condition.getStartDate());
query.setParameter("endDate", condition.getEndDate());
List<YourEntity> entities = query.getResultList();

したら

Caused by: java.sql.SQLSyntaxErrorException: ORA-00932: データ型が一致しません: NUMBERが予想されましたがBINARYです。

出てほげーーーーーってなった人へ。

query.setParameter("startDate", condition.getStartDate(), TemporalType.DATE);
// query.setParameter("startDate", condition.getStartDate(), TemporalType.TIME);
// query.setParameter("startDate", condition.getStartDate(), TemporalType.TIMESTAMP);

( ◜◡‾)(‾◡◝ )

blackawa
このアカウントで発信する内容は個人検証に基づくものであり、現在所属する会社の公式見解を示すものではありません。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away