Oracle in index()函数给出“ORA-01722:无效数字”错误

Oracle in index()函数给出“ORA-01722:无效数字”错误,oracle,hibernate,Oracle,Hibernate,我创建了一个在hibernate HQL中使用索引函数的示例,如下所示 本文档包含以下HQL示例: from Show show where 'fizard' in indices(show.acts) 因此,我为Show创建了一个实体,其中包含一系列行为,如下所示: @Entity public class Show { @Id @GeneratedValue private int id; private String name; @Elemen

我创建了一个在hibernate HQL中使用索引函数的示例,如下所示

本文档包含以下HQL示例:

from Show show where 'fizard' in indices(show.acts)
因此,我为Show创建了一个实体,其中包含一系列行为,如下所示:

@Entity
public class Show {
    @Id
    @GeneratedValue
    private int id;

    private String name;

    @ElementCollection
    private List<String> acts;

// Getters & Settters
}
@ElementCollection
@OrderColumn
private List<String> acts;
因此,为了使集合成为索引,我更新了我的Show entity属性,其操作如下:

@Entity
public class Show {
    @Id
    @GeneratedValue
    private int id;

    private String name;

    @ElementCollection
    private List<String> acts;

// Getters & Settters
}
@ElementCollection
@OrderColumn
private List<String> acts;
以下是我正在进行的项目:

要将数据保存到DB中,我有以下逻辑:

private static void saveData() {
        Session session = getSession();
        session.getTransaction().begin();

        List<String> acts = new ArrayList<String>();
        acts.add("fizard");
        acts.add("Lord of Rings");

        Show s = new Show();
        s.setName("One");
        s.setActs(acts);

        List<String> acts1 = new ArrayList<String>();
        acts1.add("Tales");
        acts1.add("Stories");


        Show s1 = new Show();
        s1.setName("Two");
        s1.setActs(acts1);

        session.save(s);
        session.save(s1);

        session.getTransaction().commit();
        session.close();
    }
private static void showData() {
        Session session = getSession();
        session.getTransaction().begin();

        Query q = session
                .createQuery("from Show show where 'fizard' in indices(show.acts)");
        List<Show> result = q.list();
        System.out.println("result=" + result);
        for (Show p : result) {
            System.out.println(p.getName());
        }

        session.getTransaction().commit();
        session.close();
    }
然后要运行HQL,我有以下逻辑:

private static void saveData() {
        Session session = getSession();
        session.getTransaction().begin();

        List<String> acts = new ArrayList<String>();
        acts.add("fizard");
        acts.add("Lord of Rings");

        Show s = new Show();
        s.setName("One");
        s.setActs(acts);

        List<String> acts1 = new ArrayList<String>();
        acts1.add("Tales");
        acts1.add("Stories");


        Show s1 = new Show();
        s1.setName("Two");
        s1.setActs(acts1);

        session.save(s);
        session.save(s1);

        session.getTransaction().commit();
        session.close();
    }
private static void showData() {
        Session session = getSession();
        session.getTransaction().begin();

        Query q = session
                .createQuery("from Show show where 'fizard' in indices(show.acts)");
        List<Show> result = q.list();
        System.out.println("result=" + result);
        for (Show p : result) {
            System.out.println(p.getName());
        }

        session.getTransaction().commit();
        session.close();
    }
基于这个错误,我知道我正在尝试将字符串“fizard”与索引(这是一个数字)进行比较。但是,由于我刚刚阅读了hibernate的官方文档,有人能告诉我如何使用hibernate的索引功能编写一个简单的程序。

您对此提出了疑问: 冬眠: 从show0\u中选择show0\u.id作为id1\u 2\u,show0\u.name作为name2\u 2\u “fizard”在哪里 从Show_acts acts1中选择acts1_uu.acts_uOrder,其中show0_u.id=acts1_u.Show_id

感觉是可以涂抹的,但是acts1_u。acts_u顺序可以是一个数字列,例如数字列,以获得这样的结果