0

私はエラーで立ち往生しています。使用している値とクエリが正しい場合でも、データベース クエリが null 値を返すようです。

public Ods_Gis_Actel getById(String id) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Ods_Gis_Actel a = (Ods_Gis_Actel) session.get(Ods_Gis_Actel.class,new String(id));
    return a;
}

(コンソールに正しいクエリを表示するLog4j、および検索している行がテーブルに存在することを確信しています)。

正常に動作するクエリ getAll()は、マッピングが正しいことを意味すると思います。 hibernate.util にすることはできますか?

public class HibernateUtil { public static final SessionFactory sessionFactory;

static {
    try {
        // Creation of SessionFactory from hibernate.cfg.xml
        sessionFactory = new Configuration().configure("Hibernate.cfg.xml").buildSessionFactory();
    } catch (Throwable ex) {
        // Make sure you log the exception, as it might be swallowed
        System.err.println("Initial SessionFactory creation failed." + ex);
        throw new ExceptionInInitializerError(ex);
    }
}

// public static final ThreadLocal session = new ThreadLocal();

public static SessionFactory getSessionFactory() {
    return sessionFactory;
}

}

ありがとう、

4

0 に答える 0