Hi,
Stuck with this error for the past three days.
org.hibernate.exception.SQLGrammarException: could not insert: [com.Course] at org.hibernate.exception.CacheSQLStateConverter.convert(CacheSQLStateConverter.java:89) ............ at com.Main.saveCourse(Main.java:43) at com.Main.main(Main.java:19) Caused by: java.sql.SQLException: [SQLCODE: <-30>:<Table or View not found>] [Cache Error: <<SYNTAX>errdone+2^%qaqqt>] [Details: <Prepare>] [%msg: < SQL ERROR #30: Table 'SQLUSER.COURSE' not found>] at com.intersys.jdbc.CacheConnection.getServerError(CacheConnection.java:1057)
Code provided below. Using intersystems cache
hibernate.cfg.xml
<hibernate-configuration> <session-factory name="SessionFactory"> <property name="hibernate.connection.driver_class">com.intersys.jdbc.CacheDriver</property> <property name="hibernate.connection.password">SYS</property> <property name="hibernate.connection.url">jdbc:Cache://127.0.0.1:1972/USER</property> <property name="hibernate.connection.username">_SYSTEM</property> <property name="hibernate.dialect">org.hibernate.dialect.Cache71Dialect</property> <mapping resource="com/Course.hbm.xml"/> </session-factory> </hibernate-configuration>
Course.hbm.xml
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Generated Jun 4, 2011 11:09:14 PM by Hibernate Tools 3.4.0.CR1 --> <hibernate-mapping> <class name="com.Course" table="SQLUSER.COURSE">(Have tried with COURSE as well) <id name="courseId" type="long"> <column name="COURSEID" /> <generator class="assigned" /> </id> <property name="courseName" type="java.lang.String"> <column name="COURSENAME" /> </property> </class> </hibernate-mapping>
Main.java
public static void main(String[] args) { // TODO Auto-generated method stub Main obj=new Main(); System.out.println("main"); obj.saveCourse("Physics"); obj.saveCourse("Chemistry"); obj.saveCourse("Maths"); } public void saveCourse(String subject) { Session sess=HibernateUtil.getSessionFactory().openSession(); Transaction trans= null; Long courseId=null; try { trans=sess.beginTransaction(); trans.begin(); Course course=new Course(); course.setCourseName(subject); courseId= (Long)sess.save(course); trans.commit(); } catch(Exception e) { e.printStackTrace(); } finally { sess.close(); } }
Would be very helpful if someone could point out the issue in the above code.
Thanks. Vickram
|