package org.hibernateTest.Practice;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.HibernateException;
import org.hibernate.query.Query;
import org.Test.modelClass.frameworkBS;
import java.util.List;
//this is the main class. i have the model class as frameworkBS and there is a mapping file for `mapping //the database with the class`
public class TestData {
public static void main(String[] args){
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
существует файл hibernate.cfg.xml, который сопоставляет файл ресурсов как frameworkBS.hbm.xml с классом frameworkBS.
Session session = sessionFactory.openSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
доступ к классу модели
List list = session.createQuery("from frameworkBS").list();
List<frameworkBS> l = (List<frameworkBS>) list;
int i = 0;
while (i < 6) {
для получения данных из таблицы
System.out.println(l.get(i).getCREAT_DTTM());
}
}
catch (HibernateException ex) {
if (tx != null) {
tx.rollback();
}
ex.printStackTrace(System.err);
} finally {
session.close();
}
}
}
база данных уже создана. Я просто хочу получить данные, используя Hibernate. я получаю ошибку AS
INFO: HHH000490: Using JtaPlatform implementation:
[org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
Hibernate: select frameworkb0_.BTCH_NM as BTCH_NM1_0_, frameworkb0_.BTCH_NBR as BTCH_NBR2_0_,
frameworkb0_.INVOK_ID as INVOK_ID3_0_, frameworkb0_.STRT_DTTM as STRT_DTTM4_0_,
frameworkb0_.END_DTTM as END_DTTM5_0_, frameworkb0_.BTCH_STS_CD as BTCH_STS_CD6_0_,
frameworkb0_.RUN_MDE_TXT as RUN_MDE_TXT7_0_, frameworkb0_.CREAT_BY_NM as CREAT_BY_NM8_0_,
frameworkb0_.CREAT_DTTM as CREAT_DTTM9_0_, frameworkb0_.UPDT_BY_NM as UPDT_BY_NM10_0_,
frameworkb0_.UPDT_DTTM as UPDT_DTTM11_0_ from SPP23_OWNER.SPP23_OWNER.ms_batch_status frameworkb0_
Nov 08, 2019 12:57:22 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 933, SQLState: 42000
Nov 08, 2019 12:57:22 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: ORA-00933: SQL command not properly ended