Hibernate-Annotations-Problem

7bkahnt

Mitglied
Hallo Leute ich hoffe Ihre könnt mir helfen,
ich wollte mich mal näher mit Hibernate beschäftigen und ein erstes Tutorial machen. Aber wie es meist so ist, funktioniert das erste Programm schon nicht.
Ich benutze MyEclipse, habe ein neues Project angelegt und per Add Hibernate Capabilities die notwendigen jar´s alle in der Build Path. Der Oracle-Treiber oracle14.jar befindet sich ebenfalls in der Build Path.
Muss ich sonst noch irgendetwas machen? In den Tutorials steht eigentlich nichts anderes.

Das Testprogramm soll 3 Kurse in der Datenbank anlegen und sie auflisten (Physik,Chemie und Mathe).
Eigentlich benutze ich eine Oracle-Datenbank. So wie ich das verstanden habe, wird durch die hsql.jar aber ein hsqlserver zur Verfügung gestellt, welcher irgendwie auch eine Datenbank zur Verfügung stellt (weil alle Tutorials eigentlich mit "org.hsqldb.jdbcDriver" beschrieben sind).
Ich habe jetzt erstmal den Quellcode im Bezu auf meine Oracle-Datenbank genommen.
Hab ich dort vielleicht einen Fehler? Ich komme hier nicht weiter...

Hier erstmal der Code zum Testprogramm:

Course.java:
Java:
package com.vaannila.course;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;


@Entity
@Table(name="COURSES")
public class Course {

	private long courseId;
	private String courseName;

	public Course() {
	}

	public Course(String courseName) {
		this.courseName = courseName;
	}

	@Id
	@GeneratedValue
	@Column(name="COURSE_ID")
	public long getCourseId() {
		return this.courseId;
	}

	public void setCourseId(long courseId) {
		this.courseId = courseId;
	}

	@Column(name="COURSE_NAME", nullable=false)
	public String getCourseName() {
		return this.courseName;
	}

	public void setCourseName(String courseName) {
		this.courseName = courseName;
	}
}


HibernatUtil:
Java:
package com.vaannila.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {
	private static final SessionFactory sessionFactory;
	static {
		try {
			sessionFactory = new AnnotationConfiguration().configure()
					.buildSessionFactory();
		} catch (Throwable ex) {
			System.err.println("Initial SessionFactory creation failed." + ex);
			throw new ExceptionInInitializerError(ex);
		}
	}

	public static SessionFactory getSessionFactory() {
		return sessionFactory;
	}
}



die hibernate.cfg:
Java:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
		"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
		"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
        <property name="hibernate.connection.username">system</property>
        <property name="connection.password">adminadmin</property>
        <property name="connection.pool_size">1</property>
        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">create</property>
        <mapping class="com.vaannila.course.Course" />
    </session-factory>
</hibernate-configuration>


und letztendlich die main.java:
Java:
package com.vaannila.course;

import java.util.List;
import java.util.Iterator;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.vaannila.util.HibernateUtil;

public class Main {

	public static void main(String[] args) {
		Main obj = new Main();
		Long courseId1 = obj.saveCourse("Physics");
		Long courseId2 = obj.saveCourse("Chemistry");
		Long courseId3 = obj.saveCourse("Maths");
		obj.listCourse();
		obj.updateCourse(courseId3, "Mathematics");
		obj.deleteCourse(courseId2);
		obj.listCourse();
	}
	
	public Long saveCourse(String courseName)
	{
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = null;
		Long courseId = null;
		try {
			transaction = session.beginTransaction();
			Course course = new Course();
			course.setCourseName(courseName);
			courseId = (Long) session.save(course);
			transaction.commit();
		} catch (HibernateException e) {
			if(transaction!=null){
			transaction.rollback();
			e.printStackTrace();}
			else{System.out.println("transaction=null");}
		} finally {
			session.close();
		}
		return courseId;
	}
	
	public void listCourse()
	{
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			List courses = session.createQuery("from Course").list();
			for (Iterator iterator = courses.iterator(); iterator.hasNext();)
			{
				Course course = (Course) iterator.next();
				System.out.println(course.getCourseName());
			}
			transaction.commit();
		} catch (HibernateException e) {
			if(transaction!=null){
				transaction.rollback();
				e.printStackTrace();}
				else{System.out.println("transaction=null");}
		} finally {
			session.close();
		}
	}
	
	public void updateCourse(Long courseId, String courseName)
	{
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			Course course = (Course) session.get(Course.class, courseId);
			course.setCourseName(courseName);
			transaction.commit();
		} catch (HibernateException e) {
			if(transaction!=null){
				transaction.rollback();
				e.printStackTrace();}
				else{System.out.println("transaction=null");}
		} finally {
			session.close();
		}
	}
	
	public void deleteCourse(Long courseId)
	{
		Session session = HibernateUtil.getSessionFactory().openSession();
		Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			Course course = (Course) session.get(Course.class, courseId);
			session.delete(course);
			transaction.commit();
		} catch (HibernateException e) {
			if(transaction!=null){
				transaction.rollback();
				e.printStackTrace();}
				else{System.out.println("transaction=null");}
		} finally {
			session.close();
		}
	}
}

Am Ende bekomme ich immer den Fehler:

14:01:52,591 INFO Version:15 - Hibernate Annotations 3.4.0.GA
14:01:52,601 INFO Environment:560 - Hibernate 3.3.2.GA
14:01:52,601 INFO Environment:593 - hibernate.properties not found
14:01:52,601 INFO Environment:771 - Bytecode provider name : javassist
14:01:52,611 INFO Environment:652 - using JDK 1.4 java.sql.Timestamp handling
14:01:52,661 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
14:01:52,661 INFO Configuration:1474 - configuring from resource: /hibernate.cfg.xml
14:01:52,661 INFO Configuration:1451 - Configuration resource: /hibernate.cfg.xml
14:01:52,721 INFO Configuration:1589 - Configured SessionFactory: null
14:01:52,721 INFO HibernateSearchEventListenerRegister:53 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
14:01:52,761 INFO AnnotationBinder:419 - Binding entity from annotated class: com.vaannila.course.Course
14:01:52,781 INFO EntityBinder:422 - Bind entity com.vaannila.course.Course on table COURSES
14:01:52,811 INFO Version:17 - Hibernate Validator 3.1.0.GA
14:01:52,851 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
14:01:52,851 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 1
14:01:52,851 INFO DriverManagerConnectionProvider:68 - autocommit mode: false
14:01:52,861 INFO DriverManagerConnectionProvider:103 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:XE
14:01:52,861 INFO DriverManagerConnectionProvider:109 - connection properties: {user=system, password=****}
14:01:53,001 INFO SettingsFactory:114 - RDBMS: Oracle, version: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
14:01:53,001 INFO SettingsFactory:115 - JDBC driver: Oracle JDBC driver, version: 10.2.0.1.0XE
14:01:53,021 INFO Dialect:175 - Using dialect: org.hibernate.dialect.HSQLDialect
14:01:53,021 INFO TransactionFactoryFactory:59 - Using default transaction strategy (direct JDBC transactions)
14:01:53,021 INFO TransactionManagerLookupFactory:80 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
14:01:53,021 INFO SettingsFactory:161 - Automatic flush during beforeCompletion(): disabled
14:01:53,021 INFO SettingsFactory:165 - Automatic session close at end of transaction: disabled
14:01:53,021 INFO SettingsFactory:172 - JDBC batch size: 15
14:01:53,021 INFO SettingsFactory:175 - JDBC batch updates for versioned data: disabled
14:01:53,021 INFO SettingsFactory:180 - Scrollable result sets: enabled
14:01:53,021 INFO SettingsFactory:188 - JDBC3 getGeneratedKeys(): enabled
14:01:53,021 INFO SettingsFactory:196 - Connection release mode: auto
14:01:53,031 INFO SettingsFactory:223 - Default batch fetch size: 1
14:01:53,031 INFO SettingsFactory:227 - Generate SQL with comments: disabled
14:01:53,031 INFO SettingsFactory:231 - Order SQL updates by primary key: disabled
14:01:53,031 INFO SettingsFactory:235 - Order SQL inserts for batching: disabled
14:01:53,031 INFO SettingsFactory:397 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:01:53,031 INFO ASTQueryTranslatorFactory:47 - Using ASTQueryTranslatorFactory
14:01:53,031 INFO SettingsFactory:243 - Query language substitutions: {}
14:01:53,031 INFO SettingsFactory:248 - JPA-QL strict compliance: disabled
14:01:53,031 INFO SettingsFactory:253 - Second-level cache: enabled
14:01:53,031 INFO SettingsFactory:257 - Query cache: disabled
14:01:53,031 INFO SettingsFactory:382 - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
14:01:53,031 INFO SettingsFactory:267 - Optimize cache for minimal puts: disabled
14:01:53,031 INFO SettingsFactory:276 - Structured second-level cache entries: disabled
14:01:53,031 INFO SettingsFactory:296 - Echoing all SQL to stdout
14:01:53,031 INFO SettingsFactory:305 - Statistics: disabled
14:01:53,031 INFO SettingsFactory:309 - Deleted entity synthetic identifier rollback: disabled
14:01:53,031 INFO SettingsFactory:324 - Default entity-mode: pojo
14:01:53,031 INFO SettingsFactory:328 - Named query checking : enabled
14:01:53,061 INFO SessionFactoryImpl:193 - building session factory
14:01:53,171 INFO SessionFactoryObjectFactory:105 - Not binding factory to JNDI, no JNDI name configured
14:01:53,181 INFO SchemaExport:226 - Running hbm2ddl schema export
14:01:53,181 INFO SchemaExport:251 - exporting generated schema to database
14:01:53,211 ERROR SchemaExport:348 - Unsuccessful: create table COURSES (COURSE_ID bigint generated by default as identity (start with 1), COURSE_NAME varchar(255) not null, primary key (COURSE_ID))
14:01:53,221 ERROR SchemaExport:349 - ORA-00907: Rechte Klammer fehlt

14:01:53,221 INFO SchemaExport:268 - schema export complete
14:01:53,251 DEBUG SQL:111 - insert into COURSES (COURSE_ID, COURSE_NAME) values (null, ?)
Hibernate: insert into COURSES (COURSE_ID, COURSE_NAME) values (null, ?)
14:01:53,291 WARN JDBCExceptionReporter:100 - SQL Error: 904, SQLState: 42000
14:01:53,291 ERROR JDBCExceptionReporter:101 - ORA-00904: "COURSE_NAME": ungültiger Bezeichner

org.hibernate.exception.SQLGrammarException: could not insert: [com.vaannila.course.Course]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at com.vaannila.course.Main.saveCourse(Main.java:34)
at com.vaannila.course.Main.main(Main.java:16)
Caused by: java.sql.SQLException: ORA-00904: "COURSE_NAME": ungültiger Bezeichner

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
... 17 more
14:01:53,301 DEBUG SQL:111 - insert into COURSES (COURSE_ID, COURSE_NAME) values (null, ?)
Hibernate: insert into COURSES (COURSE_ID, COURSE_NAME) values (null, ?)
14:01:53,301 WARN JDBCExceptionReporter:100 - SQL Error: 904, SQLState: 42000
14:01:53,301 ERROR JDBCExceptionReporter:101 - ORA-00904: "COURSE_NAME": ungültiger Bezeichner

org.hibernate.exception.SQLGrammarException: could not insert: [com.vaannila.course.Course]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at com.vaannila.course.Main.saveCourse(Main.java:34)
at com.vaannila.course.Main.main(Main.java:17)
Caused by: java.sql.SQLException: ORA-00904: "COURSE_NAME": ungültiger Bezeichner

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
... 17 more
14:01:53,301 DEBUG SQL:111 - insert into COURSES (COURSE_ID, COURSE_NAME) values (null, ?)
Hibernate: insert into COURSES (COURSE_ID, COURSE_NAME) values (null, ?)
14:01:53,301 WARN JDBCExceptionReporter:100 - SQL Error: 904, SQLState: 42000
14:01:53,301 ERROR JDBCExceptionReporter:101 - ORA-00904: "COURSE_NAME": ungültiger Bezeichner

org.hibernate.exception.SQLGrammarException: could not insert: [com.vaannila.course.Course]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at com.vaannila.course.Main.saveCourse(Main.java:34)
at com.vaannila.course.Main.main(Main.java:18)
Caused by: java.sql.SQLException: ORA-00904: "COURSE_NAME": ungültiger Bezeichner

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1169)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
... 17 more
14:01:53,411 DEBUG SQL:111 - select course0_.COURSE_ID as COURSE1_0_, course0_.COURSE_NAME as COURSE2_0_ from COURSES course0_
Hibernate: select course0_.COURSE_ID as COURSE1_0_, course0_.COURSE_NAME as COURSE2_0_ from COURSES course0_
14:01:53,411 WARN JDBCExceptionReporter:100 - SQL Error: 904, SQLState: 42000
14:01:53,411 ERROR JDBCExceptionReporter:101 - ORA-00904: "COURSE0_"."COURSE_NAME": ungültiger Bezeichner

org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at com.vaannila.course.Main.listCourse(Main.java:53)
at com.vaannila.course.Main.main(Main.java:19)
Caused by: java.sql.SQLException: ORA-00904: "COURSE0_"."COURSE_NAME": ungültiger Bezeichner

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 9 more
Exception in thread "main" java.lang.IllegalArgumentException: id to load is required for loading
at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:74)
at org.hibernate.event.LoadEvent.<init>(LoadEvent.java:56)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:840)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:836)
at com.vaannila.course.Main.updateCourse(Main.java:76)
at com.vaannila.course.Main.main(Main.java:20)

 
Zuletzt bearbeitet:
So ich habe meinen Post nochmal geändert.
Jetzt funktioniert es auch.Aber erst nachdem ich eine Tabelle namens "Courses" angelegt habe und den Dialekt auf OracleDialect umgestellt habe.
Müsste aber nicht eigentlich die Tabelle von sich aus erstellt werden, aufgrund von
Java:
<property name="hbm2ddl.auto">create</property>
?
 
Zuletzt bearbeitet:
Zurück